Merge branch 'main' into main

This commit is contained in:
Blaine Traudt 2024-09-24 10:44:38 -05:00 committed by GitHub
commit 5495c25073
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
57 changed files with 1317 additions and 424 deletions

View file

@ -7,27 +7,39 @@
{%- endif -%}
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="{{ get_url(path='/feed_style.xsl', trailing_slash=false) | safe }}" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:base="http://purl.org/atompub/base/1.0/" xml:lang="{{ lang }}" xml:base="{{ config.base_url }}">
<str:translations xmlns:str="https://github.com/welpo/tabi">
<str:separator>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{{ lang }}">
<tabi:metadata xmlns:tabi="https://github.com/welpo/tabi">
<tabi:separator>
{{ config.extra.separator | default(value="•") }}
</str:separator>
<str:about_feeds>
</tabi:separator>
<tabi:about_feeds>
{{- macros_translate::translate(key="about_feeds", default="This is a web feed, also known as an Atom feed. Subscribe by copying the URL from the address bar into your newsreader", language_strings=language_strings) -}}
</str:about_feeds>
<str:visit_the_site>
</tabi:about_feeds>
<tabi:visit_the_site>
{{- macros_translate::translate(key="visit_the_site", default="Visit website", language_strings=language_strings) -}}
</str:visit_the_site>
<str:recent_posts>
</tabi:visit_the_site>
<tabi:recent_posts>
{{- macros_translate::translate(key="recent_posts", default="Recent posts", language_strings=language_strings) -}}
</str:recent_posts>
<str:last_updated_on>
</tabi:recent_posts>
<tabi:last_updated_on>
{{- macros_translate::translate(key="last_updated_on", default="Updated on $DATE", language_strings=language_strings) -}}
</str:last_updated_on>
<str:default_theme>
</tabi:last_updated_on>
<tabi:default_theme>
{{- config.extra.default_theme | default(value="") -}}
</str:default_theme>
</str:translations>
</tabi:default_theme>
<tabi:post_listing_date>
{{- config.extra.post_listing_date | default(value="date") -}}
</tabi:post_listing_date>
<tabi:current_section>
{%- if term -%}
{{ term.name }}
{%- elif section.title -%}
{{ section.title }}
{%- else -%}
{{ config.title }}
{%- endif -%}
</tabi:current_section>
</tabi:metadata>
{#- Load extra CSS (skin) if set in config.toml -#}
{%- if config.extra.skin -%}
@ -43,14 +55,15 @@
<subtitle>{{ config.description }}</subtitle>
{%- endif %}
<link href="{{ feed_url | safe }}" rel="self" type="application/atom+xml"/>
<post_listing_date>{{ config.extra.post_listing_date | default(value="date") }}</post_listing_date>
<link href="
{%- if section -%}
{%- if term -%}
{{ term.permalink | escape_xml | safe }}
{%- elif section -%}
{{ section.permalink | escape_xml | safe }}
{%- else -%}
{{ get_url(path="/", lang=lang) | escape_xml | safe }}
{%- endif -%}
"/>
" rel="alternate" type="text/html"/>
<generator uri="https://www.getzola.org/">Zola</generator>
<updated>{{ last_updated | date(format="%+") }}</updated>
<id>{{ feed_url | safe }}</id>

View file

@ -14,9 +14,38 @@ Parameters:
{%- if section -%}
{%- set current_section = section -%}
{%- elif page -%}
{%- set current_section = "" -%}
{#- Retrieve last ancestor to determine current section, if applicable -#}
{%- set last_ancestor = page.ancestors | slice(start=-1) %}
{%- set current_section = get_section(path=last_ancestor.0, metadata_only=true) %}
{%- 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 -%}
{#- We're likely in a nested page. Try to find the parent page or nearest section. -#}
{%- 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 -%}
{#- Check for parent page first. -#}
{%- set page_data = load_data(path=potential_page, required=false) -%}
{%- if page_data -%}
{%- set_global current_section = get_page(path=potential_page) -%}
{%- break -%}
{%- endif -%}
{#- No parent page, check for 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) -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif -%}
{%- set priority_order = [

View file

@ -12,48 +12,94 @@
{%- endif -%}
{# Debugging #}
{# {% set last_ancestor = page.ancestors | slice(start=-1) %}
{% set current_section = get_section(path=last_ancestor.0) %}
{# <div><pre>
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 %}
</pre></div>
{% set settings_to_test = [
"footnote_backlinks",
"add_src_to_code_block",
"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",
] %}
{% set settings_to_test = [
"footnote_backlinks",
"add_src_to_code_block",
"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",
] %}
<table>
<thead>
<tr>
<th>setting</th>
<th>page</th>
<th>section</th>
<th>config</th>
<th>macro output</th>
</tr>
</thead>
<tbody>
{% for setting in settings_to_test %}
<table>
<thead>
<tr>
<td><code>{{ setting }}</code></td>
<td>{{ page.extra[setting] | default(value="⬛") }}</td>
<td>{{ current_section.extra[setting] | default(value="⬛") }}</td>
<td>{{ config.extra[setting] | default(value="⬛") }}</td>
<td>{{ macros_settings::evaluate_setting_priority(setting=setting, page=page) }}</td>
<th>setting</th>
<th>page</th>
<th>section</th>
<th>config</th>
<th>macro output</th>
</tr>
{% endfor %}
</tbody>
</table> #}
</thead>
<tbody>
{% for setting in settings_to_test %}
<tr>
<td><code>{{ setting }}</code></td>
<td>{{ page.extra[setting] | default(value="⬛") }}</td>
<td>{{ current_section.extra[setting] | default(value="⬛") }}</td>
<td>{{ config.extra[setting] | default(value="⬛") }}</td>
<td>{{ macros_settings::evaluate_setting_priority(setting=setting, page=page) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div> #}
{# {{ __tera_context }} #}
{# End debugging #}
@ -134,9 +180,14 @@
</ul>
{% if page.extra.tldr %}
<div class="tldr">
<h3>TL;DR:</h3>
<p>{{ page.extra.tldr }}</p>
<div class="admonition note">
<div class="admonition-icon admonition-icon-note"></div>
<div class="admonition-content">
<strong class="admonition-title">
<span title="Too long; didn't read (summary)">TL;DR</span>
</strong>
<p>{{ page.extra.tldr | markdown | safe }}</p>
</div>
</div>
{% endif %}

View file

@ -21,7 +21,7 @@
<div
title="{{ reset_str }}"
class="theme-resetter"
class="theme-resetter arrow"
tabindex="0"
role="button"
aria-hidden="true"

View file

@ -1,7 +1,30 @@
{%- set start = start | default(value=1) -%}
{%- set end = end | default(value=0) -%}
{#- load_data uses different arguments based on whether it's a remote or local file -#}
{%- if src is starting_with("http") -%}
{%- set response = load_data(url=src, format="plain") -%}
{%- else -%}
{%- set response = load_data(path=src, format="plain") -%}
{#- Try to load the file from a relative path -#}
{%- set colocated_path = page.colocated_path | default(value="") -%}
{%- set relative_path = colocated_path ~ src -%}
{%- set response = load_data(path=relative_path, format="plain", required=false) -%}
{#- If relative path fails, try absolute path -#}
{%- if not response -%}
{%- set response = load_data(path=src, format="plain") -%}
{%- endif -%}
{%- endif -%}
{{- response | trim_end | safe -}}
{%- set lines = response | trim_end | split(pat="\n") -%}
{%- if start > 0 -%}
{%- set start = start - 1 -%}
{%- endif -%}
{%- if end == 0 or end > lines | length -%}
{%- set end = lines | length -%}
{%- endif -%}
{%- set lines = lines | slice(start=start, end=end) -%}
{{- lines | join(sep="\n") | safe -}}