From cb3f6d4467678c567512b45c501d2130c5fd8825 Mon Sep 17 00:00:00 2001 From: SvyatoslavArtymovych Date: Tue, 20 Jun 2023 15:29:21 +0300 Subject: [PATCH] make book-view collections and subcollections as markdown titles #170 --- app/controllers/jinja_globals.py | 14 ++++++++++++-- app/templates/book/collection_view.html | 4 ++-- .../components/sub_collection_preview_content.html | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/controllers/jinja_globals.py b/app/controllers/jinja_globals.py index 892413d..5dac746 100644 --- a/app/controllers/jinja_globals.py +++ b/app/controllers/jinja_globals.py @@ -79,9 +79,19 @@ def build_qa_url_using_interpretation(interpretation: m.Interpretation): # Using: {{ recursive_render("template.html", collection=collection, book=book) }} def recursive_render( - template: str, collection: m.Collection, book: m.Book, version: m.BookVersion = None + template: str, + collection: m.Collection, + book: m.Book, + version: m.BookVersion = None, + loop_index: int = 1, ): - return render_template(template, collection=collection, book=book, version=version) + return render_template( + template, + collection=collection, + book=book, + version=version, + loop_index=loop_index, + ) # Using: {{ has_permission(entity=book, required_permissions=[Access.create]) }} diff --git a/app/templates/book/collection_view.html b/app/templates/book/collection_view.html index 1959281..8295b4a 100644 --- a/app/templates/book/collection_view.html +++ b/app/templates/book/collection_view.html @@ -209,12 +209,12 @@ {% set children_collections = book.active_version.children_collections %} {% endif %} {% for collection in children_collections if not collection.is_root and not collection.is_deleted %}

- #{{collection.label}} + # {{collection.label}}

{% if not collection.active_sections and not collection.active_children %}

Collection is empty

{% endif %} - {{recursive_render("book/components/sub_collection_preview_content.html",collection,book,version)|safe}} + {{recursive_render("book/components/sub_collection_preview_content.html",collection,book,version,2)|safe}} {% endfor %} diff --git a/app/templates/book/components/sub_collection_preview_content.html b/app/templates/book/components/sub_collection_preview_content.html index a7c429b..6b58ecb 100644 --- a/app/templates/book/components/sub_collection_preview_content.html +++ b/app/templates/book/components/sub_collection_preview_content.html @@ -4,7 +4,7 @@ {% for sub_collection in collection.active_children if not sub_collection.is_deleted%}

- ##{{sub_collection.label}} + {{ "#" * loop_index }} {{sub_collection.label}}

{% if not sub_collection.active_sections and not sub_collection.active_children%} @@ -12,7 +12,7 @@ {% endif %} {% if sub_collection.active_children %} -{{recursive_render("book/components/sub_collection_preview_content.html",sub_collection,book)|safe}} +{{recursive_render("book/components/sub_collection_preview_content.html",sub_collection,book, loop_index=loop_index + 1)|safe}} {% else %} {% for section in sub_collection.active_sections %}