From a2ea06d513a5802964f8f0ef5795cec7e548ed7b Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Sat, 13 Sep 2025 14:55:15 -0600 Subject: Squashed 'themes/tabi-lean/' content from commit 95c8796 git-subtree-dir: themes/tabi-lean git-subtree-split: 95c879696445ede40daa7a30a88dae5dd74d5c0c --- templates/page.html | 368 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 368 insertions(+) create mode 100644 templates/page.html (limited to 'templates/page.html') diff --git a/templates/page.html b/templates/page.html new file mode 100644 index 0000000..0dff1a7 --- /dev/null +++ b/templates/page.html @@ -0,0 +1,368 @@ +{% extends "base.html" %} + +{% block main_content %} +{%- set separator = config.extra.separator | default(value="•") -%} + +{%- set rel_attributes = macros_rel_attributes::rel_attributes() | trim -%} + +{%- set blank_target = macros_target_attribute::target_attribute(new_tab=config.markdown.external_links_target_blank) -%} + +{# Debugging #} +{#
+    Page path: {{ page.path }}
+    Page components: {{ page.components | join(sep=", ") }}
+    Page ancestors: {{ page.ancestors | join(sep=", ") }}
+    Current language: {{ lang }}
+    Default language: {{ config.default_language }}
+    Current section: {% if current_section %}{{ current_section.path }}{% else %}None{% endif %}
+    Page extra: {{ page.extra | json_encode() }}
+    {% if section -%}
+        {%- set current_section = section -%}
+    {%- elif page -%}
+        {%- set current_section = "" -%}
+        {%- if page.ancestors | length > 0 -%}
+            {%- set last_ancestor = page.ancestors | slice(start=-1) -%}
+            {%- set_global current_section = get_section(path=last_ancestor.0, metadata_only=true) -%}
+        {%- else -%}
+            {%- set components = page.components -%}
+            {%- for i in range(start=1, end=components | length) -%}
+                {%- if lang == config.default_language -%}
+                    {%- set potential_path = components | slice(end=components | length - i) | join(sep="/") -%}
+                    {%- set potential_page = potential_path ~ "/index.md" -%}
+                    {%- set potential_section = potential_path ~ "/_index.md" -%}
+                {%- else -%}
+                    {%- set potential_path = components | slice(start=1, end=components | length - i) | join(sep="/") -%}
+                    {%- set potential_page = potential_path ~ "/index." ~ lang ~ ".md" -%}
+                    {%- set potential_section = potential_path ~ "/_index." ~ lang ~ ".md" -%}
+                {%- endif -%}
+                Checking parent page: {{ potential_page }}
+                {%- set page_data = load_data(path=potential_page, required=false) -%}
+                {%- if page_data -%}
+                    {%- set_global current_section = get_page(path=potential_page) %}
+    Parent page found: {{ current_section.path }}
+                    {%- break -%}
+                {%- endif -%}
+                Checking section: {{ potential_section }}
+                {%- set section_data = load_data(path=potential_section, required=false) -%}
+                {%- if section_data -%}
+                    {%- set_global current_section = get_section(path=potential_section, metadata_only=true) -%}
+                    Section found: {{ current_section.path }}
+                    {%- break -%}
+                {%- endif -%}
+            {%- endfor -%}
+        {%- endif -%}
+    {%- endif %}
+Found nearest parent/section: {% if current_section %}{{ current_section.path }}{% else %}None{% endif %}
+Current section extra: {% if current_section %}{{ current_section.extra | json_encode() }}{% else %}None{% endif %}
+
+ + {% set settings_to_test = [ + "iine", + "iine_icon", + "enable_cards_tag_filtering", + "footnote_backlinks", + "add_src_to_code_block", + "force_codeblock_ltr", + "copy_button", + "katex", + "quick_navigation_buttons", + "show_reading_time", + "show_date", + "show_author", + "show_remote_changes", + "toc", + "show_previous_next_article_links", + "invert_previous_next_article_links", + "previous_next_article_links_full_width", + "enable_csp", + ] %} + + + + + + + + + + + + + {% for setting in settings_to_test %} + + + + + + + + {% endfor %} + +
settingpagesectionconfigmacro output
{{ setting }}{{ page.extra[setting] | default(value="⬛") }}{{ current_section.extra[setting] | default(value="⬛") }}{{ config.extra[setting] | default(value="⬛") }}{{ macros_settings::evaluate_setting_priority(setting=setting, page=page) }}
+ #} + +{# {{ __tera_context }} #} +{# End debugging #} + +
+
+

+ {{ page.title | markdown(inline=true) | safe }} +

+ + +
    + {#- Draft indicator -#} + {% if page.draft %} +
  • {{ macros_translate::translate(key="draft", default="DRAFT", language_strings=language_strings) }}
  • + {% endif %} + + {#- Author(s) -#} + {%- if page.authors or config.author and macros_settings::evaluate_setting_priority(setting="show_author", page=page, default_global_value=false) == "true" -%} + {%- if page.authors -%} + {%- set author_list = page.authors -%} + {%- else -%} + {%- set author_list = [config.author] -%} + {%- endif -%} + + {%- if author_list | length == 1 -%} + {%- set author_string = '' ~ author_list.0 ~ '' -%} + {%- else -%} + {%- set last_author = author_list | last -%} + {%- set other_authors = author_list | slice(end=-1) -%} + {%- set author_separator = macros_translate::translate(key="author_separator", default=", ", language_strings=language_strings) -%} + {%- set author_separator = '' ~ author_separator ~ '' -%} + {%- set conjunction = macros_translate::translate(key="author_conjunction", default=" and ", language_strings=language_strings) -%} + {%- set conjunction = '' ~ conjunction ~ '' -%} + {%- set author_string = other_authors | join(sep=author_separator) -%} + {%- set author_string = author_string ~ conjunction ~ last_author -%} + {%- set author_string = '' ~ author_string ~ '' -%} + {%- endif -%} + + {%- set by_author = macros_translate::translate(key="by_author", default="By $AUTHOR", language_strings=language_strings) -%} +
  • {{ by_author | replace(from="$AUTHOR", to=author_string) | safe }}
  • + {%- set previous_visible = true -%} + {%- endif -%} + + {%- if config.extra.hcard and config.extra.hcard.enable and ( not author_list or author_list is containing(config.author)) -%} + {% include "partials/hcard_small.html" %} + {%- endif -%} + + {%- set separator_with_class = ""-%} + + {#- Date -#} + {%- if page.date and macros_settings::evaluate_setting_priority(setting="show_date", page=page, default_global_value=true) == "true" -%} +
  • + {#- Variable to keep track of whether we've shown a section, to avoid separators as the first element -#} + {%- set previous_visible = true -%} + {%- endif -%} + + {#- Reading time -#} + {%- if macros_settings::evaluate_setting_priority(setting="show_reading_time", page=page, default_global_value=true) == "true" -%} +
  • {%- if previous_visible -%}{{ separator_with_class | safe }}{%- endif -%}{{ macros_translate::translate(key="min_read", number=page.reading_time, default="$NUMBER min read", language_strings=language_strings) }}
  • + {%- set previous_visible = true -%} + {%- endif -%} + + {#- Tags -#} + {%- if page.taxonomies and page.taxonomies.tags -%} +
  • {%- if previous_visible -%}{{ separator_with_class | safe }}{%- endif -%}{{- macros_translate::translate(key="tags", default="tags", language_strings=language_strings) | capitalize -}}: 
  • + {%- for tag in page.taxonomies.tags -%} +
  • {{ tag }} + {%- if not loop.last -%} + ,  + {%- endif -%} +
  • + {%- endfor -%} + {%- set previous_visible = true -%} + {%- endif -%} + + {#- Last updated on -#} + {% if page.updated %} + {%- set last_updated_str = macros_translate::translate(key="last_updated_on", default="Updated on $DATE", language_strings=language_strings) -%} + {%- set formatted_date = macros_format_date::format_date(date=page.updated, short=true, language_strings=language_strings) -%} + {%- set updated_str = last_updated_str | replace(from="$DATE", to=formatted_date) -%} + {%- set previous_visible = true -%} +
+ + {#- A page is part of a series if one of the sections above (whether it is transparent or not) has the `extra.series` parameter set to true. -#} + {#- As a series might be a transparent section in order to mix up its articles with those of the section just above or the root, -#} + {#- there is no other way but to compute the potential path of each ancestor section related to the page and look for the first one being a series. -#} + {#- Using the `ancestors` field of a section is not possible because transparent sections are not present in this field. -#} + {%- set series_path_components = [] -%} + {%- set section_paths = [] -%} + {%- for path in page.relative_path | split(pat="/") | slice(end=-1) -%} + {%- set_global series_path_components = series_path_components | concat(with=path) -%} + {%- set section_path = series_path_components | concat(with="_index.md") | join(sep="/") -%} + {%- set_global section_paths = section_paths | concat(with=section_path) -%} + {%- endfor -%} + {#- The series the page is part of is the closest section flagged as a series, if any -#} + {%- for section_path in section_paths | reverse -%} + {%- set section_file_exists = load_data(path=section_path, required=false) -%} + {%- if section_file_exists -%} + {%- set loaded_section = get_section(path=section_path,lang=lang) -%} + {%- if "series" in loaded_section.extra and loaded_section.extra.series -%} + {%- set_global series_section = loaded_section -%} + {%- set_global series_ordered_pages = loaded_section.pages -%} + {%- if loaded_section.paginated | default(value=0) > 0 and loaded_section.paginate_reversed -%} + {%- set_global series_ordered_pages = loaded_section.pages | reverse -%} + {%- endif -%} + {%- break -%} + {%- endif -%} + {%- endif -%} + {%- endfor -%} + + {% if page.extra.tldr %} +
+
+
+ + TL;DR + +

{{ page.extra.tldr | markdown | safe }}

+
+
+ {% endif %} + + {#- Optional table of contents below the header -#} + {% if page.toc and macros_settings::evaluate_setting_priority(setting="toc", page=page, default_global_value=false) == "true" %} + {{ macros_toc::toc(page=page, header=true, language_strings=language_strings) }} + {% endif %} + + {#- Optional Summary paragraph for readers -#} + {% if page.description %} + + {%- endif -%} + + +
+ {#- Replace series_intro placeholder -#} + {%- set content_with_intro = page.content -%} + {%- if "" in page.content -%} + {%- set series_intro_html = macros_series_page::get_introduction(page=page, series_section=series_section, series_ordered_pages=series_ordered_pages, language_strings=language_strings) -%} + {%- set content_with_intro = content_with_intro | replace(from="", to=series_intro_html) -%} + {%- elif series_section -%} + {%- set series_intro_html = macros_series_page::get_introduction(page=page, series_section=series_section, series_ordered_pages=series_ordered_pages, language_strings=language_strings) -%} + {%- set content_with_intro = series_intro_html ~ content_with_intro -%} + {%- endif -%} + + {#- Handle series_outro placeholder -#} + {%- set processed_content = content_with_intro -%} + {%- if "" in content_with_intro -%} + {%- set series_outro_html = macros_series_page::get_outro(page=page, series_section=series_section, series_ordered_pages=series_ordered_pages, language_strings=language_strings) -%} + {%- set processed_content = processed_content | replace(from="", to=series_outro_html) -%} + {%- elif series_section -%} + {%- set series_outro_html = macros_series_page::get_outro(page=page, series_section=series_section, series_ordered_pages=series_ordered_pages, language_strings=language_strings) -%} + {#- We want the outro at the end of the article, but before footnote definitions -#} + {%- set footnotes_marker = '
    ' -%} + {%- if footnotes_marker in content_with_intro -%} + {%- set content_sections = processed_content | split(pat=footnotes_marker) -%} + {%- set main_content = content_sections | first -%} + {%- set footnotes_content = content_sections | slice(start=1) | join(sep=footnotes_marker) -%} + {%- set processed_content = main_content ~ series_outro_html ~ footnotes_marker ~ footnotes_content -%} + {%- else -%} + {%- set processed_content = processed_content ~ series_outro_html -%} + {%- endif -%} + {%- endif -%} + + {#- Replace TOC and render final content -#} + {#- The replace pattern is used to enable arbitrary locations for the Table of Contents -#} + {#- This is Philipp Oppermann's workaround: https://github.com/getzola/zola/issues/584#issuecomment-474329637 -#} + {{ processed_content | replace(from="", to=macros_toc::toc(page=page, header=false, language_strings=language_strings)) | safe }} +
+ + {#- iine button -#} + {%- if macros_settings::evaluate_setting_priority(setting="iine", page=page, default_global_value=false) == "true" -%} + {% include "partials/iine_button.html" %} + {%- endif -%} + + {% if macros_settings::evaluate_setting_priority(setting="show_previous_next_article_links", page=page, default_global_value=true) == "true" %} + {%- if page.lower or page.higher -%} + {% set next_label = macros_translate::translate(key="next", default="Next", language_strings=language_strings) %} + {% set prev_label = macros_translate::translate(key="prev", default="Prev", language_strings=language_strings) %} + {% if macros_settings::evaluate_setting_priority(setting="invert_previous_next_article_links", page=page, default_global_value=true) == "true" %} + {% if page.higher %} + {% set left_link = page.higher.permalink %} + {% set left_label = prev_label %} + {% set left_title = page.higher.title %} + {% endif %} + {% if page.lower %} + {% set right_link = page.lower.permalink %} + {% set right_label = next_label %} + {% set right_title = page.lower.title %} + {% endif %} + {% else %} + {% if page.lower %} + {% set left_link = page.lower.permalink %} + {% set left_label = next_label %} + {% set left_title = page.lower.title %} + {% endif %} + {% if page.higher %} + {% set right_link = page.higher.permalink %} + {% set right_label = prev_label %} + {% set right_title = page.higher.title %} + {% endif %} + {% endif %} + {% if macros_settings::evaluate_setting_priority(setting="previous_next_article_links_full_width", page=page, default_global_value=true) == "true" %} + {%- set full_width_class = "full-width" -%} + {% endif %} + + {%- endif -%} + {%- endif -%} + + {#- Comments -#} + {#- Check if comments are enabled, checking that they are not disabled on the specific page -#} + {% set systems = ["giscus", "utterances", "hyvortalk", "isso"] %} + {% set enabled_systems = 0 %} + {% set comment_system = "" %} + + {% for system in systems %} + {% set global_enabled = config.extra[system].enabled_for_all_posts | default(value=false) %} + {% set page_enabled = page.extra[system] | default(value=global_enabled) %} + {% set is_enabled = global_enabled and page_enabled != false or page_enabled == true %} + + {% if is_enabled %} + {% set_global comment_system = system %} + {% set_global enabled_systems = enabled_systems + 1 %} + {% endif %} + {% endfor %} + {#- Ensure only one comment system is enabled -#} + {% if enabled_systems > 1 %} + {{ throw(message="ERROR: Multiple comment systems have been enabled for the same page. Check your config.toml and individual page settings to ensure only one comment system is activated at a time.") }} + {% endif %} + {% if comment_system %} + {% include "partials/comments.html" %} + {% endif %} + + {#- Webmentions -#} + {%- set global_webmentions_enabled = config.extra.webmentions.enable | default(value=false) -%} + {%- set page_webmentions_enabled = page.extra.webmentions | default(value=global_webmentions_enabled) -%} + {%- set webmentions_enabled = global_webmentions_enabled and page_webmentions_enabled != false or page_webmentions_enabled == true -%} + {%- if webmentions_enabled -%} + {%- include "partials/webmentions.html" -%} + {%- endif -%} + +
+
+ +{%- include "partials/extra_features.html" -%} + +{% endblock main_content %} -- cgit v1.2.3