From 35067ea1ad567e8c342a52fba2bd22fb7510ac12 Mon Sep 17 00:00:00 2001
From: linearcombination <4829djaskdfj@gmail.com>
Date: Thu, 2 Jul 2026 15:32:42 -0700
Subject: [PATCH 1/3] Provide option to link to TW word definitions online.
Closes #321
By default this is now True rather than including TW word definitions
in generated documents.
---
backend/doc/config.py | 4 ++++
backend/doc/domain/document_generator.py | 7 ++++++-
backend/doc/utils/tw_utils.py | 19 +++++++++----------
3 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/backend/doc/config.py b/backend/doc/config.py
index a5c63522..41bc44ce 100755
--- a/backend/doc/config.py
+++ b/backend/doc/config.py
@@ -180,6 +180,10 @@ class Settings(BaseSettings):
RESOURCE_TYPE_NAME_FMT_STR: str = "
{}
"
HR: str = "
"
TW_WORD_LIST_VERTICAL: bool = False
+ BIEL_TW_RESOURCE_URL_FMT_STR: str = (
+ "{}"
+ )
+ LINK_RATHER_THAN_INCLUDE_TW_DEFINITIONS: bool = True
DOWNLOAD_ASSETS: bool = False # If true then download assets, else clone assets
diff --git a/backend/doc/domain/document_generator.py b/backend/doc/domain/document_generator.py
index 8032863f..0b5c488b 100755
--- a/backend/doc/domain/document_generator.py
+++ b/backend/doc/domain/document_generator.py
@@ -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
@@ -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)
diff --git a/backend/doc/utils/tw_utils.py b/backend/doc/utils/tw_utils.py
index 23c36471..c1abf7c6 100644
--- a/backend/doc/utils/tw_utils.py
+++ b/backend/doc/utils/tw_utils.py
@@ -23,7 +23,6 @@
)
from doc.utils.list_utils import unique_list_of_strings
-
logger = settings.logger(__name__)
TW = "tw"
@@ -181,8 +180,9 @@ 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,
) -> list[DocumentPart]:
is_rtl = tw_book and tw_book.lang_direction == LangDirEnum.RTL
document_parts: list[DocumentPart] = []
@@ -196,17 +196,19 @@ 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="\n"
- + "\n".join(
+ content=""
+ + ", ".join(
[
- f"
- {localized_word}
"
+ biel_tw_resource_path_fmt_str.format(
+ tw_book.lang_code, localized_word
+ )
for localized_word, word in unique_words
]
)
- + "",
+ + "
",
is_rtl=is_rtl,
use_section_visual_separator=False,
)
@@ -221,9 +223,6 @@ def translation_words_content(
for localized_word, word in unique_words
]
)
- + "
",
- is_rtl=is_rtl,
- use_section_visual_separator=False,
)
)
return document_parts
From 21012970c6314c4e533da44030cff4ca909c5771 Mon Sep 17 00:00:00 2001
From: linearcombination <4829djaskdfj@gmail.com>
Date: Thu, 9 Jul 2026 17:03:11 -0700
Subject: [PATCH 2/3] Fix issue with regression when
LINK_RATHER_THAN_INCLUDE_TW_DEFINITIONS is False
Fixed issue raised in code review. Also clean up code a bit to remove
magic strings
---
backend/doc/config.py | 1 +
backend/doc/utils/tw_utils.py | 16 ++++++++++++----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/backend/doc/config.py b/backend/doc/config.py
index 41bc44ce..fceaac80 100755
--- a/backend/doc/config.py
+++ b/backend/doc/config.py
@@ -183,6 +183,7 @@ class Settings(BaseSettings):
BIEL_TW_RESOURCE_URL_FMT_STR: str = (
"{}"
)
+ TW_RESOURCE_URL_FMT_STR: str = "{}"
LINK_RATHER_THAN_INCLUDE_TW_DEFINITIONS: bool = True
DOWNLOAD_ASSETS: bool = False # If true then download assets, else clone assets
diff --git a/backend/doc/utils/tw_utils.py b/backend/doc/utils/tw_utils.py
index c1abf7c6..55692aea 100644
--- a/backend/doc/utils/tw_utils.py
+++ b/backend/doc/utils/tw_utils.py
@@ -183,6 +183,9 @@ def translation_words_content(
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_close: str = "
",
) -> list[DocumentPart]:
is_rtl = tw_book and tw_book.lang_direction == LangDirEnum.RTL
document_parts: list[DocumentPart] = []
@@ -199,7 +202,7 @@ def translation_words_content(
if link_rather_than_include_tw_definitions:
document_parts.append(
DocumentPart(
- content=""
+ content=div_open
+ ", ".join(
[
biel_tw_resource_path_fmt_str.format(
@@ -208,7 +211,7 @@ def translation_words_content(
for localized_word, word in unique_words
]
)
- + "
",
+ + div_close,
is_rtl=is_rtl,
use_section_visual_separator=False,
)
@@ -216,13 +219,18 @@ def translation_words_content(
else:
document_parts.append(
DocumentPart(
- content=""
+ content=div_open
+ ", ".join(
[
- f"{localized_word}"
+ tw_resource_path_fmt_str.format(
+ tw_book.lang_code, word, localized_word
+ )
for localized_word, word in unique_words
]
)
+ + div_close,
+ is_rtl=is_rtl,
+ use_section_visual_separator=False,
)
)
return document_parts
From 1ee21f4df3bcec4725de0004e97d6df905362242 Mon Sep 17 00:00:00 2001
From: linearcombination <4829djaskdfj@gmail.com>
Date: Thu, 9 Jul 2026 17:04:49 -0700
Subject: [PATCH 3/3] Remove unused configuration constant
---
.env | 6 ------
backend/doc/config.py | 1 -
2 files changed, 7 deletions(-)
diff --git a/.env b/.env
index 49173870..58624d86 100644
--- a/.env
+++ b/.env
@@ -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
diff --git a/backend/doc/config.py b/backend/doc/config.py
index fceaac80..10294c59 100755
--- a/backend/doc/config.py
+++ b/backend/doc/config.py
@@ -179,7 +179,6 @@ class Settings(BaseSettings):
BOOK_NAME_FMT_STR: str = "{}
"
RESOURCE_TYPE_NAME_FMT_STR: str = "{}
"
HR: str = "
"
- TW_WORD_LIST_VERTICAL: bool = False
BIEL_TW_RESOURCE_URL_FMT_STR: str = (
"{}"
)