Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ CHECK_ALL_BOOKS_FOR_LANGUAGE=true
# they all are available by cloning, hence the value false.
DOWNLOAD_ASSETS=false

# Setting to false will cause interleave by verse layout to put each
# TW word associated with the verse in a horizontal comma delimited
# list, otherwise it will put each TW word in a list with one word per
# line.
TW_WORD_LIST_VERTICAL=false

# File lock duration when cloning and potentially removing git repos
LOCK_TIMEOUT_SECONDS=300

Expand Down
6 changes: 5 additions & 1 deletion backend/doc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ class Settings(BaseSettings):
BOOK_NAME_FMT_STR: str = "<h2 class='book-name'>{}</h2>"
RESOURCE_TYPE_NAME_FMT_STR: str = "<h1 class='book-name'>{}</h1>"
HR: str = "<hr/>"
TW_WORD_LIST_VERTICAL: bool = False
BIEL_TW_RESOURCE_URL_FMT_STR: str = (
"<span><a href='https://bibleineverylanguage.org/resources/languages/{}?resource-type=tw'>{}</a></span>"
)
TW_RESOURCE_URL_FMT_STR: str = "<span><a href='#{}-{}'>{}</a></span>"
LINK_RATHER_THAN_INCLUDE_TW_DEFINITIONS: bool = True

DOWNLOAD_ASSETS: bool = False # If true then download assets, else clone assets

Expand Down
7 changes: 6 additions & 1 deletion backend/doc/domain/document_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ def assemble_content(
tw_books: Sequence[TWBook],
bc_books: Sequence[BCBook],
rg_books: Sequence[RGBook],
link_rather_than_include_tw_definitions: bool = settings.LINK_RATHER_THAN_INCLUDE_TW_DEFINITIONS,
) -> list[DocumentPart]:
"""
Assemble and return the content from all requested resources according to the
Expand Down Expand Up @@ -652,7 +653,11 @@ def assemble_content(
)
t1 = time.time()
logger.info("Time for interleaving document: %s", t1 - t0)
if tw_books and not document_request.layout_for_print:
if (
tw_books
and not link_rather_than_include_tw_definitions
and not document_request.layout_for_print
):
t0 = time.time()
# Add the translation words definition section for each language requested.
unique_tw_books = filter_unique_by_lang_code(tw_books)
Expand Down
27 changes: 17 additions & 10 deletions backend/doc/utils/tw_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
)
from doc.utils.list_utils import unique_list_of_strings


logger = settings.logger(__name__)

TW = "tw"
Expand Down Expand Up @@ -181,8 +180,12 @@ def translation_words_content(
tw_book: TWBook,
content: str,
use_section_visual_separator: bool,
tw_word_list_vertical: bool = settings.TW_WORD_LIST_VERTICAL,
link_rather_than_include_tw_definitions: bool = settings.LINK_RATHER_THAN_INCLUDE_TW_DEFINITIONS,
resource_type_name_fmt_str: str = settings.RESOURCE_TYPE_NAME_FMT_STR,
biel_tw_resource_path_fmt_str: str = settings.BIEL_TW_RESOURCE_URL_FMT_STR,
tw_resource_path_fmt_str: str = settings.TW_RESOURCE_URL_FMT_STR,
div_open: str = "<div>",
div_close: str = "</div>",
) -> list[DocumentPart]:
is_rtl = tw_book and tw_book.lang_direction == LangDirEnum.RTL
document_parts: list[DocumentPart] = []
Expand All @@ -196,32 +199,36 @@ def translation_words_content(
use_section_visual_separator=False,
)
)
if tw_word_list_vertical:
if link_rather_than_include_tw_definitions:
document_parts.append(
DocumentPart(
content="<ul>\n"
+ "\n".join(
content=div_open
+ ", ".join(
[
f"<li><a href='#{tw_book.lang_code}-{word}'>{localized_word}</a></li>"
biel_tw_resource_path_fmt_str.format(
tw_book.lang_code, localized_word
)
for localized_word, word in unique_words
]
)
+ "</ul>",
+ div_close,
is_rtl=is_rtl,
use_section_visual_separator=False,
)
)
else:
document_parts.append(
DocumentPart(
content="<ul>"
content=div_open
+ ", ".join(
[
f"<span><a href='#{tw_book.lang_code}-{word}'>{localized_word}</a></span>"
tw_resource_path_fmt_str.format(
tw_book.lang_code, word, localized_word
)
for localized_word, word in unique_words
]
)
+ "</ul>",
+ div_close,
is_rtl=is_rtl,
use_section_visual_separator=False,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these lines deleted on purpose? It seems like we would still need them if link_rather_than_include_tw_definitions is reset to false at some point in the future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that, unintentional. I did a bit of clean up too.

)
Expand Down
Loading