diff options
| author | Alejandro Soto <alejandro@34project.org> | 2025-09-13 15:01:06 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2025-09-13 15:01:06 -0600 |
| commit | f4fcda54638685899c730b3fa90a87d80d6dbef5 (patch) | |
| tree | 0737e627cce304c3a9c4e757bc5f6571a7456091 /sysret.org/themes/tabi-lean/templates | |
| parent | d8b9cf1f61cc07d625f1c37ccc28adfd58918416 (diff) | |
| parent | 2c13119932765c6d788f08fb53abc244407c0d80 (diff) | |
Merge commit '6a7d3111b31e73fc66af5360149d41f690fbcaa4'
Diffstat (limited to 'sysret.org/themes/tabi-lean/templates')
70 files changed, 3362 insertions, 0 deletions
diff --git a/sysret.org/themes/tabi-lean/templates/404.html b/sysret.org/themes/tabi-lean/templates/404.html new file mode 100644 index 0000000..4c19dac --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/404.html @@ -0,0 +1,34 @@ +{% extends "page.html" %} + +{% macro display_404_message(language_name) %} + {%- set language_strings = load_data(path="i18n/" ~ language_name ~ '.toml', required=false) -%} + {%- if not language_strings -%} + {%- set language_strings = load_data(path="themes/tabi/i18n/" ~ language_name ~ '.toml', required=false) -%} + {%- endif -%} + <p>{{ macros_translate::translate(key="page_missing", default="The page you've requested seems to be missing", force_lang=language_name, language_strings=language_strings) }} + {%- if config.languages | length > 0 -%} + {{ macros_translate::translate(key="translation_missing", default="or hasn't been translated into your language yet", force_lang=language_name, language_strings=language_strings) }}{{ macros_translate::translate(key="full_stop", default=".", force_lang=language_name, language_strings=language_strings) }} + {%- else %}. + {%- endif %}<br> + {{ macros_translate::translate(key="check_url", default="Check the URL for errors or", force_lang=language_name, language_strings=language_strings) }} + <a href="{{ config.base_url }}{% if language_name != config.default_language %}/{{ language_name }}{% endif %}/"> + {{ macros_translate::translate(key="go_home", default="go back to the homepage", force_lang=language_name, language_strings=language_strings) }}</a>{{ macros_translate::translate(key="full_stop", default=".", force_lang=language_name, language_strings=language_strings) }}</p> +{% endmacro %} + +{% block main_content %} + <main class="centered-text"> + {{ macros_page_header::page_header(title="404")}} + <div class="subheader">{{ macros_translate::translate(key="not_found") }}</div> + + {# 404 message for base language #} + {{ self::display_404_message(language_name=config.default_language, is_multilingual=is_multilingual) }} + + {#- Iterate through each extra language, to display the localised 404 message -#} + {%- for language_name, language in config.languages -%} + {%- if language_name == config.default_language -%} + {%- continue -%} {#- We've already displayed the 404 message for the base language -#} + {%- endif -%} + {{ self::display_404_message(language_name=language_name, is_multilingual=is_multilingual) }} + {%- endfor -%} + </main> +{% endblock main_content %} diff --git a/sysret.org/themes/tabi-lean/templates/anchor-link.html b/sysret.org/themes/tabi-lean/templates/anchor-link.html new file mode 100644 index 0000000..254dbe3 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/anchor-link.html @@ -0,0 +1 @@ +<a class="header-anchor no-hover-padding" href="#{{ id }}" aria-label="Anchor link for: {{ id }}"><span class="link-icon" aria-hidden="true"></span></a> diff --git a/sysret.org/themes/tabi-lean/templates/archive.html b/sysret.org/themes/tabi-lean/templates/archive.html new file mode 100644 index 0000000..637b414 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/archive.html @@ -0,0 +1,89 @@ +{% extends "base.html" %} + +{% block main_content %} + +{{ macros_page_header::page_header(title=section.title) }} + +{# Set locale for date #} +{% set date_locale = macros_translate::translate(key="date_locale", default="en_GB", language_strings=language_strings) %} + +{#- Check for language-specific date formats -#} +{%- set language_format = "" -%} +{%- if config.extra.date_formats -%} + {%- for format_config in config.extra.date_formats -%} + {%- if format_config.lang == lang -%} + {%- if format_config.archive -%} + {%- set_global language_format = format_config.archive -%} + {%- endif -%} + {%- endif -%} + {%- endfor -%} +{%- endif -%} + +<div class="archive"> + <ul class="list-with-title"> + {%- set source_paths = section.extra.section_path | default(value="blog/") -%} + {%- if source_paths is iterable -%} + {%- set paths = source_paths -%} + {%- else -%} + {%- set paths = [source_paths] -%} + {%- endif %} + {%- set all_posts = [] -%} + {%- for path in paths -%} + {%- if lang == config.default_language %} + {%- set section_item = get_section(path=path ~ "_index.md") -%} + {%- else %} + {%- set section_item = get_section(path=path ~ "_index." ~ lang ~ ".md") -%} + {%- endif %} + {%- set_global all_posts = all_posts | concat(with=section_item.pages) -%} + {%- endfor %} + + {# Sort all posts by date #} + {%- set archive_reverse = section.extra.archive_reverse | default(value=false) -%} + {%- set all_posts = all_posts | sort(attribute="date") -%} + {%- if not archive_reverse -%} + {%- set all_posts = all_posts | reverse -%} + {%- endif -%} + + {# Group posts by year. #} + {% set posts_by_year = all_posts | group_by(attribute="year") %} + {% set years = [] %} + {% for year, ignored in posts_by_year %} + {% set_global years = years | concat(with=[year]) %} + {% endfor %} + + {# Iterate over years #} + {% set years = years | sort %} + {%- if not archive_reverse -%} + {%- set years = years | reverse -%} + {%- endif -%} + + {% for year in years %} + {% set posts = posts_by_year[year] %} + {% if posts | length > 0 %} + <li> + <h2 class="listing-title">{{ year }}</h2> + <ul class="listing"> + {% for post in posts %} + <li class="listing-item"> + <div class="post-time"> + <span class="date"> + {%- if language_format -%} + {{ post.date | date(format=language_format, locale=date_locale) }} + {%- elif config.extra.archive_date_format -%} + {{ post.date | date(format=config.extra.archive_date_format, locale=date_locale) }} + {%- else -%} + {{ post.date | date(format="%d %b", locale=date_locale) }} + {%- endif -%} + </span> + </div> + <a href="{{ post.permalink }}" title="{{ post.title }}">{{ post.title | markdown(inline=true) | safe }}</a> + </li> + {% endfor %} + </ul> + </li> + {% endif %} + {% endfor %} + </ul> +</div> + +{% endblock main_content %} diff --git a/sysret.org/themes/tabi-lean/templates/atom.xml b/sysret.org/themes/tabi-lean/templates/atom.xml new file mode 100644 index 0000000..3e5b55c --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/atom.xml @@ -0,0 +1,110 @@ +{%- import "macros/translate.html" as macros_translate -%} +{%- import "macros/settings.html" as macros_settings -%} +{#- Load the internationalisation data -#} +{%- set language_strings = load_data(path="i18n/" ~ lang ~ '.toml', required=false) -%} +{%- if not language_strings -%} + {%- set language_strings = load_data(path="themes/tabi/i18n/" ~ lang ~ ".toml", required=false) -%} +{%- 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" xml:lang="{{ lang }}"> + <tabi:metadata xmlns:tabi="https://github.com/welpo/tabi"> + <tabi:base_url>{{ config.base_url }}</tabi:base_url> + <tabi:separator> + {{ config.extra.separator | default(value="•") }} + </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) -}} + </tabi:about_feeds> + <tabi:visit_the_site> + {{- macros_translate::translate(key="visit_the_site", default="Visit website", language_strings=language_strings) -}} + </tabi:visit_the_site> + <tabi:recent_posts> + {{- macros_translate::translate(key="recent_posts", default="Recent posts", language_strings=language_strings) -}} + </tabi:recent_posts> + <tabi:last_updated_on> + {{- macros_translate::translate(key="last_updated_on", default="Updated on $DATE", language_strings=language_strings) -}} + </tabi:last_updated_on> + <tabi:default_theme> + {{- config.extra.default_theme | default(value="") -}} + </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 -%} + <link rel="extra-stylesheet" href="{{ get_url(path='skins/' ~ config.extra.skin ~ '.css', cachebust=true) | safe }}" /> + {%- endif -%} + + <title>{{ config.title | striptags | safe }} + {%- if term %} - {{ term.name }} + {%- elif section.title %} - {{ section.title }} + {%- endif -%} + </title> + {%- if config.description %} + <subtitle>{{ config.description }}</subtitle> + {%- endif %} + <link href="{{ feed_url | safe }}" rel="self" type="application/atom+xml"/> + <link href=" + {%- 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> + {%- if last_updated -%} + <updated>{{ last_updated | date(format="%+") }}</updated> + {%- endif -%} + <id>{{ feed_url | safe }}</id> + {%- for page in pages %} + {%- if macros_settings::evaluate_setting_priority(setting="hide_from_feed", page=page, default_global_value=false) == "true" -%} + {%- continue -%} + {%- endif -%} + {#- Skip if hide_from_main_feed is true and this is the main feed -#} + {%- if macros_settings::evaluate_setting_priority(setting="hide_from_main_feed", page=page, default_global_value=false) == "true" + and not section + and not term -%} + {%- continue -%} + {%- endif -%} + <entry xml:lang="{{ page.lang }}"> + <title>{{ page.title }}</title> + <published>{{ page.date | date(format="%+") }}</published> + <updated>{{ page.updated | default(value=page.date) | date(format="%+") }}</updated> + <author> + <name> + {%- if page.authors -%} + {{ page.authors[0] }} + {%- elif config.author -%} + {{ config.author }} + {%- else -%} + Unknown + {%- endif -%} + </name> + </author> + <link rel="alternate" href="{{ page.permalink | safe }}" type="text/html"/> + <id>{{ page.permalink | safe }}</id> + {% if config.extra.full_content_in_feed %} + <content type="html">{{ page.content }}</content> + {% endif -%} + {% if page.description -%} + <summary type="html">{{ page.description }}</summary> + {% elif page.summary -%} + <summary type="html">{{ page.summary | striptags | trim_end_matches(pat=".") | safe }}…</summary> + {% endif -%} + </entry> + {%- endfor %} +</feed> diff --git a/sysret.org/themes/tabi-lean/templates/base.html b/sysret.org/themes/tabi-lean/templates/base.html new file mode 100644 index 0000000..56f2a65 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/base.html @@ -0,0 +1,51 @@ +{% import "macros/feed_utils.html" as feed_utils %} +{% import "macros/format_date.html" as macros_format_date %} +{% import "macros/list_posts.html" as macros_list_posts %} +{% import "macros/page_header.html" as macros_page_header %} +{% import "macros/rel_attributes.html" as macros_rel_attributes %} +{% import "macros/series_page.html" as macros_series_page %} +{% import "macros/settings.html" as macros_settings %} +{% import "macros/table_of_contents.html" as macros_toc %} +{% import "macros/target_attribute.html" as macros_target_attribute %} +{% import "macros/translate.html" as macros_translate %} + +{# Load the internationalisation data for the current language from +the .toml files in the user's '/i18n' folder, falling back to the theme's. +This variable will hold all the text strings for the language #} +{%- set language_strings = load_data(path="i18n/" ~ lang ~ '.toml', required=false) -%} +{%- if not language_strings -%} + {%- set language_strings = load_data(path="themes/tabi/i18n/" ~ lang ~ ".toml", required=false) -%} +{%- endif -%} +{% set rtl_languages = ["ar", "arc", "az", "dv", "ff", "he", "ku", "nqo", "fa", "rhg", "syc", "ur"] %} + +{#- Necessary for the hierarchy macro -#} +{%- if page -%} + {%- set current_page = page -%} +{%- else -%} + {%- set current_page = ""-%} +{%- endif -%} + +<!DOCTYPE html> +<html lang="{{ lang }}" {% if config.extra.default_theme -%} + data-theme="{{config.extra.default_theme}}" +{%- endif -%}{% if macros_settings::evaluate_setting_priority(setting="force_codeblock_ltr", page=current_page, default_global_value=true) == "false" -%} + data-code-direction="inherit"{% endif %}> + +{% include "partials/header.html" %} + +<body{% if lang in rtl_languages %} dir="rtl"{% endif %}{% if config.extra.override_serif_with_sans %} class="use-sans-serif"{% endif %}> + {% include "partials/nav.html" %} + <div class="content"> + + {# Post page is the default #} + {% block main_content %} + Nothing here?! + {% endblock main_content %} + </div> + {% include "partials/footer.html" %} + + {# Users can optionally provide this template to add content to the body element. #} + {% include "tabi/extend_body.html" ignore missing %} +</body> + +</html> diff --git a/sysret.org/themes/tabi-lean/templates/cards.html b/sysret.org/themes/tabi-lean/templates/cards.html new file mode 100644 index 0000000..451f6b2 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/cards.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} + +{% block main_content %} + {% if section.extra.section_path -%} + {% set section = get_section(path=section.extra.section_path) %} + {% endif -%} + + {{ macros_page_header::page_header(title=section.title) }} + + <main> + {% if section.content -%} + <div id="page-content">{{ section.content | safe }}</div> + {% endif %} + + {%- if paginator %} + {%- set show_pages = paginator.pages -%} + {% else %} + {%- set show_pages = section.pages -%} + {% endif -%} + + {%- if macros_settings::evaluate_setting_priority(setting="enable_cards_tag_filtering", page=section, default_global_value=true) == "true" -%} + {%- include "partials/filter_card_tags.html" -%} + {%- endif -%} + + + {%- include "partials/cards_pages.html" -%} + </main> + + {% if paginator %} + {%- include "partials/paginate.html" -%} + {% endif %} +{% endblock main_content %} diff --git a/sysret.org/themes/tabi-lean/templates/index.html b/sysret.org/themes/tabi-lean/templates/index.html new file mode 100644 index 0000000..d0dfc01 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/index.html @@ -0,0 +1 @@ +{% extends "section.html" %} diff --git a/sysret.org/themes/tabi-lean/templates/info-page.html b/sysret.org/themes/tabi-lean/templates/info-page.html new file mode 100644 index 0000000..077b1a1 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/info-page.html @@ -0,0 +1,21 @@ +{# Template for non-articles (About Me, Privacy…) #} + +{% extends "base.html" %} + +{%- block main_content %} + +{%- set page_or_section = page | default(value=section) -%} + +{{ macros_page_header::page_header(title=page_or_section.title) }} + +<div id="page-content"> + <main> + {# 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 #} + {{ page_or_section.content | replace(from="<!-- toc -->", to=macros_toc::toc(page=page_or_section, header=false, language_strings=language_strings)) | safe }} + </main> +</div> + +{%- include "partials/extra_features.html" -%} + +{%- endblock main_content %} diff --git a/sysret.org/themes/tabi-lean/templates/internal/alias.html b/sysret.org/themes/tabi-lean/templates/internal/alias.html new file mode 100644 index 0000000..f56f769 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/internal/alias.html @@ -0,0 +1,13 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <link rel="canonical" href="{{ url | safe }}"> + <link rel="stylesheet" href="{{ get_url(path="main.css", cachebust=true) | safe }}" /> + <meta http-equiv="refresh" content="0; url={{ url | safe }}"> + <title>Redirect</title> +</head> +<body class="center-content"> + <h1><a href="{{ url | safe }}">Click here</a> to be redirected.</h1> +</body> +</html> diff --git a/sysret.org/themes/tabi-lean/templates/macros/feed_utils.html b/sysret.org/themes/tabi-lean/templates/macros/feed_utils.html new file mode 100644 index 0000000..ff35194 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/macros/feed_utils.html @@ -0,0 +1,17 @@ +{#- Feed utility macros -#} + +{#- Zola 0.19.0 uses `generate_feeds`. Prior versions use `generate_feed` -#} +{%- macro get_generate_feed() -%} + {{- config.generate_feeds | default(value=config.generate_feed) -}} +{%- endmacro get_generate_feed -%} + +{%- macro get_feed_url() -%} + {{- config.feed_filenames[0] | default(value=(config.feed_filename)) -}} +{%- endmacro get_feed_url -%} + +{#- Check footer feed icon conditions -#} +{%- macro should_show_footer_feed_icon() -%} + {%- set generate_feed = feed_utils::get_generate_feed() == "true" -%} + {%- set feed_url = feed_utils::get_feed_url() -%} + {{- generate_feed and config.extra.feed_icon and feed_url -}} +{%- endmacro should_show_footer_feed_icon -%} diff --git a/sysret.org/themes/tabi-lean/templates/macros/format_date.html b/sysret.org/themes/tabi-lean/templates/macros/format_date.html new file mode 100644 index 0000000..f747fd1 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/macros/format_date.html @@ -0,0 +1,59 @@ +{%- macro format_date(date, short, language_strings="") -%} + +{#- Set locale -#} +{%- set date_locale = macros_translate::translate(key="date_locale", default="en_GB", language_strings=language_strings) -%} + +{#- Check for language-specific date formats -#} +{%- set language_format = "" -%} +{%- if config.extra.date_formats -%} + {%- for format_config in config.extra.date_formats -%} + {%- if format_config.lang == lang -%} + {%- if short and format_config.short -%} + {%- set_global language_format = format_config.short -%} + {%- elif not short and format_config.long -%} + {%- set_global language_format = format_config.long -%} + {%- endif -%} + {%- endif -%} + {%- endfor -%} +{%- endif -%} + +{%- if language_format -%} + {{ date | date(format=language_format, locale=date_locale) }} +{%- elif config.extra.short_date_format and short -%} + {{ date | date(format=config.extra.short_date_format, locale=date_locale) }} +{%- elif config.extra.long_date_format and not short -%} + {{ date | date(format=config.extra.long_date_format, locale=date_locale) }} +{%- elif not config.extra.short_date_format and date_locale == "en_GB" -%} + {%- set day = date | date(format='%-d') | int -%} + + {%- if day in [11, 12, 13] -%} + {%- set suffix = "th" -%} + {%- else -%} + {%- set last_digit = day % 10 -%} + {%- if last_digit == 1 -%} + {%- set suffix = "st" -%} + {%- elif last_digit == 2 -%} + {%- set suffix = "nd" -%} + {%- elif last_digit == 3 -%} + {%- set suffix = "rd" -%} + {%- else -%} + {%- set suffix = "th" -%} + {%- endif -%} + {%- endif -%} + + {#- Return the date. -#} + {{ date | date(format="%-d") }}{{ suffix }} + {%- if short == true -%} + {{ date | date(format=" %b %Y") }} + {%- else -%} + {{ date | date(format=" %B %Y") }} + {%- endif -%} +{%- else -%} + {%- if short -%} + {{ date | date(format="%-d %b %Y", locale=date_locale) }} + {%- else -%} + {{ date | date(format="%d %b %Y", locale=date_locale) }} + {%- endif -%} +{%- endif -%} + +{%- endmacro -%} diff --git a/sysret.org/themes/tabi-lean/templates/macros/list_posts.html b/sysret.org/themes/tabi-lean/templates/macros/list_posts.html new file mode 100644 index 0000000..2076194 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/macros/list_posts.html @@ -0,0 +1,163 @@ +{# `metadata` can be "dates", "indexes" or both (e.g. "dates indexes" or "indexes dates"). #} +{# If both, the order doesn't matter and indexes will always be displayed before dates. #} +{# It would also work with arrays (e.g. ["dates"] or ["indexes"] or even ["indexes","dates"]). #} +{# Nevertheless, arrays cannot be used as a default value for a macro parameter in Tera (see https://github.com/Keats/tera/issues/710). #} +{# `paginator` is only used to compute indexes metadata and can be let empty otherwise. #} +{% macro list_posts(posts, all_posts="", max=999999, metadata="dates", language_strings="", section_path="", paginator="", pinned_first=false, current_page=1) %} + +{%- set separator = config.extra.separator | default(value="•") -%} + +{# Separate pinned and regular posts from all_posts if available, otherwise from posts #} +{% if pinned_first %} + {% set source_posts = all_posts | default(value=posts) %} + {% set pinned_posts = [] %} + {% set regular_posts = [] %} + {% for post in source_posts %} + {% if post.extra.pinned %} + {% set_global pinned_posts = pinned_posts | concat(with=post) %} + {% else %} + {% set_global regular_posts = regular_posts | concat(with=post) %} + {% endif %} + {% endfor %} + + {# On page 1 or when no pagination, show pinned then regular #} + {% if current_page == 1 %} + {% if paginator %} + {# With pagination: pinned + current page's posts #} + {% set display_posts = pinned_posts | concat(with=posts) %} + {% else %} + {# Without pagination: pinned + regular (no duplicates) #} + {% set display_posts = pinned_posts | concat(with=regular_posts) %} + {% endif %} + {% else %} + {% set display_posts = posts %} + {% endif %} +{% else %} + {% set display_posts = posts %} +{% endif %} + +<div class="bloglist-container"> + {# Display posts #} + {% for post in display_posts %} + {% if loop.index <= max %} + {% if loop.index == max or loop.last %} + {% set bottom_divider = false %} + {% else %} + {% set bottom_divider = true %} + {% endif %} + + <section class="bloglist-meta {% if bottom_divider -%}bottom-divider{%- endif -%}"> + <ul> + {%- if "indexes" in metadata -%} + {%- set post_index = loop.index -%} + {%- set number_of_posts = posts | length -%} + {# in case we have a pager, the index has been computed for the current page. #} + {%- if paginator -%} + {%- set number_of_posts = paginator.total_pages -%} + {%- set number_of_other_pages = paginator.current_index - 1 -%} + {%- set posts_per_page = paginator.paginate_by -%} + {%- set posts_in_other_pages = number_of_other_pages * posts_per_page -%} + {%- set post_index = posts_in_other_pages + post_index -%} + {%- endif -%} + {%- if macros_settings::evaluate_setting_priority(setting="post_listing_index_reversed", page=section, default_global_value=false) == "true" -%} + {# index starts at 1 instead of 0 #} + {%- set post_index = number_of_posts + 1 - post_index -%} + {%- endif -%} + <li class="index-label">{{ post_index }}</li> + {%- endif -%} + + {%- if "dates" in metadata -%} + {%- set allowed_post_listing_dates = ["date", "updated", "both"] -%} + {#- Calling the hierarchy macro here causes an error due to the "get parents" part of the macro. -#} + {#- This seems cleaner. -#} + {%- set post_listing_date = section.extra.post_listing_date | default(value=config.extra.post_listing_date) | default(value="date") -%} + {%- if post_listing_date not in allowed_post_listing_dates -%} + {{ throw(message="ERROR: Invalid value for config.extra.post_listing_date. Allowed values are 'date', 'updated', or 'both'.") }} + {%- endif -%} + + {%- set show_date = post.date and post_listing_date == "date" or post.date and post_listing_date == "both" or post.date and post_listing_date == "updated" and not post.updated -%} + {%- set show_updated = post.updated and post_listing_date == "updated" or post.updated and post_listing_date == "both" -%} + + {%- if show_date or show_updated -%} + {%- if show_date -%} + <li class="date">{{- macros_format_date::format_date(date=post.date, short=false, language_strings=language_strings) -}}</li> + {%- endif -%} + {%- if show_date and show_updated -%} + <li class="mobile-only separator">{{- separator -}}</li> + {%- endif -%} + {%- if show_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=post.updated, short=true, language_strings=language_strings) -%} + {%- set updated_str = last_updated_str | replace(from="$DATE", to=formatted_date) -%} + <li class="date">{{ updated_str }}</li> + {%- endif -%} + {%- endif -%} + {%- endif -%} + + {% if post.extra.local_image or post.extra.remote_image %} + <li class="post-thumbnail"> + <a href="{{ post.permalink }}"> + {% if post.extra.local_image %} + {% set meta = get_image_metadata(path=post.extra.local_image, allow_missing=true) %} + <img class="thumbnail-image" + alt="{{ post.extra.local_image }}" + src="{{ get_url(path=post.extra.local_image) }}" + {% if meta.width %}width="{{ meta.width }}"{% endif %} + {% if meta.height %}height="{{ meta.height }}"{% endif %}> + {% elif post.extra.remote_image %} + <img class="thumbnail-image" + alt="{{ post.extra.remote_image }}" + src="{{ post.extra.remote_image }}"> + {% endif %} + </a> + </li> + {% endif %} + + {% if post.draft %} + <li class="draft-label">{{ macros_translate::translate(key="draft", default="DRAFT", language_strings=language_strings) }}</li> + {% endif %} + </ul> + </section> + + <section class="bloglist-content {% if bottom_divider -%}bottom-divider{%- endif -%}"> + <div> + {% if pinned_first and post.extra.pinned %} + <div class="pinned-label"> + <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M10.5 2.255v-.01c.003-.03.013-.157-.361-.35C9.703 1.668 8.967 1.5 8 1.5s-1.703.169-2.138.394c-.375.194-.365.32-.362.351v.01c-.003.03-.013.157.362.35C6.297 2.832 7.033 3 8 3s1.703-.169 2.139-.394c.374-.194.364-.32.361-.351M12 2.25c0 .738-.433 1.294-1.136 1.669l.825 2.31c1.553.48 2.561 1.32 2.561 2.52c0 1.854-2.402 2.848-5.5 2.985V15a.75.75 0 0 1-1.5 0v-3.266c-3.098-.136-5.5-1.131-5.5-2.984c0-1.2 1.008-2.04 2.561-2.52l.825-2.311C4.433 3.544 4 2.988 4 2.25C4 .75 5.79 0 8 0s4 .75 4 2.25" clip-rule="evenodd"/></svg> + <span>{{ macros_translate::translate(key="pinned", default="Pinned", language_strings=language_strings) }}</span> + </div> + {% endif %} + + <h2 class="bloglist-title"> + <a href="{{ post.permalink }}">{{ post.title }}</a> + </h2> + + {% if post.taxonomies.tags %} + <div class="bloglist-tags"> + {% for tag in post.taxonomies.tags %} + <a class="tag" href="{{ get_taxonomy_url(kind='tags', name=tag, lang=lang) | safe }}">{{ tag }}</a> + {% endfor %} + </div> + {% endif %} + + <div class="description"> + {% if post.description %} + <p>{{ post.description | markdown(inline=true) | safe }}</p> + {% elif post.summary %} + <p>{{ post.summary | markdown(inline=true) | trim_end_matches(pat=".") | safe }}…</p> + {% endif %} + </div> + <a class="readmore" href="{{ post.permalink }}">{{ macros_translate::translate(key="read_more", default="Read more", language_strings=language_strings) }} <span class="arrow">→</span></a> + </div> + </section> + {% endif %} + {% if not loop.last %} + {% if loop.index == max %} + <div class="all-posts"> + <a href="{{ get_url(path=section_path, lang=lang) }}/">{{ macros_translate::translate(key="all_posts", default="All posts", language_strings=language_strings) }} <span class="arrow">⟶</span></a> + </div> + {% endif %} + {% endif %} + {% endfor %} +</div> +{% endmacro %} diff --git a/sysret.org/themes/tabi-lean/templates/macros/page_header.html b/sysret.org/themes/tabi-lean/templates/macros/page_header.html new file mode 100644 index 0000000..daa8d02 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/macros/page_header.html @@ -0,0 +1,18 @@ +{% macro page_header(title, show_feed_icon=false) %} + +{% 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) -%} + +<h1 class="title-container section-title bottom-divider"> + {{ title -}} + {% if show_feed_icon %} + {%- set feed_url = feed_utils::get_feed_url() -%} + <a class="no-hover-padding social" rel="{{ rel_attributes }}" {{ blank_target }} href="{{ get_url(path=term.path ~ feed_url, lang=lang, trailing_slash=false) | safe }}"> + <img loading="lazy" alt="feed" title="feed" src="{{ get_url(path='/social_icons/rss.svg') }}"> + </a> + {% endif %} +</h1> + +{% endmacro page_header %} diff --git a/sysret.org/themes/tabi-lean/templates/macros/rel_attributes.html b/sysret.org/themes/tabi-lean/templates/macros/rel_attributes.html new file mode 100644 index 0000000..71672c7 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/macros/rel_attributes.html @@ -0,0 +1,19 @@ +{% macro rel_attributes() %} + +{%- set rel_attributes = [] -%} +{%- if config.markdown.external_links_target_blank -%} + {%- set rel_attributes = rel_attributes | concat(with="noopener") -%} +{%- endif -%} +{# https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel#nofollow #} +{# This is ignored, as it doesn't make sense to set `nofollow` on projects or social links. #} +{# {%- if config.markdown.external_links_no_follow -%} + {%- set rel_attributes = rel_attributes | concat(with="nofollow") -%} +{%- endif -%} #} +{%- if config.markdown.external_links_no_referrer -%} + {%- set rel_attributes = rel_attributes | concat(with="noreferrer") -%} +{%- endif -%} + +{# Return the array of rel attributes joined by a space #} +{{- rel_attributes | join(sep=" ") -}} + +{% endmacro rel_attributes %} diff --git a/sysret.org/themes/tabi-lean/templates/macros/series_page.html b/sysret.org/themes/tabi-lean/templates/macros/series_page.html new file mode 100644 index 0000000..d5704a1 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/macros/series_page.html @@ -0,0 +1,162 @@ +{# +Those macros deal with introduction and navigation for series pages. +Using macros have been prefered over partial inclusion or inline code to make sure series_ordered_pages is forced to be used. +A section's pages natural order is invalid in case of reversed pagination which would lead to invalid series' pages order. +To prevent this, pages are ordered correctly in a separate variable which must be used instead of the series section pages. +#} + +{# +Computes the introduction of a series's page. + +Parameters: + - `page`: The page object being part of the series. + - `series_section`: The series' section the page belongs to. + - `series_ordered_pages`: The series' pages properly ordered (see at the top of this file for an explanation). + - `language_strings`: A dictionary containing the translation strings. +#} +{% macro process_series_template(template_type, page, series_section, series_ordered_pages, language_strings) %} + {%- if "series" in series_section.extra and series_section.extra.series -%} + {# Prepare variables for substitution #} + {%- set series_title = series_section.title -%} + {%- set series_permalink = series_section.permalink -%} + {%- set series_html_link = '<a href="' ~ series_section.permalink ~ '" aria_label="' ~ series_section.title ~ '">' ~ series_section.title ~ '</a>' -%} + {# Build series pages list #} + {%- set series_pages_list = [] -%} + {%- for series_page in series_ordered_pages -%} + {%- if series_page.relative_path == page.relative_path -%} + {%- set series_pages_list_item = '<li>' ~ series_page.title ~ '</li>' -%} + {%- else -%} + {%- set series_pages_list_item = '<li><a href="' ~ series_page.permalink ~ '" aria_label="' ~ series_page.title ~ '">' ~ series_page.title ~ '</a></li>' -%} + {%- endif -%} + {%- set_global series_pages_list = series_pages_list | concat(with=series_pages_list_item) -%} + {%- endfor -%} + {%- set series_pages_list = series_pages_list | join(sep="") -%} + {%- if macros_settings::evaluate_setting_priority(setting="post_listing_index_reversed", page=series_section, default_global_value=false) == "true" -%} + {%- set series_pages_ordered_list = '<ol reversed>' ~ series_pages_list ~ '</ol>' -%} + {%- else -%} + {%- set series_pages_ordered_list = '<ol>' ~ series_pages_list ~ '</ol>' -%} + {%- endif -%} + {%- set series_pages_unordered_list = '<ul>' ~ series_pages_list ~ '</ul>' -%} + + {# Get page position and navigation info #} + {%- set series_pages_number = 0 -%} + {%- set series_page_index = 0 -%} + {%- set first_page = series_ordered_pages | first -%} + {%- set is_found = false -%} + + {%- for series_page in series_ordered_pages -%} + {%- set_global series_pages_number = series_pages_number + 1 -%} + {%- if series_page.relative_path == page.relative_path -%} + {%- set_global series_page_index = series_pages_number -%} + {%- set_global is_found = true -%} + {%- else -%} + {%- if not is_found -%} + {%- set_global prev_page = series_page -%} + {%- elif not next_page is defined -%} + {%- set_global next_page = series_page -%} + {%- endif -%} + {%- endif -%} + {%- endfor -%} + + {# Determine template to use based on available navigation #} + {%- set position = "middle" -%} + {%- if prev_page is defined and not next_page is defined -%} + {%- set_global position = "prev_only" -%} + {%- elif next_page is defined and not prev_page is defined -%} + {%- set_global position = "next_only" -%} + {%- endif -%} + + {# Get template from config #} + {%- set templates_key = "series_" ~ template_type ~ "_templates" -%} + {%- set template = "" -%} + {%- if series_section.extra[templates_key] is defined -%} + {%- if series_section.extra[templates_key][position] is defined -%} + {%- set_global template = series_section.extra[templates_key][position] -%} + {%- elif series_section.extra[templates_key].default is defined -%} + {%- set_global template = series_section.extra[templates_key].default -%} + {%- endif -%} + {%- endif -%} + + {# Prepare navigation variables #} + {%- if prev_page is defined -%} + {%- set prev_title = prev_page.title -%} + {%- set prev_permalink = prev_page.permalink -%} + {%- set prev_html_link = '<a href="' ~ prev_page.permalink ~ '" aria_label="' ~ prev_page.title ~ '">' ~ prev_page.title ~ '</a>' -%} + {%- set prev_description = prev_page.description | default(value="") -%} + {%- endif -%} + {%- if next_page is defined -%} + {%- set next_title = next_page.title -%} + {%- set next_permalink = next_page.permalink -%} + {%- set next_html_link = '<a href="' ~ next_page.permalink ~ '" aria_label="' ~ next_page.title ~ '">' ~ next_page.title ~ '</a>' -%} + {%- set next_description = next_page.description | default(value="") -%} + {%- endif -%} + + {# Replace standard variables #} + {%- set template = template + | replace(from="$SERIES_TITLE", to=series_title) + | replace(from="$SERIES_PERMALINK", to=series_permalink) + | replace(from="$SERIES_HTML_LINK", to=series_html_link) + | replace(from="$FIRST_TITLE", to=first_page.title) + | replace(from="$FIRST_HTML_LINK", to='<a href="' ~ first_page.permalink ~ '">' ~ first_page.title ~ '</a>') + | replace(from="$SERIES_PAGES_NUMBER", to=series_pages_number | as_str) + | replace(from="$SERIES_PAGE_INDEX", to=series_page_index | as_str) + | replace(from="$SERIES_PAGES_OLIST", to=series_pages_ordered_list) + | replace(from="$SERIES_PAGES_ULIST", to=series_pages_unordered_list) + -%} + + {# Replace navigation variables if they exist #} + {%- if prev_page is defined -%} + {%- set template = template + | replace(from="$PREV_TITLE", to=prev_title) + | replace(from="$PREV_PERMALINK", to=prev_permalink) + | replace(from="$PREV_HTML_LINK", to=prev_html_link) + | replace(from="$PREV_DESCRIPTION", to=prev_description) + -%} + {%- endif -%} + + {%- if next_page is defined -%} + {%- set template = template + | replace(from="$NEXT_TITLE", to=next_title) + | replace(from="$NEXT_PERMALINK", to=next_permalink) + | replace(from="$NEXT_HTML_LINK", to=next_html_link) + | replace(from="$NEXT_DESCRIPTION", to=next_description) + -%} + {%- endif -%} + + {# Custom placeholders #} + {%- if series_section.extra.series_template_placeholders is defined -%} + {%- set missing_vars = [] -%} + {%- for placeholder in series_section.extra.series_template_placeholders -%} + {%- if placeholder in template -%} + {%- set var_name = placeholder | replace(from="$", to="") | lower -%} + {%- if page.extra.series_template_variables is defined and page.extra.series_template_variables[var_name] is defined -%} + {%- set_global template = template | replace(from=placeholder, to=page.extra.series_template_variables[var_name]) -%} + {%- else -%} + {%- set_global missing_vars = missing_vars | concat(with=var_name) -%} + {%- endif -%} + {%- endif -%} + {%- endfor -%} + {%- if missing_vars | length > 0 -%} + {%- set missing_vars_str = missing_vars | join(sep=", ") -%} + {{ throw(message="ERROR: The following variables are included in this page's series templates (`series_template_placeholders`) but have not been set in the `series_template_variables` of this page: " ~ missing_vars_str) }} + {%- endif -%} + {%- endif -%} + + {# Output the processed template if not empty #} + {%- if template | length > 0 -%} + <section class="series-page-{{ template_type }}"> + {{ template | markdown | safe }} + </section> + {%- endif -%} + {%- endif -%} +{% endmacro %} + +{# Macro for series introduction #} +{% macro get_introduction(page, series_section, series_ordered_pages, language_strings) %} + {{ macros_series_page::process_series_template(template_type="intro", page=page, series_section=series_section, series_ordered_pages=series_ordered_pages, language_strings=language_strings) }} +{% endmacro %} + +{# Macro for series outro #} +{% macro get_outro(page, series_section, series_ordered_pages, language_strings) %} + {{ macros_series_page::process_series_template(template_type="outro", page=page, series_section=series_section, series_ordered_pages=series_ordered_pages, language_strings=language_strings) }} +{% endmacro %} diff --git a/sysret.org/themes/tabi-lean/templates/macros/settings.html b/sysret.org/themes/tabi-lean/templates/macros/settings.html new file mode 100644 index 0000000..d237d7a --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/macros/settings.html @@ -0,0 +1,68 @@ +{# +Evaluates the priority of a particular setting across different scopes. + +The priority is as follows: page > section > config. + +Parameters: + - setting: The name of the setting to evaluate. + - page: The page object containing settings. + - default_global_value: The setting's default value. +#} + +{% macro evaluate_setting_priority(setting, page, section="", default_global_value="") %} + +{%- if section -%} + {%- set current_section = section -%} +{%- elif page -%} + {%- set current_section = "" -%} + {#- Retrieve last ancestor to determine current section, if applicable -#} + {%- 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 = [ + page.extra[setting] | default(value=""), + current_section.extra[setting] | default(value=""), + config.extra[setting] | default(value="") +] -%} + +{%- set output = default_global_value -%} + +{%- for value in priority_order -%} + {%- if value != "" -%} + {%- set_global output = value -%} + {%- break -%} + {%- endif -%} +{%- endfor -%} + +{{- output -}} + +{% endmacro %} diff --git a/sysret.org/themes/tabi-lean/templates/macros/table_of_contents.html b/sysret.org/themes/tabi-lean/templates/macros/table_of_contents.html new file mode 100644 index 0000000..18a3ab6 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/macros/table_of_contents.html @@ -0,0 +1,54 @@ +{% macro toc(page, header, language_strings="") %} + +{%- set toc_levels = page.extra.toc_levels | default(value=3) -%} + +{% if page.extra.toc_ignore_pattern %} + {%- set toc_ignore_pattern = page.extra.toc_ignore_pattern -%} +{% endif %} + +<div class="toc-container"> + {% if header %} + <h3>{{ macros_translate::translate(key="table_of_contents", default="Table of Contents", language_strings=language_strings) }}</h3> + {% endif %} + + <ul> + {% for h1 in page.toc %} + {# Only render headers if there's no ignore pattern, or if the header text doesn't match the pattern. #} + {% if not toc_ignore_pattern or not (h1.title is matching(toc_ignore_pattern)) %} + <li><a href="{{ h1.permalink | safe }}">{{ h1.title }}</a> + {% if h1.children and toc_levels > 1 %} + <ul> + {% for h2 in h1.children %} + {% if not toc_ignore_pattern or not (h2.title is matching(toc_ignore_pattern)) %} + <li><a href="{{ h2.permalink | safe }}">{{ h2.title }}</a> + {% if h2.children and toc_levels > 2 %} + <ul> + {% for h3 in h2.children %} + {% if not toc_ignore_pattern or not (h3.title is matching(toc_ignore_pattern)) %} + <li><a href="{{ h3.permalink | safe }}">{{ h3.title }}</a> + {% if h3.children and toc_levels > 3 %} + <ul> + {% for h4 in h3.children %} + {% if not toc_ignore_pattern or not (h4.title is matching(toc_ignore_pattern)) %} + <li><a href="{{ h4.permalink | safe }}">{{ h4.title }}</a></li> + {% endif %} + {% endfor %} + </ul> + {% endif %} + </li> + {% endif %} + {% endfor %} + </ul> + {% endif %} + </li> + {% endif %} + {% endfor %} + </ul> + {% endif %} + </li> + {% endif %} + {% endfor %} + </ul> +</div> + +{% endmacro toc %} diff --git a/sysret.org/themes/tabi-lean/templates/macros/target_attribute.html b/sysret.org/themes/tabi-lean/templates/macros/target_attribute.html new file mode 100644 index 0000000..2da5b9d --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/macros/target_attribute.html @@ -0,0 +1,11 @@ +{% macro target_attribute(new_tab) %} + +{%- set blank_target = "" -%} + +{%- if new_tab -%} + {%- set blank_target = "target=_blank" -%} +{%- endif -%} + +{{ blank_target }} + +{% endmacro target_attribute %} diff --git a/sysret.org/themes/tabi-lean/templates/macros/translate.html b/sysret.org/themes/tabi-lean/templates/macros/translate.html new file mode 100644 index 0000000..1b138dd --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/macros/translate.html @@ -0,0 +1,72 @@ +{#- Dynamically selects the appropriate translation key based on the provided `number` and `lang` context. +If a `number` is provided, the macro will attempt to pluralize the translation key based on the language's rules. + +Parameters: +- `key`: The base key for the translation string, matching the i18n files. Example: `results` to get `zero_results`, `one_results`, `many_results`, etc. +- `number`: Optional. The numerical value associated with the key. +- `language_strings`: A dictionary containing the translation strings. +- `default`: A default string to use if no translation is found for the key. +- `replace`: Optional. If `true`, the macro will replace the `$NUMBER` placeholder in the translation string with the provided `number`. + +The macro supports special pluralization rules for: +- Arabic (`ar`): Has unique forms for zero, one, two, few, and many. +- Slavic languages: Pluralization depends on the last digit of the number, with exceptions for numbers ending in 11-14. + +NOTE: If the logic for pluralization is modified, it needs to be replicated on the JavaScript search. +Files: static/js/searchElasticlunr.js and its minified version at static/js/searchElasticlunr.min.js +Function name: getPluralizationKey -#} +{% macro translate(key, number=-1, language_strings="", default="", replace=true) %} + {%- set slavic_plural_languages = ["uk", "be", "bs", "hr", "ru", "sr"] -%} + + {%- set key_prefix = "" -%} + {#- `zero_` and `one_` are common cases. We handle "many" (plural) later, after language-specific pluralization -#} + {%- if number == 0 -%} + {%- set key_prefix = "zero_" -%} + {%- elif number == 1 -%} + {%- set key_prefix = "one_" -%} + {%- endif -%} + + {#- Pluralization -#} + {%- if number != -1 and key_prefix == "" -%} + {#- Arabic -#} + {%- if lang == "ar" -%} + {%- set modulo = number % 100 -%} + {%- if number == 2 -%} + {%- set key_prefix = "two_" -%} + {%- elif modulo >= 3 and modulo <= 10 -%} + {%- set key_prefix = "few_" -%} + {%- else -%} + {%- set key_prefix = "many_" -%} + {%- endif -%} + {#- Slavic languages like Russian or Ukrainian -#} + {%- elif lang in slavic_plural_languages -%} + {%- set modulo10 = number % 10 -%} + {%- set modulo100 = number % 100 -%} + {%- if modulo10 == 1 and modulo100 != 11 -%} + {%- set key_prefix = "one_" -%} + {%- elif modulo10 >= 2 and modulo10 <= 4 -%} + {%- if modulo100 >= 12 and modulo100 <= 14 -%} + {%- set key_prefix = "many_" -%} + {%- else -%} + {%- set key_prefix = "few_" -%} + {%- endif -%} + {%- else -%} + {%- set key_prefix = "many_" -%} + {%- endif -%} + {%- else -%} + {#- Default pluralization -#} + {#- Zero and one are already handled -#} + {%- set key_prefix = "many_" -%} + {%- endif -%} + {%- endif -%} + + {#- Translated string -#} + {%- set final_key = key_prefix ~ key -%} + {%- set translated_text = language_strings[final_key] | default(value=default) | safe -%} + + {#- Replace $NUMBER with the number -#} + {%- if replace -%} + {%- set translated_text = translated_text | replace(from="$NUMBER", to=number | as_str) -%} + {%- endif -%} + {{- translated_text -}} +{% endmacro %} diff --git a/sysret.org/themes/tabi-lean/templates/page.html b/sysret.org/themes/tabi-lean/templates/page.html new file mode 100644 index 0000000..0dff1a7 --- /dev/null +++ b/sysret.org/themes/tabi-lean/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 #} +{# <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 = [ + "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", + ] %} + + <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 %} + <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 #} + +<main> + <article class="h-entry"> + <h1 class="p-name article-title"> + {{ page.title | markdown(inline=true) | safe }} + </h1> + <a class="u-url u-uid" href="{{ page.permalink | safe }}"></a> + + <ul class="meta"> + {#- Draft indicator -#} + {% if page.draft %} + <li class="draft-label">{{ macros_translate::translate(key="draft", default="DRAFT", language_strings=language_strings) }}</li> + {% 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 = '<span class="p-author">' ~ author_list.0 ~ '</span>' -%} + {%- 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 = '</span>' ~ author_separator ~ '<span class="p-author">' -%} + {%- set conjunction = macros_translate::translate(key="author_conjunction", default=" and ", language_strings=language_strings) -%} + {%- set conjunction = '</span>' ~ conjunction ~ '<span class="p-author">' -%} + {%- set author_string = other_authors | join(sep=author_separator) -%} + {%- set author_string = author_string ~ conjunction ~ last_author -%} + {%- set author_string = '<span class="p-author">' ~ author_string ~ '</span>' -%} + {%- endif -%} + + {%- set by_author = macros_translate::translate(key="by_author", default="By $AUTHOR", language_strings=language_strings) -%} + <li>{{ by_author | replace(from="$AUTHOR", to=author_string) | safe }}</li> + {%- 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 = "<span class='separator' aria-hidden='true'>" ~ separator ~ "</span>"-%} + + {#- Date -#} + {%- if page.date and macros_settings::evaluate_setting_priority(setting="show_date", page=page, default_global_value=true) == "true" -%} + <li><time class="dt-published" datetime="{{ page.date }}">{%- if previous_visible -%}{{ separator_with_class | safe }}{%- endif -%}{{ macros_format_date::format_date(date=page.date, short=true, language_strings=language_strings) }}</time></li> + {#- 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" -%} + <li title="{{ macros_translate::translate(key="words", number=page.word_count, default="$NUMBER words", language_strings=language_strings) }}">{%- 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) }}</li> + {%- set previous_visible = true -%} + {%- endif -%} + + {#- Tags -#} + {%- if page.taxonomies and page.taxonomies.tags -%} + <li class="tag">{%- if previous_visible -%}{{ separator_with_class | safe }}{%- endif -%}{{- macros_translate::translate(key="tags", default="tags", language_strings=language_strings) | capitalize -}}: </li> + {%- for tag in page.taxonomies.tags -%} + <li class="tag"><a class="p-category" href="{{ get_taxonomy_url(kind='tags', name=tag, lang=lang) | safe }}">{{ tag }}</a> + {%- if not loop.last -%} + , + {%- endif -%} + </li> + {%- 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 -%} + </ul><ul class="meta last-updated"><li><time class="dt-updated" datetime="{{ page.updated }}">{{ updated_str }}</time></li> + {#- Show link to remote changes if enabled -#} + {%- if config.extra.remote_repository_url and macros_settings::evaluate_setting_priority(setting="show_remote_changes", page=page, default_global_value=true) == "true" -%} + <li>{%- if previous_visible -%}{{ separator_with_class | safe }}{%- endif -%}<a class="external" href="{% include "partials/history_url.html" %}" {{ blank_target }} rel="{{ rel_attributes }}">{{ macros_translate::translate(key="see_changes", default="See changes", language_strings=language_strings) }}</a></li> + {%- endif -%} + {% endif %} + </ul> + + {#- 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 %} + <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 %} + + {#- 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 %} + <p class="p-summary" hidden>{{ page.description }}</p> + {%- endif -%} + + + <section class="e-content body"> + {#- Replace series_intro placeholder -#} + {%- set content_with_intro = page.content -%} + {%- if "<!-- series_intro -->" 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="<!-- series_intro -->", 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 "<!-- series_outro -->" 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="<!-- series_outro -->", 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 = '<hr><ol class="footnotes-list">' -%} + {%- 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="<!-- toc -->", to=macros_toc::toc(page=page, header=false, language_strings=language_strings)) | safe }} + </section> + + {#- 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 %} + <nav class="{{ full_width_class | default(value="") }} article-navigation"> + <div> + {%- if left_link and left_label and left_title -%} + <a href="{{ left_link | safe }}" aria-label="{{ left_label }}" aria-describedby="left_title"><span class="arrow">←</span> {{ left_label }}</a> + <p aria-hidden="true" id="left_title">{{ left_title | truncate(length=100, end="…") | markdown(inline=true) | safe }}</p> + {%- endif -%} + </div> + <div> + {%- if right_link and right_label and right_title -%} + <a href="{{ right_link | safe }}" aria-label="{{ right_label }}" aria-describedby="right_title">{{ right_label }} <span class="arrow">→</span></a> + <p aria-hidden="true" id="right_title">{{ right_title | truncate(length=100, end="…") | markdown(inline=true) | safe }}</p> + {%- endif -%} + </div> + </nav> + {%- 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 -%} + + </article> +</main> + +{%- include "partials/extra_features.html" -%} + +{% endblock main_content %} diff --git a/sysret.org/themes/tabi-lean/templates/partials/analytics.html b/sysret.org/themes/tabi-lean/templates/partials/analytics.html new file mode 100644 index 0000000..6a5d30e --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/analytics.html @@ -0,0 +1,38 @@ +{% set analytics_service = config.extra.analytics.service %} +{% set analytics_id = config.extra.analytics.id | default(value="") %} +{% set self_hosted_url = config.extra.analytics.self_hosted_url | default(value="") %} + +{% if analytics_service == "goatcounter" %} + {# Prevent non-demo sites from using the demo analytics account #} + {% if self_hosted_url == "https://tabi-stats.osc.garden" and config.base_url == "https://welpo.github.io/tabi" or self_hosted_url != "https://tabi-stats.osc.garden" %} + <script async + {% if self_hosted_url %} + data-goatcounter="{{ self_hosted_url ~ '/count' }}" + src="{{ self_hosted_url ~ '/count.js' }}" + {% else %} + data-goatcounter="https://{{ analytics_id }}.goatcounter.com/count" + src="https://gc.zgo.at/count.js" + {% endif %} + ></script> + {% endif %} + +{% elif analytics_service == "umami" %} + <script async defer + {% if self_hosted_url %} + data-website-id="{{ analytics_id }}" + src="{{ self_hosted_url ~ '/script.js' }}" + {% else %} + data-website-id="{{ analytics_id }}" + src="https://cloud.umami.is/script.js" + {% endif %} + {% if config.extra.analytics.do_not_track %}data-do-not-track="true"{% endif %}> + </script> + + {% elif analytics_service == "plausible" %} + <script + defer + data-domain="{{ analytics_id }}" + src="{% if self_hosted_url %}{{ self_hosted_url ~ '/js/plausible.js' }}{% else %}https://plausible.io/js/script.js{% endif %}" + ></script> + +{% endif %} diff --git a/sysret.org/themes/tabi-lean/templates/partials/cards_pages.html b/sysret.org/themes/tabi-lean/templates/partials/cards_pages.html new file mode 100644 index 0000000..89bdabc --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/cards_pages.html @@ -0,0 +1,46 @@ +{%- set rel_attributes = macros_rel_attributes::rel_attributes() | trim -%} +{%- set max_projects = max_projects | default(value=999999) -%} +<div class="cards"> + {%- for page in show_pages %} + {# Used only in main page #} + {% if loop.index > max_projects %} + {% break %} + {% endif %} + {# Determine which URL to use, default is page.permalink #} + {%- set blank_target = macros_target_attribute::target_attribute(new_tab=config.markdown.external_links_target_blank and page.extra.link_to) -%} + + {% set target_url = page.extra.link_to | default(value=page.permalink) %} + + <a rel="{{ rel_attributes }}" + {{ blank_target }} + href="{{ target_url }}" + class="card" + {% if page.taxonomies %} + data-tags="{% for tax_name, terms in page.taxonomies %}{% for term in terms | unique %}{{ term | lower }}{% if not loop.last %},{% endif %}{% endfor %}{% endfor %}" + {% endif %}> + {% if page.extra.local_image %} + {% set meta = get_image_metadata(path=page.extra.local_image, allow_missing=true) %} + <img class="card-image" + alt="{{ page.extra.local_image }}" + src="{{ get_url(path=page.extra.local_image) }}" + {% if meta.width %}width="{{ meta.width }}"{% endif %} + {% if meta.height %}height="{{ meta.height }}"{% endif %}> + {% elif page.extra.remote_image %} + <img class="card-image" + alt="{{ page.extra.remote_image }}" + src="{{ page.extra.remote_image }}"> + {% else %} + <div class="card-image-placeholder"></div> + {% endif %} + + <div class="card-info"> + <h2 class="card-title">{{ page.title | markdown(inline=true) | safe }}</h2> + <div class="card-description"> + {% if page.description %} + {{ page.description | markdown(inline=true) | safe }} + {% endif %} + </div> + </div> + </a> + {% endfor -%} +</div> diff --git a/sysret.org/themes/tabi-lean/templates/partials/comments.html b/sysret.org/themes/tabi-lean/templates/partials/comments.html new file mode 100644 index 0000000..1129055 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/comments.html @@ -0,0 +1,95 @@ +{% set automatic_loading = config.extra[comment_system].automatic_loading %} + +<div id="comments" class="comments" + +{% if comment_system == "giscus" %} + data-repo="{{ config.extra.giscus.repo }}" + data-repo-id="{{ config.extra.giscus.repo_id }}" + data-category="{{ config.extra.giscus.category }}" + data-category-id="{{ config.extra.giscus.category_id }}" + {% if config.extra.giscus.mapping == "slug" %} + data-mapping="specific" + data-term="{{ page.slug }}" + {% else %} + data-mapping="{{ config.extra.giscus.mapping }}" + {% endif %} + data-strict="{{ config.extra.giscus.strict_title_matching }}" + data-reactions-enabled="{{ config.extra.giscus.enable_reactions }}" + {% if config.extra.giscus.comment_box_above_comments %} + data-input-position="top" + {% else %} + data-input-position="bottom" + {% endif %} + data-light-theme="{{ config.extra.giscus.light_theme }}" + data-dark-theme="{{ config.extra.giscus.dark_theme }}" + {% if config.extra.giscus.lang %} + data-lang="{{ config.extra.giscus.lang }}" + {% else %} + data-lang="{{ lang }}" + {% endif %} + data-lazy-loading="{{ config.extra.giscus.lazy_loading }}" + > + +{% elif comment_system == "utterances" %} + data-repo="{{ config.extra.utterances.repo }}" + {% if config.extra.utterances.issue_term == "slug" %} + data-issue-term="{{ page.slug }}" + {% else %} + data-issue-term="{{ config.extra.utterances.issue_term }}" + {% endif %} + data-label="{{ config.extra.utterances.label }}" + data-light-theme="{{ config.extra.utterances.light_theme }}" + data-dark-theme="{{ config.extra.utterances.dark_theme }}" + data-lazy-loading="{{ config.extra.utterances.lazy_loading }}" + > + +{% elif comment_system == "hyvortalk" %} + data-website-id="{{ config.extra.hyvortalk.website_id }}" + {% if config.extra.hyvortalk.page_id_is_slug %} + data-page-id="{{ page.slug }}" + {% else %} + data-page-id="{{ current_url }}" + {% endif %} + {% if config.extra.hyvortalk.lang %} + data-page-language="{{ config.extra.hyvortalk.lang }}" + {% else %} + data-page-language="{{ lang }}" + {% endif %} + data-page-author="{{ config.extra.hyvortalk.page_author }}" + {% if config.extra.hyvortalk.lazy_loading %} + data-loading="lazy" + {% else %} + data-loading="default" + {% endif %} + > + +{% elif comment_system == "isso" %} + data-endpoint-url="{{ config.extra.isso.endpoint_url }}" + {% if config.extra.isso.page_id_is_slug %} + {%- set default_lang_url = current_path | replace(from='/' ~ lang ~ '/', to = '/') -%} + data-isso-id="{{ default_lang_url }}" + data-title="{{ default_lang_url }}" + {% endif %} + {% if config.extra.isso.lang %} + data-page-language="{{ config.extra.isso.lang }}" + {% else %} + data-page-language="{{ lang }}" + {% endif %} + data-max-comments-top="{{ config.extra.isso.max_comments_top }}" + data-max-comments-nested="{{ config.extra.isso.max_comments_nested }}" + data-avatar="{{ config.extra.isso.avatar }}" + data-voting="{{ config.extra.isso.voting }}" + data-page-author-hashes="{{ config.extra.isso.page_author_hashes }}" + data-lazy-loading="{{ config.extra.isso.lazy_loading }}" + > +{% endif %} + +{% if automatic_loading %} + <script src="{{ get_url(path='js/' ~ comment_system ~ '.min.js', trailing_slash=false) | safe }}" async></script> +{% else %} + <button id="load-comments" class="load-comments-button" data-script-src="{{ get_url(path='js/' ~ comment_system ~ '.min.js', trailing_slash=false) | safe }}">{{ macros_translate::translate(key="load_comments", default="Load comments", language_strings=language_strings) }}</button> + <script src="{{ get_url(path='js/loadComments.min.js', trailing_slash=false) | safe }}" async></script> +{% endif %} + +<noscript>You need JavaScript to view the comments.</noscript> +</div> diff --git a/sysret.org/themes/tabi-lean/templates/partials/content_security_policy.html b/sysret.org/themes/tabi-lean/templates/partials/content_security_policy.html new file mode 100644 index 0000000..e8fa062 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/content_security_policy.html @@ -0,0 +1,119 @@ +<meta http-equiv="Content-Security-Policy" +content="default-src 'self' +{%- if config.extra.allowed_domains -%} +; + {#- Check if a comment system is enabled to allow the necessary domains and directives -#} + {%- set utterances_enabled = config.extra.utterances.enabled_for_all_posts or page.extra.utterances -%} + {%- set giscus_enabled = config.extra.giscus.enabled_for_all_posts or page.extra.giscus -%} + {%- set hyvortalk_enabled = config.extra.hyvortalk.enabled_for_all_posts or page.extra.hyvortalk -%} + {%- set isso_enabled = config.extra.isso.enabled_for_all_posts or page.extra.isso -%} + {%- if page -%} + {%- set iine_enabled = macros_settings::evaluate_setting_priority(setting="iine", page=page, default_global_value=false) == "true" -%} + {%- endif -%} + {%- if page -%} + {%- set mermaid_enabled = macros_settings::evaluate_setting_priority(setting="mermaid", page=page, default_global_value=false) == "true" -%} + {%- endif -%} + {%- set serve_local_mermaid = config.extra.serve_local_mermaid | default(value=true) -%} + + {#- Initialise a base script-src directive -#} + {%- set script_src = "script-src 'self'" -%} + + {#- Initialise a base connect-src directive -#} + {%- set connect_src = "connect-src 'self'" -%} + + {# Base logic for appending analytics domains #} + {%- set analytics_url = config.extra.analytics.self_hosted_url | default(value="") %} + {%- if analytics_url -%} + {%- set script_src = script_src ~ " " ~ analytics_url -%} + {%- set connect_src = connect_src ~ " " ~ analytics_url -%} + {%- else -%} + {%- if config.extra.analytics.service -%} + {%- if config.extra.analytics.service == "goatcounter" -%} + {%- set script_src = script_src ~ " gc.zgo.at" -%} + {%- set connect_src = connect_src ~ " " ~ config.extra.analytics.id ~ ".goatcounter.com/count" -%} + {%- elif config.extra.analytics.service == "umami" -%} + {%- set script_src = script_src ~ " cloud.umami.is" -%} + {%- set connect_src = connect_src ~ " *.umami.dev" ~ " cloud.umami.is" -%} + {%- elif config.extra.analytics.service == "plausible" -%} + {%- set script_src = script_src ~ " plausible.io" -%} + {%- set connect_src = connect_src ~ " plausible.io" -%} + {%- endif -%} + {%- endif -%} + {%- endif -%} + + {%- if hyvortalk_enabled -%} + {%- set connect_src = connect_src ~ " talk.hyvor.com" -%} + {%- set script_src = script_src ~ " talk.hyvor.com" -%} + {%- elif isso_enabled -%} + {%- set connect_src = connect_src ~ " " ~ config.extra.isso.endpoint_url -%} + {%- set script_src = script_src ~ " " ~ config.extra.isso.endpoint_url -%} + {%- elif giscus_enabled -%} + {%- set script_src = script_src ~ " " ~ " giscus.app" -%} + {%- elif utterances_enabled -%} + {%- set script_src = script_src ~ " " ~ " utteranc.es" -%} + {%- endif -%} + + {%- if (mermaid_enabled and not serve_local_mermaid) or iine_enabled -%} + {%- set script_src = script_src ~ " " ~ " cdn.jsdelivr.net" -%} + {%- endif -%} + + {#- Check if a webmention system is enabled to allow the necessary domains and directives -#} + {%- if config.extra.webmentions.enable -%} + {%- set connect_src = connect_src ~ " webmention.io" -%} + {%- endif -%} + + {#- Check if iine like buttons are enabled to allow the necessary domains -#} + {%- if iine_enabled -%} + {%- set connect_src = connect_src ~ " vhiweeypifbwacashxjz.supabase.co" -%} + {%- endif -%} + + {#- Append WebSocket for Zola serve mode -#} + {%- if config.mode == "serve" -%} + {%- set connect_src = connect_src ~ " ws:" -%} + {%- endif -%} + + {%- for domain in config.extra.allowed_domains -%} + {%- if domain.directive == "connect-src" -%} + {%- set configured_connect_src = domain.domains | join(sep=' ') | safe -%} + {%- set_global connect_src = connect_src ~ " " ~ configured_connect_src -%} + {%- continue -%} + {%- endif -%} + + {%- if domain.directive == "script-src" -%} + {%- set configured_script_src = domain.domains | join(sep=' ') | safe -%} + {%- set_global script_src = script_src ~ " " ~ configured_script_src -%} + {%- continue -%} + {%- endif -%} + + {#- Handle directives that are not connect-src -#} + {{ domain.directive }} {{ domain.domains | join(sep=' ') | safe -}} + + {%- if domain.directive == "style-src" -%} + {%- if utterances_enabled or hyvortalk_enabled or mermaid_enabled %} 'unsafe-inline' + {%- endif -%} + {%- endif -%} + + {%- if domain.directive == "font-src" -%} + {%- if mermaid_enabled %} 'self' + {%- endif -%} + {%- endif -%} + + {%- if domain.directive == "frame-src" -%} + {%- if giscus_enabled %} giscus.app + {%- elif utterances_enabled %} utteranc.es + {%- elif hyvortalk_enabled %} talk.hyvor.com + {%- endif %} + {%- endif -%} + + {%- if not loop.last -%} + ; + {%- endif -%} + {%- endfor -%} + + {#- Insert the generated connect-src -#} + {{ ";" ~ connect_src }} + + {#- Insert the generated script-src -#} + {{ ";" ~ script_src }} + +{%- endif -%}"> diff --git a/sysret.org/themes/tabi-lean/templates/partials/copyright.html b/sysret.org/themes/tabi-lean/templates/partials/copyright.html new file mode 100644 index 0000000..b9cfc01 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/copyright.html @@ -0,0 +1,39 @@ +{%- if config.extra.copyright -%} + {% set copyright = config.extra.copyright %} + {# Try to look for a language-specific copyright notice in the new config setup #} + {%- if config.extra.copyright_translations -%} + {%- if lang in config.extra.copyright_translations -%} + {% set copyright = config.extra.copyright_translations[lang] %} + {%- endif -%} + {%- elif config.extra.translate_copyright -%} + {# Old way to translate the copyright through toml files #} + {{ throw(message="ERROR: The 'translate_copyright' feature has been deprecated. Please set 'copyright_translations' in config.toml. See the documentation: https://welpo.github.io/tabi/blog/mastering-tabi-settings/#copyright") }} + {%- endif -%} + + {# Check for missing variables in the notice #} + {% set copyright_placeholders = ["$AUTHOR", "$TITLE"] %} + {% set missing_vars = [] %} + {% for placeholder in copyright_placeholders %} + {% if placeholder in copyright %} + {# Attempt to retrieve the corresponding variable by trimming the $ sign and converting to lowercase #} + {% set var_name = placeholder | replace(from="$", to="") | lower %} + {% if not config[var_name] %} + {# Append the variable name to the list of missing variables #} + {% set_global missing_vars = missing_vars | concat(with=var_name) %} + {% endif %} + {% endif %} + {% endfor %} + + {% if missing_vars | length > 0 %} + {% set missing_vars_str = missing_vars | join(sep=", ") %} + {{ throw(message="ERROR: The following variables are included in `copyright` but have not been set in the config.toml: " ~ missing_vars_str) }} + {% endif %} + + {# At this point, we know that all variables needed defined, so we can safely override the missing ones #} + {% set author = config.author | default(value="") %} + {% set title = config.title | default(value="") %} + + {# Render the copyright notice, replacing the variables #} + {% set current_year = now() | date(format="%Y") %} + <p>{{ copyright | replace(from="$AUTHOR", to=author) | replace(from="$TITLE", to=title) | replace(from="$CURRENT_YEAR", to=current_year) | replace(from="$SEPARATOR", to=separator) | markdown | safe }}</p> +{%- endif -%} diff --git a/sysret.org/themes/tabi-lean/templates/partials/extra_features.html b/sysret.org/themes/tabi-lean/templates/partials/extra_features.html new file mode 100644 index 0000000..50c3337 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/extra_features.html @@ -0,0 +1,88 @@ +{%- set page_or_section = page | default(value=section) -%} + +{# prepare parameters for evaluate_setting_priority macro #} +{%- set page_s = page | default(value="") -%} +{%- set section_s = section | default(value="") -%} + +{# Quick navigation buttons #} +{% if macros_settings::evaluate_setting_priority(setting="quick_navigation_buttons", page=page_s, section=section_s, default_global_value=false) == "true" %} + <div id="button-container"> + {# Button to go show a floating Table of Contents #} + {% if page_or_section.toc %} + <div id="toc-floating-container"> + <input type="checkbox" id="toc-toggle" class="toggle"/> + <label for="toc-toggle" class="overlay"></label> + <label for="toc-toggle" id="toc-button" class="button" title="{{ macros_translate::translate(key="toggle_toc", default="Toggle Table of Contents", language_strings=language_strings) }}"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M414.82-193.094q-18.044 0-30.497-12.32-12.453-12.319-12.453-30.036t12.453-30.086q12.453-12.37 30.497-12.37h392.767q17.237 0 29.927 12.487 12.69 12.486 12.69 30.203 0 17.716-12.69 29.919t-29.927 12.203H414.82Zm0-244.833q-18.044 0-30.497-12.487Q371.87-462.9 371.87-480.45t12.453-29.92q12.453-12.369 30.497-12.369h392.767q17.237 0 29.927 12.511 12.69 12.512 12.69 29.845 0 17.716-12.69 30.086-12.69 12.37-29.927 12.37H414.82Zm0-245.167q-18.044 0-30.497-12.32t-12.453-30.037q0-17.716 12.453-30.086 12.453-12.369 30.497-12.369h392.767q17.237 0 29.927 12.486 12.69 12.487 12.69 30.203 0 17.717-12.69 29.92-12.69 12.203-29.927 12.203H414.82ZM189.379-156.681q-32.652 0-55.878-22.829t-23.226-55.731q0-32.549 23.15-55.647 23.151-23.097 55.95-23.097 32.799 0 55.313 23.484 22.515 23.484 22.515 56.246 0 32.212-22.861 54.893-22.861 22.681-54.963 22.681Zm0-245.167q-32.652 0-55.878-23.134-23.226-23.135-23.226-55.623 0-32.487 23.467-55.517t56.12-23.03q32.102 0 54.721 23.288 22.62 23.288 22.62 55.775 0 32.488-22.861 55.364-22.861 22.877-54.963 22.877Zm-.82-244.833q-32.224 0-55.254-23.288-23.03-23.289-23.03-55.623 0-32.333 23.271-55.364 23.272-23.03 55.495-23.03 32.224 0 55.193 23.288 22.969 23.289 22.969 55.622 0 32.334-23.21 55.364-23.21 23.031-55.434 23.031Z"/></svg> + </label> + <div class="toc-content"> + {{ macros_toc::toc(page=page_or_section, header=false, language_strings=language_strings) }} + </div> + </div> + {% endif %} + + {# Button to go to the comment/webmentions section #} + {% if comment_system or config.extra.webmentions.enable %} + {%- if comment_system -%} + {#- Comments are shown above webmentions -#} + {%- set comments_id = "comments" -%} + {%- else -%} + {%- set comments_id = "webmentions" -%} + {%- endif -%} + + <a href="#{{- comments_id -}}" id="comments-button" class="no-hover-padding" title="{{ macros_translate::translate(key="go_to_comments", default="Go to comments section", language_strings=language_strings) }}"> + <svg viewBox="0 0 20 20" fill="currentColor"><path d="M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z" clip-rule="evenodd" fill-rule="evenodd"/></svg> + </a> + {% endif %} + + {# Button to go to the top of the page #} + <a href="#" id="top-button" class="no-hover-padding" title="{{ macros_translate::translate(key="go_to_top", default="Go to the top of the page", language_strings=language_strings) }}"> + <svg viewBox="0 0 20 20" fill="currentColor"><path d="M3.293 9.707a1 1 0 010-1.414l6-6a1 1 0 011.414 0l6 6a1 1 0 01-1.414 1.414L11 5.414V17a1 1 0 11-2 0V5.414L4.707 9.707a1 1 0 01-1.414 0z"/></svg> + </a> + </div> +{% endif %} + +{# Add KaTeX functionality #} +{%- if macros_settings::evaluate_setting_priority(setting="katex", page=page_s, section=section_s, default_global_value=false) == "true" -%} + <link rel="stylesheet" href="{{ get_url(path='katex.min.css', trailing_slash=false) | safe }}"> + <script defer src="{{ get_url(path='js/katex.min.js', trailing_slash=false) | safe }}"></script> +{%- endif -%} + +{# Load mermaid.js #} +{%- if macros_settings::evaluate_setting_priority(setting="mermaid", page=page_s, section=section_s, default_global_value=false) == "true" -%} + {%- if config.extra.serve_local_mermaid | default(value=true) -%} + <script defer src="{{ get_url(path='js/mermaid.min.js', trailing_slash=false) | safe }}"></script> + {%- else -%} + <script defer src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script> + {%- endif -%} +{%- endif -%} + +{# Add copy button to code blocks #} +{%- if macros_settings::evaluate_setting_priority(setting="copy_button", page=page_s, section=section_s, default_global_value=true) == "true" -%} + {#- Add hidden HTML elements with the translated strings for the button's interactions -#} + <span id="copy-success" class="hidden"> + {{ macros_translate::translate(key="copied", default="Copied!", language_strings=language_strings) }} + </span> + <span id="copy-init" class="hidden"> + {{ macros_translate::translate(key="copy_code_to_clipboard", default="Copy code to clipboard", language_strings=language_strings) }} + </span> + <script defer src="{{ get_url(path='js/copyCodeToClipboard.min.js', trailing_slash=false) | safe }}"></script> +{%- endif -%} + +{# JavaScript to make code block names clickable when they are URLs: https://welpo.github.io/tabi/blog/shortcodes/#show-source-or-path #} +{# Note: "add_src_to_code_block" is deprecated in favor of "code_block_name_links". It will be removed in a future release. #} +{# See https://github.com/welpo/tabi/pull/489 #} +{%- if macros_settings::evaluate_setting_priority(setting="code_block_name_links", page=page_s, section=section_s, default_global_value=false) == "true" + or macros_settings::evaluate_setting_priority(setting="add_src_to_code_block", page=page_s, section=section_s, default_global_value=false) == "true" -%} + <script defer src="{{ get_url(path='js/codeBlockNameLinks.min.js', trailing_slash=false) | safe }}"></script> +{%- endif -%} + +{# Add backlinks to footnotes #} +{%- if macros_settings::evaluate_setting_priority(setting="footnote_backlinks", page=page_s, section=section_s, default_global_value=false) == "true" -%} + <script defer src="{{ get_url(path='js/footnoteBacklinks.min.js', trailing_slash=false | safe )}}"></script> +{%- endif -%} + +{# Add iine.js for the like button #} +{%- if macros_settings::evaluate_setting_priority(setting="iine", page=page_s, section=section_s, default_global_value=false) == "true" -%} + <script defer src="https://cdn.jsdelivr.net/gh/welpo/iine@main/iine.mini.js"></script> +{%- endif -%} diff --git a/sysret.org/themes/tabi-lean/templates/partials/filter_card_tags.html b/sysret.org/themes/tabi-lean/templates/partials/filter_card_tags.html new file mode 100644 index 0000000..d40ec2d --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/filter_card_tags.html @@ -0,0 +1,35 @@ +{#- Collect all terms. -#} +{#- We don't use `get_taxonomy` so users aren't forced to use 'tags' -#} +{% set all_terms = [] %} +{% for page in show_pages %} + {% if page.taxonomies %} + {% for tax_name, terms in page.taxonomies %} + {% for term in terms %} + {% set_global all_terms = all_terms | concat(with=term) %} + {% endfor %} + {% endfor %} + {% endif %} +{% endfor %} + +{#- Display unique terms -#} +{% set unique_terms = all_terms | unique | sort %} +{%- if unique_terms | length >= 2 -%} + <ul class="filter-controls" role="group" aria-label="{{ macros_translate::translate(key='project_filters', default='Project filters', language_strings=language_strings) }}"> + <li class="taxonomy-item no-hover-padding"> + <a id="all-projects-filter" class="no-hover-padding active" + href="{{ get_url(path="projects", lang=lang) }}" + data-filter="all"> + {{- macros_translate::translate(key="all_projects", default="All projects", language_strings=language_strings) -}} + </a> + </li> + {% for term in unique_terms %} + <li class="taxonomy-item no-hover-padding"> + <a class="no-hover-padding" + href="{{ get_taxonomy_url(kind="tags", name=term, lang=lang) }}" + data-filter="{{ term | lower }}">{{ term }}</a> + </li> + {% endfor %} + </ul> + {#- Load the script -#} + <script src="{{ get_url(path='js/filterCards.min.js', trailing_slash=false, cachebust=true) | safe }}" defer></script> +{% endif %} diff --git a/sysret.org/themes/tabi-lean/templates/partials/footer.html b/sysret.org/themes/tabi-lean/templates/partials/footer.html new file mode 100644 index 0000000..db4bd85 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/footer.html @@ -0,0 +1,127 @@ +{%- 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) -%} + +{#- Feed icon -#} +{%- set feed_url = feed_utils::get_feed_url() -%} +{%- set should_show_feed = feed_utils::should_show_footer_feed_icon() == "true" -%} + +{%- set should_show_footer_icons = should_show_feed or config.extra.socials or config.extra.email -%} + +<footer> + <section> + <nav class="socials nav-navs"> + {%- if should_show_footer_icons -%} + <ul> + {%- if should_show_feed -%} + <li> + <a class="nav-links no-hover-padding social" rel="{{ rel_attributes }}" {{ blank_target }} href="{{ get_url(path=feed_url, lang=lang, trailing_slash=false) | safe }}"> + <img loading="lazy" alt="feed" title="feed" src="{{ get_url(path='/social_icons/rss.svg') }}"> + </a> + </li> + {%- endif -%} + + {# Mail icon #} + {%- if config.extra.email -%} + {%- set email_already_encoded = (config.extra.email is not containing("@")) -%} + {%- set email_needs_decoding = email_already_encoded or config.extra.encode_plaintext_email -%} + + {%- if email_already_encoded -%} + {%- set encoded_email = config.extra.email -%} + {# Verify the pre-encoded e-mail is valid (i.e. contains an '@') #} + {%- set decoded_email = encoded_email | base64_decode -%} + {%- if '@' not in decoded_email -%} + {{ throw(message="ERROR: The provided e-mail appears to be base64-encoded, but does not decode to a valid e-mail address.")}} + {%- endif -%} + {%- elif config.extra.encode_plaintext_email -%} + {%- set encoded_email = config.extra.email | base64_encode -%} + {%- endif -%} + + <li class="{% if email_needs_decoding %}js{% endif %}"> + {%- if email_needs_decoding -%} + <a class="nav-links no-hover-padding social" href="#" data-encoded-email="{{ encoded_email | safe }}"> + {%- else -%} + <a class="nav-links no-hover-padding social" href="mailto:{{ config.extra.email | safe }}"> + {%- endif -%} + <img loading="lazy" alt="email" title="email" src="{{ get_url(path='social_icons/email.svg') }}"> + </a> + </li> + {%- endif -%} + + {%- if config.extra.socials %} + {% for social in config.extra.socials %} + <li> + <a class="nav-links no-hover-padding social" rel="{{ rel_attributes }} me" {{ blank_target }} href="{{ social.url | safe }}"> + <img loading="lazy" alt="{{ social.name }}" title="{{ social.name }}" src="{{ get_url(path='social_icons/' ~ social.icon ~ '.svg') }}"> + </a> + </li> + {% endfor %} + {% endif %} + </ul> + {% endif %} + </nav> + + {# Footer menu #} + <nav class="nav-navs"> + {%- if config.extra.footer_menu %} + <small> + <ul> + {% for menu in config.extra.footer_menu %} + <li> + {%- set trailing_slash = menu.trailing_slash | default(value=true) -%} + + {%- if menu.url == "sitemap.xml" -%} + {%- set url = get_url(path=menu.url, trailing_slash=trailing_slash) -%} + {%- elif menu.url is starting_with("http") -%} + {%- if menu.trailing_slash -%} + {%- set url = menu.url ~ "/" -%} + {%- else -%} + {%- set url = menu.url -%} + {%- endif -%} + {%- else -%} + {%- set url = get_url(path=menu.url, lang=lang, trailing_slash=trailing_slash) -%} + {%- endif -%} + + <a class="nav-links no-hover-padding" href="{{ url }}"> + {{ macros_translate::translate(key=menu.name, default=menu.name, language_strings=language_strings) }} + </a> + </li> + {% endfor %} + </ul> + </small> + {% endif %} + </nav> + + <div class="credits"> + <small> + {% include "partials/copyright.html" %} + + {# Shows "Powered by Zola & tabi" notice #} + {{ macros_translate::translate(key="powered_by", default="Powered by", language_strings=language_strings) }} + <a rel="{{ rel_attributes }}" {{ blank_target }} href="https://www.getzola.org">Zola</a> + {{ macros_translate::translate(key="and", default="&", language_strings=language_strings) }} + <a rel="{{ rel_attributes }}" {{ blank_target }} href="https://github.com/welpo/tabi">tabi</a> + + {# Shows link to remote repository #} + {%- if config.extra.remote_repository_url and config.extra.show_remote_source | default(value=true) -%} + {{ separator }} + <a rel="{{ rel_attributes }}" {{ blank_target }} href="{{ config.extra.remote_repository_url }}"> + {{ macros_translate::translate(key="site_source", default="Site source", language_strings=language_strings) }} + </a> + {%- endif -%} + </small> + </div> + </section> + + {# Load the decoding script if email is encoded #} + {%- if email_needs_decoding -%} + <script src="{{ get_url(path='js/decodeMail.min.js') }}" async></script> + {%- endif -%} + + {# Modal structure for search #} + {%- if config.build_search_index -%} + {% include "partials/search_modal.html" %} + {%- endif -%} +</footer> diff --git a/sysret.org/themes/tabi-lean/templates/partials/hcard.html b/sysret.org/themes/tabi-lean/templates/partials/hcard.html new file mode 100644 index 0000000..6479da6 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/hcard.html @@ -0,0 +1,75 @@ +{%- set hcard = config.extra.hcard -%} + +{% set full_name = config.author %} +{% if hcard.full_name %} + {% set full_name = hcard.full_name %} +{% endif %} + +{%- set homepage = config.base_url -%} +{% if hcard.homepage %} + {%- set homepage = hcard.homepage -%} +{% endif %} + +{% if hcard.enable %} +<div class="h-card hidden"> + <div> + {%- if hcard.avatar -%} + <img + class="u-photo" + src="{{ get_url(path=hcard.avatar, cachebust=true) }}" + width="200" + height="200" + alt="{{ full_name }}" + /> + {%- endif -%} + + <span class="p-name" rel="me">{{ full_name }}</span> + + {% if hcard.p_nickname %} + ( <span class="p-nickname">{{ hcard.p_nickname }}</span> ) + {% endif %} + </div> + + {% if hcard.biography %} + <p class="p-note">{{ hcard.biography }}</p> + {% endif %} + + {# links #} + <div> + {%- if hcard.with_mail and config.extra.email and not config.extra.encode_plaintext_email -%} + <span> + <a class="u-email" href="mailto:{{ config.extra.email | safe }}">email</a> + </span> - + {%- endif -%} + + <span> + <a class="u-url u-id" href="{{ homepage }}">homepage</a> + </span> - + + {%- if hcard.with_social_links and config.extra.socials %} + {% for social in config.extra.socials %} + <span> + <a class="p-url" rel="me" href="{{ social.url | safe }}">{{ social.name }}</a> + </span> - + {% endfor %} + {% endif %} + </div> + + {# additional properties #} + {% set dl_started = false %} + {% for key, value in hcard %} + {% if key not in ['enable', 'with_mail', 'with_social_links', 'homepage', 'full_name', 'avatar', 'biography', 'p_nickname'] %} + {% if not dl_started %} + <dl> + {% set_global dl_started = true %} + {% endif %} + <dt>{{ key | replace(from="p_", to="") | replace(from="u_", to="") | replace(from="dt_", to="") | replace(from="_", to=" ") | capitalize }}</dt> + <dd class="{{ key | replace(from="_", to="-") }}">{{ value }}</dd> + {% endif %} + {% endfor %} + {% if dl_started %} + </dl> + {% endif %} + + </div> +{% endif %} diff --git a/sysret.org/themes/tabi-lean/templates/partials/hcard_small.html b/sysret.org/themes/tabi-lean/templates/partials/hcard_small.html new file mode 100644 index 0000000..f30add5 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/hcard_small.html @@ -0,0 +1,26 @@ +{%- set hcard = config.extra.hcard -%} + +{%- set full_name = config.author -%} +{%- if hcard.full_name -%} + {%- set full_name = hcard.full_name -%} +{%- endif -%} + +{%- set homepage = config.base_url -%} +{%- if hcard.homepage -%} + {%- set homepage = hcard.homepage -%} +{%- endif -%} + +{%- set icon_attr = "" -%} +{%- if hcard.avatar -%} + {%- set icon_attr = "author-icon" -%} +{%- endif -%} + +<span class="hidden p-author h-card"> +<a rel="author" href="{{ homepage }}" class="u-url {{ icon_attr }}" title="{{ full_name }}"> + {%- if hcard.avatar -%} + <img class="u-photo" src="{{ get_url(path=hcard.avatar, cachebust=true) }}" alt="{{ full_name }}" /> + {%- else -%} + {{ full_name }} + {%- endif -%} +</a> +</span> diff --git a/sysret.org/themes/tabi-lean/templates/partials/header.html b/sysret.org/themes/tabi-lean/templates/partials/header.html new file mode 100644 index 0000000..ada1f23 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/header.html @@ -0,0 +1,182 @@ +<head> + <meta charset="UTF-8"> + + {%- if macros_settings::evaluate_setting_priority(setting="enable_csp", page=page | default(value=""), section=section | default(value=""), default_global_value="true") == "true" -%} + {%- include "partials/content_security_policy.html" -%} + {%- endif -%} + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <meta name="base" content="{{ config.base_url | safe }}"> + + {# Site title #} + <title>{%- include "partials/title.html" -%}</title> + + {# Favicon #} + {% if config.extra.favicon %} + <link rel="icon" type="image/png" href="{{ get_url(path=config.extra.favicon) }}"/> + {% endif %} + {% if config.extra.favicon_emoji %} + <link rel=icon href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="50%" x="50%" dominant-baseline="central" text-anchor="middle" font-size="88">{{ config.extra.favicon_emoji }}</text></svg>'> + {% endif %} + + {# Feeds #} + {% if config.generate_feeds | default(value=config.generate_feed) %} + {% if config.feed_filenames %} + {# Zola 0.19 and newer #} + {% for feed in config.feed_filenames %} + {% if feed == "atom.xml" %} + <link rel="alternate" type="application/atom+xml" title="{{ config.title | safe }} - Atom Feed" href="{{ get_url(path=feed, trailing_slash=false) | safe }}"> + {% elif feed == "rss.xml" %} + <link rel="alternate" type="application/rss+xml" title="{{ config.title | safe }} - RSS Feed" href="{{ get_url(path=feed, trailing_slash=false) | safe }}"> + {% else %} + <link rel="alternate" href="{{ get_url(path=feed, trailing_slash=false) | safe }}"> + {% endif %} + {% endfor %} + {% else %} + {# Older Zola versions #} + {% set feed_url = config.feed_filename | default(value="atom.xml") %} + <link rel="alternate" type="application/atom+xml" title="{{ config.title | safe }}" href="{{ get_url(path=feed_url, trailing_slash=false) | safe }}"> + {% endif %} + {% endif %} + + {# CSS #} + {# Load subset of glyphs for header. Avoids flashing issue in Firefox #} + {% if config.extra.enable_subset %} + {% if config.extra.custom_subset == true %} + <link rel="stylesheet" href="{{ get_url(path="custom_subset.css" , cachebust=true) }}"> + {% elif lang == 'en' %} + <link rel="stylesheet" href="{{ get_url(path="inter_subset_en.css", cachebust=true ) }}"> + {% elif lang == 'es' %} + <link rel="stylesheet" href="{{ get_url(path="inter_subset_es.css", cachebust=true ) }}"> + {% endif %} + {% endif %} + + {# Define array of CSS files to load. main.css is always loaded. #} + {%- set stylesheets = [ "main.css" ] -%} + + {# Load extra CSS files from config.toml #} + {%- if config.extra.stylesheets -%} + {%- set stylesheets = stylesheets | concat(with=config.extra.stylesheets) -%} + {%- endif -%} + + {# Load extra CSS files from page metadata #} + {%- if page.extra.stylesheets -%} + {%- set stylesheets = stylesheets | concat(with=page.extra.stylesheets) -%} + {%- endif -%} + + {# Load extra CSS for custom skin #} + {%- if config.extra.skin -%} + {%- set stylesheets = stylesheets | concat(with='skins/' ~ config.extra.skin ~ '.css') -%} + {%- endif -%} + + {# Load all stylesheets #} + {%- for stylesheet in stylesheets %} + <link rel="stylesheet" href="{{ get_url(path=stylesheet, cachebust=true) | safe }}" /> + {%- endfor %} + + <meta name="color-scheme" content="{%- if config.extra.theme_switcher -%}light dark{%- elif config.extra.default_theme -%}{{config.extra.default_theme}}{%- else -%}light{%- endif -%}" /> + + {%- if config.extra.browser_theme_color and config.extra.browser_theme_color is iterable -%} + {# Handle array values: theme_color[0] for light mode, theme_color[1] for dark mode #} + <meta name="theme-color" media="(prefers-color-scheme: light)" content="{{ config.extra.browser_theme_color[0] }}" /> + <meta name="theme-color" media="(prefers-color-scheme: dark)" content="{{ config.extra.browser_theme_color[1] }}" /> + {%- elif config.extra.browser_theme_color -%} + {# Handle single value #} + <meta name="theme-color" content="{{ config.extra.browser_theme_color }}" /> + {%- endif -%} + + {%- if page.description %} + <meta name="description" content="{{ page.description }}" /> + <meta property="og:description" content="{{ page.description }}" /> + {%- elif section.description %} + <meta name="description" content="{{ section.description }}" /> + <meta property="og:description" content="{{ section.description }}" /> + {%- elif page.summary %} + <meta name="description" content="{{ page.summary | striptags | trim_end_matches(pat=".") | safe }}…" /> + <meta property="og:description" content="{{ page.summary | striptags | trim_end_matches(pat=".") | safe }}…" /> + {%- else %} + <meta name="description" content="{{ config.description }}" /> + <meta property="og:description" content="{{ config.description }}" /> + {%- endif %} + + {% if is_404 %} + <meta name="robots" content="noindex, follow" /> + {% endif %} + + <meta property="og:title" content="{{ page.title | default(value=config.title) | safe }}" /> + <meta property="og:type" content="article" /> + + {# Image for social media sharing #} + {%- include "partials/social_media_images.html" -%} + + {# Add og:locale and hreflang tags for multilingual sites #} + {%- if config.languages | length > 0 and current_url %} + {%- include "partials/multilingual_tags.html" -%} + {%- else -%} + <meta property="og:locale" content="{{ macros_translate::translate(key="date_locale", default="en_GB", language_strings=language_strings) }}" /> + {%- endif %} + + {# Set canonical URL #} + {%- if current_url -%} + {%- if page.extra.canonical_url or section.extra.canonical_url -%} + {%- set canonical_url = page.extra.canonical_url | default(value=section.extra.canonical_url) -%} + {%- elif config.extra.base_canonical_url -%} + {%- set canonical_url = current_url | replace(from=config.base_url, to=config.extra.base_canonical_url) -%} + {%- endif -%} + {%- endif -%} + + {# Add canonical URL, if set #} + {%- if canonical_url -%} + <link rel="canonical" href="{{ canonical_url }}" /> + <meta property="og:url" content="{{ canonical_url }}" /> + {%- elif current_url -%} + <meta property="og:url" content="{{ current_url }}" /> + {%- endif -%} + + <meta property="og:site_name" content="{{ config.title }}"> + + {%- if config.extra.theme_switcher and config.extra.theme_switcher == true -%} + {# If JavaScript is disabled, hide the button. #} + <noscript><link rel="stylesheet" href="{{ get_url(path='no_js.css') | safe }}"/></noscript> + <script type="text/javascript" src="{{ get_url(path='js/initializeTheme.min.js') | safe }}"></script> + <script defer src="{{ get_url(path='js/themeSwitcher.min.js', trailing_slash=false) | safe }}"></script> + {%- endif -%} + + {%- if config.extra.analytics.service -%} + {%- include "partials/analytics.html" -%} + {%- endif -%} + + {# Socials #} + {%- if config.extra.fediverse_creator -%} + <meta name="fediverse:creator" content="@{{ config.extra.fediverse_creator["handle"] }}@{{ config.extra.fediverse_creator["domain"]}}" /> + {%- endif -%} + + {# Search #} + {%- if config.build_search_index -%} + {%- if config.search.index_format -%} + {%- set search_index_format = config.search.index_format -%} + {%- elif config.extra.index_format -%} + {# Necessary to support Zola 0.17.X, as it doesn't have access to config.search.index_format #} + {# See: https://github.com/getzola/zola/issues/2165 #} + {%- set search_index_format = config.extra.index_format -%} + {%- else -%} + {%- set search_index_format = "elasticlunr_json" -%} + {%- endif -%} + + {%- if search_index_format == "elasticlunr_javascript" -%} + <script defer src="{{ get_url(path='search_index.' ~ lang ~ '.js', cachebust=true) | safe }}"></script> + {%- endif -%} + + {# Main search script #} + <script defer src="{{ get_url(path='js/searchElasticlunr.min.js', cachebust=true) | safe }}"></script> + + {# Support correct stemming and stop word filtering in non-English search #} + {%- if lang != "en" -%} + <script defer src="{{ get_url(path='js/lunr/lunrStemmerSupport.min.js') | safe }}"></script> + <script defer src="{{ get_url(path='js/lunr/lunr.' ~ lang ~ '.min.js') | safe }}"></script> + {%- endif -%} + {%- endif -%} + + {# Users can optionally provide this template to add content to the head element. #} + {% include "tabi/extend_head.html" ignore missing %} +</head> diff --git a/sysret.org/themes/tabi-lean/templates/partials/history_url.html b/sysret.org/themes/tabi-lean/templates/partials/history_url.html new file mode 100644 index 0000000..8327ca3 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/history_url.html @@ -0,0 +1,26 @@ +{%- set relative_path = page.relative_path -%} +{%- set repository_url = config.extra.remote_repository_url | trim_end_matches(pat='/') -%} +{%- set branch = config.extra.remote_repository_branch | default(value="main") -%} +{%- set git_platform = config.extra.remote_repository_git_platform | default(value="auto") -%} + +{# Auto-detect the git platform based on the URL#} +{%- if git_platform == "auto" %} + {%- if repository_url is containing("github.") -%} + {%- set git_platform = "github" -%} + {%- elif repository_url is containing("gitlab.") -%} + {%- set git_platform = "gitlab" -%} + {%- elif repository_url is matching("(gitea\.|codeberg\.)") -%} + {%- set git_platform = "gitea" -%} + {%- endif -%} +{%- endif -%} + +{# Generate the commit history URL based on the git platform #} +{%- if git_platform == "github" -%} + {{ repository_url ~ '/commits/' ~ branch ~ '/content/' }}{{ relative_path | urlencode }} +{%- elif git_platform == "gitlab" -%} + {{ repository_url ~ '/-/commits/' ~ branch ~ '/content/' }}{{ relative_path | urlencode }} +{%- elif git_platform in ["gitea", "codeberg"] -%} + {{ repository_url ~ '/commits/branch/' ~ branch ~ '/content/' }}{{ relative_path | urlencode }} +{%- else -%} + {{ throw(message="ERROR: Unknown, unsupported, or unspecified git platform. If you're using a custom domain, please specify the 'git_platform' in the config. If you think this is a bug, please report it: https://github.com/welpo/tabi/issues/new?assignees=&labels=bug&template=bug_report.md&title=Unsupported%20Git%20Platform%20Detected") }} +{%- endif -%} diff --git a/sysret.org/themes/tabi-lean/templates/partials/home_banner.html b/sysret.org/themes/tabi-lean/templates/partials/home_banner.html new file mode 100644 index 0000000..353757b --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/home_banner.html @@ -0,0 +1,20 @@ +{%- set header = section.extra.header-%} +<div id="banner-container-home"> + <div id="home-banner-text"> + <h1 id="home-banner-header">{{ header.title }}</h1> + <section id="banner-home-subtitle"> + {{ section.content | safe }} + </section> + </div> + {%- if header.img -%} + {%- if header.img is containing("$BASE_URL") -%} + {# Conversion no longer supported in favour of proper path. #} + {{ throw(message="ERROR: The image path for the header should not contain '$BASE_URL'. Please remove it and use the proper image path.") }} + {%- else -%} + {%- set image_path = get_url(path=header.img, trailing_slash=false) | safe -%} + {%- endif -%} + <div id="image-container-home"> + <img alt="{{ header.img_alt | default(value="the owner") }}" id="banner-home-img" src="{{ image_path }}" /> + </div> + {%- endif -%} +</div> diff --git a/sysret.org/themes/tabi-lean/templates/partials/iine_button.html b/sysret.org/themes/tabi-lean/templates/partials/iine_button.html new file mode 100644 index 0000000..508fd3a --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/iine_button.html @@ -0,0 +1,33 @@ +{% import "macros/settings.html" as macros_settings %} +{%- set button_icon = button_icon | default(value=macros_settings::evaluate_setting_priority(setting="iine_icon", page=page | default(value=""), section=section | default(value=""), default_global_value="heart")) -%} +{%- if config.extra.iine_unified_languages and lang != config.default_language -%} + {%- set unified_slug = page.path | replace(from='/' ~ lang ~ '/', to='/') -%} + {%- set slug = slug | default(value=unified_slug) -%} +{%- else -%} + {%- set slug = slug | default(value=page.path) -%} +{%- endif -%} +{%- if label -%} + {%- set final_label = label -%} +{%- elif language_strings -%} + {%- set final_label = macros_translate::translate(key="like_this_post", default="Like this post", language_strings=language_strings) -%} +{%- else -%} + {%- set final_label = "Like this post" -%} +{%- endif -%} + +{%- if button_icon == "heart" -%} + {%- set icon_display = "♥️" -%} +{%- elif button_icon == "thumbs_up" -%} + {%- set icon_display = "👍" -%} +{%- elif button_icon == "upvote" -%} + {%- set icon_display = "⬆️" -%} +{%- else -%} + {%- set icon_display = button_icon -%} +{%- endif -%} + +<form method="post" action="https://vhiweeypifbwacashxjz.supabase.co/rest/v1/rpc/increment_hits?apikey=sb_publishable_EoB7MFJhCmb6PiAk-GPJ4w_PGhQ44Ru" class="iine-form"> + <input type="hidden" name="page_slug" value="{%- if slug -%}{{ slug }}{%- else -%}{{ current_url | default(value=page.path) }}{%- endif -%}"> + <button class="iine-button" type="submit" + {%- if slug %} data-slug="{{ slug }}"{% endif %} + {%- if button_icon %} data-icon="{{ button_icon }}"{% endif %} + aria-label="{{ final_label }}" title="{{ final_label }}">{{ icon_display }}</button> +</form> diff --git a/sysret.org/themes/tabi-lean/templates/partials/language_switcher.html b/sysret.org/themes/tabi-lean/templates/partials/language_switcher.html new file mode 100644 index 0000000..83cf61f --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/language_switcher.html @@ -0,0 +1,38 @@ +<li class="language-switcher"> + <details class="dropdown"> + <summary role="button" aria-haspopup="true" title="{{ macros_translate::translate(key="language_selection", default="Language selection", language_strings=language_strings) }}" aria-label="{{ macros_translate::translate(key="language_selection", default="Language selection", language_strings=language_strings) }}"> + <div class="language-switcher-icon"></div> + </summary> + <div class="dropdown-content" role="menu"> + {#- Display the current language first in the dropdown -#} + {{ macros_translate::translate(key="language_name", default=lang, language_strings=language_strings) }} + {#- Loop through all the available languages in the config -#} + {%- for lcode, ldetails in config.languages -%} + {#- Skip the current language to avoid linking to the current page -#} + {%- if lang == lcode -%} + {%- continue -%} + {%- endif -%} + {#- Dynamically load the language strings for each language -#} + {%- set other_language_strings = load_data(path="i18n/" ~ lcode ~ ".toml", required=false) -%} + {%- if not other_language_strings -%} + {%- set other_language_strings = load_data(path="themes/tabi/i18n/" ~ lcode ~ ".toml", required=false) -%} + {%- endif -%} + {#- Use the loaded language strings to get the language name -#} + {% set language_name = macros_translate::translate(key="language_name", default=lcode, + language_strings=other_language_strings) %} + {#- Check if the language code matches the default language -#} + {%- if lcode == config.default_language -%} + {#- If it does, link to the root path (no language code in URL) -#} + <a role="menuitem" lang="{{ lcode }}" aria-label="{{ language_name }}" href="{{ current_url | replace(from='/' ~ lang ~ '/', to = '/') }}">{{ language_name }}</a> + {#- Check if the current language is the default language -#} + {#- If it is, append the language code to the base URL -#} + {%- elif lang == config.default_language -%} + <a role="menuitem" lang="{{ lcode }}" aria-label="{{ language_name }}" href="{{ config.base_url }}/{{ lcode }}{{ current_path | default(value="/") | safe }}">{{ language_name }}</a> + {%- else -%} + {#- If it's not, replace the current language code in the URL with the new one -#} + <a role="menuitem" lang="{{ lcode }}" aria-label="{{ language_name }}" href="{{ current_url | replace(from='/' ~ lang ~ '/', to='/' ~ lcode ~ '/') }}">{{ language_name }}</a> + {%- endif -%} + {%- endfor -%} + </div> + </details> +</li> diff --git a/sysret.org/themes/tabi-lean/templates/partials/main_page_posts_list.html b/sysret.org/themes/tabi-lean/templates/partials/main_page_posts_list.html new file mode 100644 index 0000000..067e178 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/main_page_posts_list.html @@ -0,0 +1,61 @@ +{%- if paginator or extra_section -%} + <div id="posts-list"> + <div> + {{ macros_page_header::page_header(title=section.title) }} + </div> + + {# Check if both paginate_by and section_path are set #} + {%- set both_settings_set = paginator and extra_section -%} + {%- set paginator_has_no_pages = paginator and paginator.pages | length == 0 -%} + {%- set extra_section_has_pages = extra_section and extra_section.pages | length > 0 -%} + + {# Display warning if both settings are set #} + {%- if both_settings_set and paginator_has_no_pages and extra_section_has_pages -%} + <div class="admonition warning"> + <div class="admonition-icon admonition-icon-warning"></div> + <div class="admonition-content"> + <strong class="admonition-title">WARNING: Conflicting Configuration</strong> + <p> + No posts are displayed due to conflicting settings in your <code>_index.md</code>: + </p> + <ul> + <li><code>paginate_by</code> is set, but there are no posts to paginate in the current section.</li> + <li><code>section_path</code> is set, and posts are available in that section.</li> + </ul> + <p> + <strong>Solution:</strong> Remove <code>paginate_by</code> from your <code>_index.md</code>. + To limit the number of displayed posts, use <code>max_posts</code> in the <code>[extra]</code> section instead. + </p> + </div> + </div> + {%- endif -%} + + {# Get all posts for pinning if we're in root section with pagination #} + {%- if paginator and is_root_section -%} + {%- set root_section = get_section(path="_index.md") -%} + {%- set all_posts = root_section.pages -%} + {%- set pages = paginator.pages -%} + {%- elif paginator -%} + {%- set all_posts = paginator.pages -%} + {%- set pages = paginator.pages -%} + {%- else -%} + {%- set all_posts = extra_section.pages -%} + {%- set pages = extra_section.pages -%} + {%- endif -%} + + {% set max_posts = section.extra.max_posts | default(value=999999) %} + {{ macros_list_posts::list_posts( + posts=pages, + all_posts=all_posts, + max=max_posts, + language_strings=language_strings, + section_path=extra_section.path | default(value="blog"), + pinned_first=is_root_section, + current_page=paginator.current_index | default(value=1) + ) }} + </div> + + {% if paginator and paginator.pages | length > 0 %} + {%- include "partials/paginate.html" -%} + {% endif %} +{%- endif -%} diff --git a/sysret.org/themes/tabi-lean/templates/partials/main_page_projects_list.html b/sysret.org/themes/tabi-lean/templates/partials/main_page_projects_list.html new file mode 100644 index 0000000..82f0637 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/main_page_projects_list.html @@ -0,0 +1,16 @@ +{% if section.extra.projects_path %} + {%- set projects_section = get_section(path=section.extra.projects_path) -%} + {%- if projects_section -%} + <div id="featured-projects" class="list"> + {{ macros_page_header::page_header(title=macros_translate::translate(key="featured_projects", default="Featured projects", language_strings=language_strings)) }} + </div> + {%- set show_pages = projects_section.pages -%} + {%- set max_projects = section.extra.max_projects | default(value=3) -%} + {%- include "partials/cards_pages.html" -%} + {%- endif -%} + {%- if show_pages | length > max_projects -%} + <div class="all-posts" id="all-projects"> + <a href="{{ get_url(path=projects_section.path, lang=lang) }}/">{{ macros_translate::translate(key="all_projects", default="All projects", language_strings=language_strings) }} <span class="arrow">⟶</span></a> + </div> + {%- endif -%} +{% endif %} diff --git a/sysret.org/themes/tabi-lean/templates/partials/multilingual_tags.html b/sysret.org/themes/tabi-lean/templates/partials/multilingual_tags.html new file mode 100644 index 0000000..fe81e6e --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/multilingual_tags.html @@ -0,0 +1,29 @@ +{%- if section.translations -%} + {%- set current_translations = section.translations -%} +{%- elif page.translations -%} + {%- set current_translations = page.translations -%} +{%- endif -%} + +{%- if current_translations -%} + + {%- for translation in current_translations -%} + {%- set lcode = translation.lang | default(value = config.default_language) -%} + + {#- Dynamically load the language strings for each language -#} + {%- set other_language_strings = load_data(path="i18n/" ~ lcode ~ ".toml", required=false) -%} + {%- if not other_language_strings -%} + {%- set other_language_strings = load_data(path="themes/tabi/i18n/" ~ lcode ~ ".toml", required=false) -%} + {%- endif -%} + <meta property="og:locale:alternate" content="{{ macros_translate::translate(key="date_locale", default="en_GB", language_strings=other_language_strings) }}" /> + + {# Construct href for hreflang #} + {%- set href = translation.permalink -%} + {%- if lcode == config.default_language -%} + {%- set href = href | replace(from='/' ~ lang ~ '/', to = '/') -%} + {%- else -%} + {%- set href = href | replace(from='/' ~ lang ~ '/', to='/' ~ lcode ~ '/') -%} + {%- endif -%} + <link rel="alternate" hreflang="{{ lcode }}" href="{{ href | safe }}" /> + {%- endfor -%} + +{%- endif -%} diff --git a/sysret.org/themes/tabi-lean/templates/partials/nav.html b/sysret.org/themes/tabi-lean/templates/partials/nav.html new file mode 100644 index 0000000..de55151 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/nav.html @@ -0,0 +1,60 @@ +<header> + <nav class="navbar"> + <div class="nav-title"> + <a class="home-title" href="{{ get_url(path='/', lang=lang, trailing_slash=(lang == config.default_language)) }}">{{ config.title }}</a> + </div> + + {%- if config.extra.menu %} + <div class="nav-navs"> + <ul> + {%- if config.extra.menu %} + {% for menu in config.extra.menu %} + <li> + {% set trailing_slash = menu.trailing_slash | default(value=true) %} + {%- if menu.url is starting_with("http") -%} + {%- if trailing_slash -%} + <a class="nav-links no-hover-padding" href="{{ menu.url }}/"> + {%- else -%} + <a class="nav-links no-hover-padding" href="{{ menu.url }}"> + {%- endif -%} + {%- else -%} + <a class="nav-links no-hover-padding" href="{{ get_url(path=menu.url, lang=lang, trailing_slash=trailing_slash) }}"> + {%- endif -%} + {{ macros_translate::translate(key=menu.name, default=menu.name, language_strings=language_strings) }} + </a> + </li> + {% endfor %} + {%- endif -%} + + {#- Wrap the icons to keep them all together -#} + <li class="menu-icons-container"> + <ul class="menu-icons-group"> + {# Search #} + {%- if config.build_search_index %} + {%- set search_icon_title = macros_translate::translate(key='search_icon_title', default='Press $SHORTCUT to open search', language_strings=language_strings) -%} + <li class="js menu-icon"> + <div role="button" tabindex="0" id="search-button" class="search-icon interactive-icon" title="{{ search_icon_title }}" aria-label="{{ search_icon_title }}"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"> + <path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/> + </svg> + </div> + </li> + {%- endif %} + + {# Language switcher #} + {# Displayed only if more than one language is available #} + {%- if config.languages | length > 0 %} + {% include "partials/language_switcher.html" %} + {%- endif %} + + {# Theme switcher #} + {%- if config.extra.theme_switcher and config.extra.theme_switcher == true -%} + {%- include "partials/theme_switcher.html" -%} + {%- endif -%} + </ul> + </li> + </ul> + </div> + {% endif %} + </nav> +</header> diff --git a/sysret.org/themes/tabi-lean/templates/partials/paginate.html b/sysret.org/themes/tabi-lean/templates/partials/paginate.html new file mode 100644 index 0000000..6502af7 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/paginate.html @@ -0,0 +1,27 @@ +{% if paginator and paginator.number_pagers > 1 %} + <ul class="pagination"> + {% if paginator.previous %} + <li class="page-item page-prev"> + <a href="{{ paginator.previous }}" class="page-link" aria-label="{{ macros_translate::translate(key="prev", default="Prev", language_strings=language_strings) }}"><span class="arrow">←</span> {{ macros_translate::translate(key="prev", default="Prev", language_strings=language_strings) }}</a> + </li> + {% else %} + <li class="page-item page-prev"> + <span class="page-link disabled" aria-disabled="true" aria-label="{{ macros_translate::translate(key="prev", default="Prev", language_strings=language_strings) }} (disabled)"><span class="arrow">←</span> {{ macros_translate::translate(key="prev", default="Prev", language_strings=language_strings) }}</span> + </li> + {% endif %} + + <li class="page-item page-numbers"> + {{ paginator.current_index }} {{ macros_translate::translate(key="of", default="of", language_strings=language_strings) }} {{ paginator.number_pagers }} + </li> + + {% if paginator.next %} + <li class="page-item page-next"> + <a href="{{ paginator.next }}" class="page-link" aria-label="{{ macros_translate::translate(key="next", default="Next", language_strings=language_strings) }}">{{ macros_translate::translate(key="next", default="Next", language_strings=language_strings) }} <span class="arrow">→</span></a> + </li> + {% else %} + <li class="page-item page-next"> + <span class="page-link disabled" aria-disabled="true" aria-label="{{ macros_translate::translate(key="next", default="Next", language_strings=language_strings) }} (disabled)">{{ macros_translate::translate(key="next", default="Next", language_strings=language_strings) }} <span class="arrow">→</span></span> + </li> + {% endif %} + </ul> +{% endif %} diff --git a/sysret.org/themes/tabi-lean/templates/partials/search_modal.html b/sysret.org/themes/tabi-lean/templates/partials/search_modal.html new file mode 100644 index 0000000..a3702d2 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/search_modal.html @@ -0,0 +1,31 @@ +<div id="searchModal" class="search-modal js" role="dialog" aria-labelledby="modalTitle"> + <h1 id="modalTitle" class="visually-hidden">{{ macros_translate::translate(key='search', default='Search', language_strings=language_strings) }}</h1> + <div id="modal-content"> + <div id="searchBar"> + <div class="search-icon" aria-hidden="true"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"> + <path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z"/> + </svg> + </div> + <input id="searchInput" role="combobox" autocomplete="off" spellcheck="false" aria-expanded="false" aria-controls="results-container" placeholder="{{ macros_translate::translate(key='search', default='Search', language_strings=language_strings) }}…"/> + <div id="clear-search" class="close-icon interactive-icon" tabindex="0" role="button" title="{{ macros_translate::translate(key='clear_search', default='Clear search', language_strings=language_strings) }}"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"> + <path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/> + </svg> + </div> + </div> + <div id="results-container"> + <div id="results-info"> + {#- Add the strings here so JavaScript can grab them -#} + {#- These are used in all languages -#} + <span id="zero_results"> {{ macros_translate::translate(key='results', number=0, default='No results', language_strings=language_strings, replace=false) }}</span> + <span id="one_results"> {{ macros_translate::translate(key='results', number=1, default='1 result', language_strings=language_strings, replace=false) }}</span> + <span id="many_results"> {{ macros_translate::translate(key='results', number=11, default='$NUMBER results', language_strings=language_strings, replace=false) }}</span> + {#- Strings for specific languages -#} + <span id="two_results"> {{ macros_translate::translate(key='results', number=2, default='$NUMBER results', language_strings=language_strings, replace=false) }}</span> + <span id="few_results"> {{ macros_translate::translate(key='results', number=2, default='$NUMBER results', language_strings=language_strings, replace=false) }}</span> + </div> + <div id="results" role="listbox"></div> + </div> + </div> +</div> diff --git a/sysret.org/themes/tabi-lean/templates/partials/social_media_images.html b/sysret.org/themes/tabi-lean/templates/partials/social_media_images.html new file mode 100644 index 0000000..d6bbcc7 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/social_media_images.html @@ -0,0 +1,50 @@ +{%- set social_media_card = macros_settings::evaluate_setting_priority(setting="social_media_card", page=page | default(value=""), section=section | default(value=""), default_global_value="") -%} +{% if social_media_card %} + {# Get base path from page/section #} + {% set base_path = "" %} + {% if section and section.path %} + {% set base_path = section.path | trim_end_matches(pat="/_index.md") %} + {% if base_path and not social_media_card is starting_with("/") %} + {% set base_path = base_path ~ "/" %} + {% endif %} + {% else %} + {% set base_path = page.colocated_path | default(value="") %} + {% endif %} + + {% set current_path = base_path ~ social_media_card | trim_start_matches(pat="/") %} + + {# Try parent path by removing the last directory component #} + {% set parent_path = base_path | split(pat="/") | slice(end=-2) | join(sep="/") %} + {% if parent_path and not social_media_card is starting_with("/") %} + {% set parent_path = parent_path ~ "/" %} + {% endif %} + {% set parent_relative_path = parent_path ~ social_media_card | trim_start_matches(pat="/") %} + + {# Check all possible locations #} + {%- set current_meta = get_image_metadata(path=current_path, allow_missing=true) -%} + {%- set parent_meta = get_image_metadata(path=parent_relative_path, allow_missing=true) -%} + {%- set absolute_meta = get_image_metadata(path=social_media_card, allow_missing=true) -%} + + {% if current_meta %} + {% set final_path = current_path %} + {% set meta = current_meta %} + {% elif parent_meta %} + {% set final_path = parent_relative_path %} + {% set meta = parent_meta %} + {% elif absolute_meta %} + {% set final_path = social_media_card %} + {% set meta = absolute_meta %} + {% else %} + {{ throw(message="Could not find social media card image. Tried: + 1. Current page path: '" ~ current_path ~ "' + 2. Parent page path: '" ~ parent_relative_path ~ "' + 3. Absolute path: '" ~ social_media_card ~ "' + Please ensure the file exists at one of these locations.") }} + {% endif %} + + <meta property="og:image" content="{{ get_url(path=final_path, cachebust=true) }}" /> + <meta property="og:image:width" content="{{ meta.width }}" /> + <meta property="og:image:height" content="{{ meta.height }}" /> + <meta name="twitter:image" content="{{ get_url(path=final_path, cachebust=true) }}" /> + <meta name="twitter:card" content="summary_large_image" /> +{% endif %} diff --git a/sysret.org/themes/tabi-lean/templates/partials/theme_switcher.html b/sysret.org/themes/tabi-lean/templates/partials/theme_switcher.html new file mode 100644 index 0000000..2e30f90 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/theme_switcher.html @@ -0,0 +1,31 @@ +<li class="theme-switcher-wrapper js"> + {#- Create the localised strings for the title and aria-label attributes -#} + {%- set toggle_str = macros_translate::translate(key='toggle_mode', default='Toggle $MODE mode', language_strings=language_strings) -%} + {%- set dark_str = macros_translate::translate(key='dark', default='dark', language_strings=language_strings) -%} + {%- set light_str = macros_translate::translate(key='light', default='light', language_strings=language_strings) -%} + + {%- set combined_mode_str = dark_str ~ "/" ~ light_str -%} + {%- set title_label = toggle_str | replace(from="$MODE", to=combined_mode_str) -%} + {%- set aria_label = toggle_str | replace(from="$MODE", to=dark_str) -%} + + <div + title="{{ title_label }}" + class="theme-switcher" + tabindex="0" + role="button" + aria-label="{{ aria_label }}" + aria-pressed="false"> + </div> + + {%- set reset_str = macros_translate::translate(key='reset_mode', default='Reset mode to default', language_strings=language_strings) -%} + + <div + title="{{ reset_str }}" + class="theme-resetter arrow" + tabindex="0" + role="button" + aria-hidden="true" + aria-label="{{ reset_str }}"> + </div> + +</li> diff --git a/sysret.org/themes/tabi-lean/templates/partials/title.html b/sysret.org/themes/tabi-lean/templates/partials/title.html new file mode 100644 index 0000000..de77d73 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/title.html @@ -0,0 +1,40 @@ +{#- Setup -#} +{% if not config.title %} +{{ throw(message="ERROR: No `title` set in `config.toml`. tabi requires a title to function.") }} +{% endif %} +{%- set prefix = config.title | safe -%} +{%- set custom_separator = config.extra.separator | default(value="•") -%} +{%- set separator = " " ~ custom_separator ~ " " -%} + +{#- Get the base path for the current language -#} +{%- if lang != config.default_language %} + {%- set base_path = "/" ~ lang ~ "/" %} +{%- else -%} + {%- set base_path = "/" %} +{%- endif %} + +{%- if current_path and current_path == base_path -%} + {%- set suffix = "" -%} + {%- set separator = "" -%} +{% elif title %} + {%- set suffix = title -%} +{% elif section.title -%} + {%- set suffix = section.title -%} +{% elif page.title %} + {%- set suffix = page.title -%} +{% elif term.name %} + {#- Individual tags -#} + {%- set suffix = term.name -%} +{% elif taxonomy.name %} + {#- List of tags -#} + {%- set suffix = macros_translate::translate(key=taxonomy.name, language_strings=language_strings) | capitalize -%} +{% else %} + {%- set suffix = "404" %} +{%- endif -%} + +{#- Return the final concatenated string -#} +{%- if config.extra.invert_title_order -%} + {{- suffix ~ separator ~ prefix -}} +{%- else -%} + {{- prefix ~ separator ~ suffix -}} +{%- endif -%} diff --git a/sysret.org/themes/tabi-lean/templates/partials/webmentions.html b/sysret.org/themes/tabi-lean/templates/partials/webmentions.html new file mode 100644 index 0000000..e579a04 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/partials/webmentions.html @@ -0,0 +1,51 @@ +{# Incorporate webmention.io links and script into the page head. +1. Provide the link to the webmention data in the at webmention.io. +2. Link to the stylesheet for styling webmentions on a page. +3. Add and configure the javascript to fetch and display the webmentions collected at webmention.io. #} + +<link rel="webmention" href="https://webmention.io/{{ config.extra.webmentions.domain }}/webmention" /> + +{# Calculate the configured data for the script, if any #} + +{% set script_data = "" %} + +{% if config.extra.webmentions.id %} +{% set script_data = script_data ~ "data-id=" ~ config.extra.webmentions.id %} +{% endif %} + +{% if config.extra.webmentions.page_url %} +{% set script_data = script_data ~ " data-page-url=" ~ config.extra.webmentions.page_url %} +{% endif %} + +{% if config.extra.webmentions.add_urls %} +{% set script_data = script_data ~ "data-add-urls=" ~ config.extra.webmentions.add_urls %} +{% endif %} + +{% if config.extra.webmentions.wordcount %} +{% set script_data = script_data ~ " data-wordcount=" ~ config.extra.webmentions.wordcount %} +{% endif %} + +{% if config.extra.webmentions.max_webmentions %} +{% set script_data = script_data ~ "data-max-webmentions=" ~ config.extra.webmentions.max_webmentions %} +{% endif %} + +{% if config.extra.webmentions.prevent_spoofing %} +{% set script_data = script_data ~ "data-prevent-spoofing=" ~ config.extra.webmentions.prevent_spoofing %} +{% endif %} + +{% if config.extra.webmentions.sort_by %} +{% set script_data = script_data ~ "data-sort-by=" ~ config.extra.webmentions.sort_by %} +{% endif %} + +{% if config.extra.webmentions.sort_dir %} +{% set script_data = script_data ~ "data-sort-dir=" ~ config.extra.webmentions.sort_dir %} +{% endif %} + +{% if config.extra.webmentions.comments_are_reactions %} +{% set script_data = script_data ~ " data-comments-are-reactions=" ~ config.extra.webmentions.comments_are_reactions %} +{% endif %} + +<script async src="{{ get_url(path='js/webmention.min.js', trailing_slash=false, cachebust=true) | safe }}" {{ script_data }}> +</script> + +<div class="webmentions-container" id="webmentions"></div> diff --git a/sysret.org/themes/tabi-lean/templates/section.html b/sysret.org/themes/tabi-lean/templates/section.html new file mode 100644 index 0000000..3f2af39 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/section.html @@ -0,0 +1,57 @@ +{% extends "base.html" %} + +{% block main_content %} + +{# We'll only pin posts in the root section. #} +{# Right now both the main page and blog/ use the same `section.html` template. #} +{# To avoid using different templates, we do this. #} +{%- if lang == config.default_language -%} + {%- set expected_root = "/" -%} +{%- else -%} + {%- set expected_root = "/" ~ lang ~ "/" -%} +{%- endif -%} +{%- set is_root_section = current_path == expected_root -%} + +{%- set show_projects_first = section.extra.show_projects_first | default(value=false) -%} +{%- if show_projects_first -%} + {%- set first_section = "projects" -%} +{%- else -%} + {%- set first_section = "posts" -%} +{%- endif -%} + +{%- if section.extra.section_path or paginator and projects_path -%} + {%- set more_than_one_section_shown = true -%} +{%- endif -%} + +<main {% if more_than_one_section_shown %}class="{{ first_section }}-first"{% endif %}> +{%- if config.extra.hcard %} + {%- include "partials/hcard.html" -%} +{% endif -%} +{%- if section.extra.header %} + {%- include "partials/home_banner.html" -%} +{%- elif section.content -%} +<section> + {{ section.content | safe }} +</section> +{% endif -%} + +{% if section.extra.section_path -%} + {% set extra_section = get_section(path=section.extra.section_path) %} +{% endif -%} + +{% if section.extra.section_path -%} + {% set path = section.extra.section_path | replace(from="/_index.md", to = "") %} +{% else -%} + {% set path = section.path %} +{% endif -%} + +{%- if show_projects_first -%} + {%- include "partials/main_page_projects_list.html" -%} + {%- include "partials/main_page_posts_list.html" -%} +{%- else -%} + {%- include "partials/main_page_posts_list.html" -%} + {%- include "partials/main_page_projects_list.html" -%} +{%- endif -%} +</main> + +{% endblock main_content %} diff --git a/sysret.org/themes/tabi-lean/templates/series.html b/sysret.org/themes/tabi-lean/templates/series.html new file mode 100644 index 0000000..5a4cc0c --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/series.html @@ -0,0 +1,62 @@ +{% extends "base.html" %} + +{% block main_content %} + +{# Throw an error if the section is not flagged as a series. #} +{# This page would be displayed properly but it would become impossible for the series' child pages to reference their series. #} +{%- if "series" not in section.extra or not section.extra.series -%} + {{ throw(message="Section is not flagged as a series. Set `section.extra.series` to `true` if you want to use `series.html` template.") }} +{%- endif -%} + +<main> +{%- if section.extra.header %} + {%- include "partials/home_banner.html" -%} +{% endif -%} + + {%- set show_jump = false -%} + {%- set show_jump_hierarchy = macros_settings::evaluate_setting_priority(setting="show_jump_to_posts", page=section) -%} + {%- if show_jump_hierarchy == "true" -%} + {%- set show_jump = true -%} + {%- elif show_jump_hierarchy != "false" -%} + {#- Default to true if the content is long and var is unset #} + {%- if section.content | length > 2000 -%} + {%- set show_jump = true -%} + {%- endif -%} + {%- endif -%} + + {%- if show_jump -%} + <div class="title-with-jump bottom-divider"> + <h1 class="title-container section-title">{{ section.title }}</h1> + <a href="#posts-list" class="jump-link">{{ macros_translate::translate(key="jump_to_posts", default="Jump to posts", language_strings=language_strings) }} ↓</a> + </div> + {%- else -%} + {{ macros_page_header::page_header(title=section.title) }} + {%- endif -%} + + <section class="body"> + {{ section.content | safe }} + </section> + + <div id="posts-list"> + <h2 class="bottom-divider"> + {{ macros_translate::translate(key="all_posts", default="All posts", language_strings=language_strings) }} + </h2> + {%- if paginator %} + {%- set pages = paginator.pages -%} + {% else %} + {%- set pages = section.pages -%} + {% endif -%} + + {% set max_posts = section.extra.max_posts | default(value=999999) %} + {{ macros_list_posts::list_posts(posts=pages, max=max_posts, metadata="indexes", language_strings=language_strings, section_path=section.path, paginator=paginator | default(value="")) }} + </div> + + {% if paginator %} + {%- include "partials/paginate.html" -%} + {% endif %} + +</main> + +{%- include "partials/extra_features.html" -%} + +{% endblock main_content %} diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/add_src_to_code_block.html b/sysret.org/themes/tabi-lean/templates/shortcodes/add_src_to_code_block.html new file mode 100644 index 0000000..907e092 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/add_src_to_code_block.html @@ -0,0 +1 @@ +<span class="code-source hidden" data-source="{{ src | safe }}"></span> diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/admonition.html b/sysret.org/themes/tabi-lean/templates/shortcodes/admonition.html new file mode 100644 index 0000000..3519527 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/admonition.html @@ -0,0 +1,12 @@ +{%- set type = type | default(value="info") -%} +{%- set title = title | default(value=type | upper) -%} +{%- set icon = icon | default(value=type) -%} +{%- set text = text | default(value=body) -%} + +<div class="admonition {{ type }}"> + <div class="admonition-icon admonition-icon-{{ icon }}"></div> + <div class="admonition-content"> + <strong class="admonition-title">{{ title | safe }}</strong> + {{ text | markdown | safe }} + </div> +</div> diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/aside.html b/sysret.org/themes/tabi-lean/templates/shortcodes/aside.html new file mode 100644 index 0000000..ca337f9 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/aside.html @@ -0,0 +1,5 @@ +{%- set text = text | default(value=body) -%} + +<aside {% if position %}data-position="{{ position }}"{% endif %}> + {{ text | markdown | safe }} +</aside> diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/dimmable_image.html b/sysret.org/themes/tabi-lean/templates/shortcodes/dimmable_image.html new file mode 100644 index 0000000..a72720c --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/dimmable_image.html @@ -0,0 +1,31 @@ +{#- Determine image path based on whether the src is remote or local -#} +{%- if src is starting_with("http") or raw_path -%} + {%- set image_url = src -%} +{%- else -%} + {%- set colocated_path = page.colocated_path | default(value="") -%} + {%- set relative_path = colocated_path ~ src -%} + {%- set meta = get_image_metadata(path=relative_path, allow_missing=true) -%} + + {#- Fallback to absolute path if relative path doesn't work -#} + {%- if not meta -%} + {%- set meta = get_image_metadata(path=src, allow_missing=true) -%} + {%- set image_url = get_url(path=src, cachebust=true) -%} + {%- else -%} + {%- set image_url = get_url(path=relative_path, cachebust=true) -%} + {%- endif -%} +{%- endif -%} + +{%- set lazy_loading = lazy_loading | default(value=true) -%} + +{%- set class_list = "dimmable-image" -%} +{%- if inline -%} + {%- set class_list = class_list ~ " inline" -%} +{%- endif -%} + +{%- if full_width -%} + <div class="full-width"> +{%- endif -%} +<img class="{{ class_list }}" src="{{ image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}{% if meta.width %} width="{{ meta.width }}"{% endif %}{% if meta.height %} height="{{ meta.height }}" {% endif %}/> +{%- if full_width -%} + </div> +{%- endif -%} diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/dual_theme_image.html b/sysret.org/themes/tabi-lean/templates/shortcodes/dual_theme_image.html new file mode 100644 index 0000000..5eadc09 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/dual_theme_image.html @@ -0,0 +1,45 @@ +{%- set colocated_path = page.colocated_path | default(value="") -%} +{%- set lazy_loading = lazy_loading | default(value=true) -%} +{%- set inline = inline | default(value=false) -%} + +{%- set light_class_list = "img-light" -%} +{%- set dark_class_list = "img-dark" -%} +{%- if inline -%} + {%- set light_class_list = light_class_list ~ " inline" -%} + {%- set dark_class_list = dark_class_list ~ " inline" -%} +{%- endif -%} + +{# Handling for light mode image #} +{%- if light_src is starting_with("http") or raw_path -%} + {%- set light_image_url = light_src -%} +{%- else -%} + {%- set relative_light_path = colocated_path ~ light_src -%} + {%- set light_meta = get_image_metadata(path=relative_light_path, allow_missing=true) -%} + {%- if not light_meta -%} + {%- set light_image_url = get_url(path=light_src, cachebust=true) -%} + {%- else -%} + {%- set light_image_url = get_url(path=relative_light_path, cachebust=true) -%} + {%- endif -%} +{%- endif -%} + +{# Handling for dark mode image #} +{%- if dark_src is starting_with("http") or raw_path -%} + {%- set dark_image_url = dark_src -%} +{%- else -%} + {%- set relative_dark_path = colocated_path ~ dark_src -%} + {%- set dark_meta = get_image_metadata(path=relative_dark_path, allow_missing=true) -%} + {%- if not dark_meta -%} + {%- set dark_image_url = get_url(path=dark_src, cachebust=true) -%} + {%- else -%} + {%- set dark_image_url = get_url(path=relative_dark_path, cachebust=true) -%} + {%- endif -%} +{%- endif -%} + +{%- if full_width -%} + <div class="full-width"> +{%- endif -%} +<img class="{{ light_class_list }}" src="{{ light_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}{% if light_meta.width %} width="{{ light_meta.width }}"{% endif %}{% if light_meta.height %} height="{{ light_meta.height }}" {% endif %}> +<img class="{{ dark_class_list }}" src="{{ dark_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}{% if dark_meta.width %} width="{{ dark_meta.width }}"{% endif %}{% if dark_meta.height %} height="{{ dark_meta.height }}" {% endif %}> +{%- if full_width -%} + </div> +{%- endif -%} diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/force_text_direction.html b/sysret.org/themes/tabi-lean/templates/shortcodes/force_text_direction.html new file mode 100644 index 0000000..79d9697 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/force_text_direction.html @@ -0,0 +1,5 @@ +{%- set direction = direction | default(value="ltr") -%} + +<div data-force-text-direction="{{ direction }}"> + {{ body | markdown | safe }} +</div> diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/full_width_image.html b/sysret.org/themes/tabi-lean/templates/shortcodes/full_width_image.html new file mode 100644 index 0000000..a50bf10 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/full_width_image.html @@ -0,0 +1,22 @@ +{#- Set paths based on whether the src is remote or local -#} +{%- if src is starting_with("http") or raw_path -%} + {%- set image_url = src -%} +{%- else -%} + {%- set colocated_path = page.colocated_path | default(value="") -%} + {%- set relative_path = colocated_path ~ src -%} + {%- set meta = get_image_metadata(path=relative_path, allow_missing=true) -%} + + {#- Fallback to absolute path if relative path doesn't work -#} + {%- if not meta -%} + {%- set meta = get_image_metadata(path=src, allow_missing=true) -%} + {%- set image_url = get_url(path=src, cachebust=true) -%} + {%- else %} + {%- set image_url = get_url(path=relative_path, cachebust=true) -%} + {%- endif -%} +{%- endif -%} + +{%- set lazy_loading = lazy_loading | default(value=true) -%} + +<div class="full-width"> + <img src="{{ image_url }}"{% if alt %} alt="{{ alt }}"{% endif %}{% if meta.width %} width="{{ meta.width }}"{% endif %}{% if meta.height %} height="{{ meta.height }}"{% endif %}{% if lazy_loading %} loading="lazy"{% endif %}/> +</div> diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/iine.html b/sysret.org/themes/tabi-lean/templates/shortcodes/iine.html new file mode 100644 index 0000000..d37211d --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/iine.html @@ -0,0 +1,5 @@ +{% set button_icon = icon | default(value="heart") %} +{% set label = label | default(value="Like this post") %} +{% set slug = slug | default(value=page.path) %} + +{% include "partials/iine_button.html" %} diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/image_hover.html b/sysret.org/themes/tabi-lean/templates/shortcodes/image_hover.html new file mode 100644 index 0000000..443329b --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/image_hover.html @@ -0,0 +1,50 @@ +{%- set colocated_path = page.colocated_path | default(value="") -%} +{%- set lazy_loading = lazy_loading | default(value=true) -%} +{%- set inline = inline | default(value=false) -%} + +{#- Determine the tag for container elements -#} +{#- Necessary for inline images -#} +{%- set tag = "div" -%} +{%- if inline -%} + {%- set tag = "span" -%} +{%- endif -%} + +{%- set img_class_list = "" -%} +{%- if inline -%} + {%- set img_class_list = img_class_list ~ " inline" -%} +{%- endif -%} + +{#- Direct or relative URL handling for default image -#} +{%- if default_src is starting_with("http") or raw_path -%} + {%- set default_image_url = default_src -%} +{%- else -%} + {%- set relative_default_path = colocated_path ~ default_src -%} + {%- set default_meta = get_image_metadata(path=relative_default_path, allow_missing=true) -%} + {%- if not default_meta -%} + {%- set default_image_url = get_url(path=default_src, cachebust=true) -%} + {%- else -%} + {%- set default_image_url = get_url(path=relative_default_path, cachebust=true) -%} + {%- endif -%} +{%- endif -%} + +{#- Direct or relative URL handling for hovered image -#} +{%- if hovered_src is starting_with("http") or raw_path -%} + {%- set hovered_image_url = hovered_src -%} +{%- else -%} + {%- set relative_hovered_path = colocated_path ~ hovered_src -%} + {%- set hovered_meta = get_image_metadata(path=relative_hovered_path, allow_missing=true) -%} + {%- if not hovered_meta -%} + {%- set hovered_image_url = get_url(path=hovered_src, cachebust=true) -%} + {%- else -%} + {%- set hovered_image_url = get_url(path=relative_hovered_path, cachebust=true) -%} + {%- endif -%} +{%- endif -%} + +<{{ tag }} class="image-hover-container{% if full_width %} full-width{% endif %}"> + <{{ tag }} class="image-default"> + <img class="{{ img_class_list }}" src="{{ default_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if default_alt %} alt="{{ default_alt }}"{% endif %}{% if default_meta.width %} width="{{ default_meta.width }}"{% endif %}{% if default_meta.height %} height="{{ default_meta.height }}"{% endif %}> + </{{ tag }}> + <{{ tag }} class="image-hovered"> + <img class="{{ img_class_list }}" src="{{ hovered_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if hovered_alt %} alt="{{ hovered_alt }}"{% endif %}{% if hovered_meta.width %} width="{{ hovered_meta.width }}"{% endif %}{% if hovered_meta.height %} height="{{ hovered_meta.height }}"{% endif %}> + </{{ tag }}> +</{{ tag }}> diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/image_toggler.html b/sysret.org/themes/tabi-lean/templates/shortcodes/image_toggler.html new file mode 100644 index 0000000..991d5f5 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/image_toggler.html @@ -0,0 +1,57 @@ +{# The `random_id` ensures that each instance of the shortcode has a "unique" id #} +{# allowing individual interactive elements (like toggles) to function correctly. #} +{# This avoids conflicts when multiple instances of the shortcode are used. #} +{%- set random_id = get_random(end=100000) -%} +{%- set colocated_path = page.colocated_path | default(value="") -%} +{%- set lazy_loading = lazy_loading | default(value=true) -%} +{%- set inline = inline | default(value=false) -%} + +{#- Determine the class for the images -#} +{#- Necessary for inline images -#} +{%- set tag = "div" -%} +{%- if inline -%} + {%- set tag = "span" -%} +{%- endif -%} + +{%- set img_class_list = "" -%} +{%- if inline -%} + {%- set img_class_list = img_class_list ~ " inline" -%} +{%- endif -%} + +{# Direct or relative URL handling for default image #} +{%- if default_src is starting_with("http") or raw_path -%} + {%- set default_image_url = default_src -%} +{%- else -%} + {%- set relative_default_path = colocated_path ~ default_src -%} + {%- set default_meta = get_image_metadata(path=relative_default_path, allow_missing=true) -%} + {%- if not default_meta -%} + {%- set default_image_url = get_url(path=default_src, cachebust=true) -%} + {%- else -%} + {%- set default_image_url = get_url(path=relative_default_path, cachebust=true) -%} + {%- endif -%} +{%- endif -%} + +{# Direct or relative URL handling for toggled image #} +{%- if toggled_src is starting_with("http") or raw_path -%} + {%- set toggled_image_url = toggled_src -%} +{%- else -%} + {%- set relative_toggled_path = colocated_path ~ toggled_src -%} + {%- set toggled_meta = get_image_metadata(path=relative_toggled_path, allow_missing=true) -%} + {%- if not toggled_meta -%} + {%- set toggled_image_url = get_url(path=toggled_src, cachebust=true) -%} + {%- else -%} + {%- set toggled_image_url = get_url(path=relative_toggled_path, cachebust=true) -%} + {%- endif -%} +{%- endif -%} + +<{{ tag }} class="image-toggler-container {% if full_width %}full-width{% endif %}"> + <input type="checkbox" id="toggle-img-{{ random_id }}" class="image-toggler-toggle"> + <label for="toggle-img-{{ random_id }}" class="image-label"> + <{{ tag }} class="image-default"> + <img class="{{ img_class_list }}" src="{{ default_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if default_alt %} alt="{{ default_alt }}"{% endif %}{% if default_meta.width %} width="{{ default_meta.width }}"{% endif %}{% if default_meta.height %} height="{{ default_meta.height }}"{% endif %}> + </{{ tag }}> + <{{ tag }} class="image-toggled"> + <img class="{{ img_class_list }}" src="{{ toggled_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if toggled_alt %} alt="{{ toggled_alt }}"{% endif %}{% if toggled_meta.width %} width="{{ toggled_meta.width }}"{% endif %}{% if toggled_meta.height %} height="{{ toggled_meta.height }}"{% endif %}> + </{{ tag }}> + </label> +</{{ tag }}> diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/invertible_image.html b/sysret.org/themes/tabi-lean/templates/shortcodes/invertible_image.html new file mode 100644 index 0000000..0e3c920 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/invertible_image.html @@ -0,0 +1,32 @@ +{#- Determine if src is a remote URL or a local path -#} +{%- if src is starting_with("http") or raw_path -%} + {%- set image_url = src -%} +{%- else -%} + {%- set colocated_path = page.colocated_path | default(value="") -%} + {%- set relative_path = colocated_path ~ src -%} + {%- set meta = get_image_metadata(path=relative_path, allow_missing=true) -%} + + {#- Fallback to absolute path if relative path doesn't work -#} + {%- if not meta -%} + {%- set meta = get_image_metadata(path=src, allow_missing=true) -%} + {%- set image_url = get_url(path=src, cachebust=true) -%} + {%- else %} + {%- set image_url = get_url(path=relative_path, cachebust=true) -%} + {%- endif -%} +{%- endif -%} + +{%- set lazy_loading = lazy_loading | default(value=true) -%} +{%- set inline = inline | default(value=false) -%} + +{%- set class_list = "invertible-image" -%} +{%- if inline -%} + {%- set class_list = class_list ~ " inline" -%} +{%- endif -%} + +{%- if full_width -%} + <div class="full-width"> +{%- endif -%} +<img class="{{ class_list }}" src="{{ image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}{% if meta.width %} width="{{ meta.width }}"{% endif %}{% if meta.height %} height="{{ meta.height }}" {% endif %}/> +{%- if full_width -%} + </div> +{%- endif -%} diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/mermaid.html b/sysret.org/themes/tabi-lean/templates/shortcodes/mermaid.html new file mode 100644 index 0000000..88bbdc4 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/mermaid.html @@ -0,0 +1,8 @@ +{% set invertible = invertible | default(value=true) %} +{% set full_width = full_width | default(value=false) %} +<noscript> + <strong>⚠️ JavaScript is required to render the diagram.</strong> +</noscript> +<pre class="mermaid{% if invertible %} invertible-image{% endif %}{% if full_width %} full-width{% endif %}"> + {{ body | safe }} +</pre> diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/multilingual_quote.html b/sysret.org/themes/tabi-lean/templates/shortcodes/multilingual_quote.html new file mode 100644 index 0000000..7ea9849 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/multilingual_quote.html @@ -0,0 +1,37 @@ +{%- import "macros/translate.html" as macros_translate -%} +{# Load internationalisation data #} +{%- set language_strings = load_data(path="i18n/" ~ lang ~ '.toml', required=false) -%} +{%- if not language_strings -%} + {%- set language_strings = load_data(path="themes/tabi/i18n/" ~ lang ~ ".toml", required=false) -%} +{%- endif -%} + +{%- set open_quote = macros_translate::translate(key="open_quotation_mark", default="“", language_strings=language_strings) -%} +{%- set close_quote = macros_translate::translate(key="close_quotation_mark", default="”", language_strings=language_strings) -%} + +{#- The `random_id` ensures that each instance of the shortcode has a "unique" id -#} +{#- allowing individual interactive elements (like toggles) to function correctly. -#} +{#- This avoids conflicts when multiple instances of the shortcode are used. -#} +{#- More context: https://github.com/welpo/tabi/issues/82 -#} +{%- set random_id = get_random(end=100000) -%} + +<div class="quote-container"> + <input type="checkbox" id="toggle-{{ random_id }}" class="quote-toggle"> + <div class="quote"> + <div class="translated"> + <blockquote> + <p>{{ open_quote ~ translated ~ close_quote }}</p> + <p>{% if author %}— {{ author | safe }}{% endif %} <label for="toggle-{{ random_id }}" class="quote-label quote-label-original"> + ({{- macros_translate::translate(key="show_original_quote", default="Show original quote", language_strings=language_strings) -}}) + </label></p> + </blockquote> + </div> + <div class="original"> + <blockquote> + <p>{{ open_quote ~ original ~ close_quote }}</p> + <p>{% if author %}— {{ author | safe }}{% endif %} <label for="toggle-{{ random_id }}" class="quote-label quote-label-translate"> + ({{- macros_translate::translate(key="show_translation", default="Show translation", language_strings=language_strings) -}}) + </label></p> + </blockquote> + </div> + </div> +</div> diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/references.html b/sysret.org/themes/tabi-lean/templates/shortcodes/references.html new file mode 100644 index 0000000..1894479 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/references.html @@ -0,0 +1,3 @@ +<div class="references"> + {{ body | markdown | safe }} +</div> diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/remote_text.html b/sysret.org/themes/tabi-lean/templates/shortcodes/remote_text.html new file mode 100644 index 0000000..70fd33a --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/remote_text.html @@ -0,0 +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 -%} + {#- 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 -%} + +{%- 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 -}} diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/spoiler.html b/sysret.org/themes/tabi-lean/templates/shortcodes/spoiler.html new file mode 100644 index 0000000..ff9e695 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/spoiler.html @@ -0,0 +1,13 @@ +{# The `random_id` ensures that each instance of the shortcode has a "unique" id #} +{# allowing individual interactive elements (like toggles) to function correctly. #} +{# This avoids conflicts when multiple instances of the shortcode are used. #} +{# More context: https://github.com/welpo/tabi/issues/82 #} +{%- set random_id = get_random(end=100000) -%} +{%- set fixed_blur = fixed_blur | default(value=false) -%} + +<label class="spoiler-container{% if fixed_blur %} fixed-blur{% endif %}"> + <input type="checkbox" id="spoiler-{{random_id}}" class="spoiler-toggle" role="button" aria-pressed="false" /> + <span class="spoiler-content" title="reveal spoiler" tabindex="0"> + <span class="spoiler-hidden">{{ text | markdown | trim_start_matches(pat="<p>") | trim_start_matches(pat="</p>") | safe }}</span> + </span> +</label> diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/toc.html b/sysret.org/themes/tabi-lean/templates/shortcodes/toc.html new file mode 100644 index 0000000..8756586 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/toc.html @@ -0,0 +1,2 @@ +{# Inserts special string to add the Table of Contents anywhere on a post #} +<!-- toc --> diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/wide_container.html b/sysret.org/themes/tabi-lean/templates/shortcodes/wide_container.html new file mode 100644 index 0000000..6268e63 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/shortcodes/wide_container.html @@ -0,0 +1,3 @@ +<div class="full-width"> + {{ body | markdown | safe }} +</div> diff --git a/sysret.org/themes/tabi-lean/templates/sitemap.xml b/sysret.org/themes/tabi-lean/templates/sitemap.xml new file mode 100644 index 0000000..480759f --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/sitemap.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-stylesheet href="{{ get_url(path='/sitemap_style.xsl', trailing_slash=false) | safe }}" type="text/xsl"?> +<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> + {%- for sitemap_entry in entries %} + <url> + <loc>{{ sitemap_entry.permalink | escape_xml | safe }}</loc> + {%- if sitemap_entry.updated %} + <lastmod>{{ sitemap_entry.updated }}</lastmod> + {%- endif %} + </url> + {%- endfor %} +</urlset> diff --git a/sysret.org/themes/tabi-lean/templates/tags/list.html b/sysret.org/themes/tabi-lean/templates/tags/list.html new file mode 100644 index 0000000..7b5e468 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/tags/list.html @@ -0,0 +1,40 @@ +{% extends "index.html" %} + +{% block main_content %} + +{%- set title = macros_translate::translate(key="all_tags", default="All tags", language_strings=language_strings) -%} + +{{ macros_page_header::page_header(title=title)}} + +{% set tag_count = terms | length %} +{% if config.extra.tag_sorting == "frequency" %} + {% set terms = terms | sort(attribute="pages") | reverse %} +{% elif config.extra.tag_sorting != "name" %} + {{ throw (message="Invalid tag_sorting option: " ~ config.extra.tag_sorting ~ ". Valid options are 'name' and 'frequency'.") }} +{% endif %} +<div id="tag-cloud" class="{% if tag_count > 16 %}three-columns{% elif tag_count > 8 %}two-columns{% endif %}"> + <ul class="tags"> + {%- for term in terms -%} + <li class="tags-item"> + {%- set number_of_posts = term.pages | length -%} + {% if config.extra.compact_tags %} + {# Shows the number of posts per tag as a superscript #} + <a href="{{ term.permalink | safe }}" + aria-label="{{ term.name }} – + {{ term.pages | length }} + {{- macros_translate::translate(key="posts", number=number_of_posts, default="$NUMBER posts", language_strings=language_strings) -}} + "> + {{ term.name }} + </a> <sup>{{ number_of_posts }}</sup> + {% else %} + <a href="{{ term.permalink | safe }}"> + {{ term.name }} </a> + <span> – </span> + {{- macros_translate::translate(key="posts", number=number_of_posts, default="$NUMBER posts", language_strings=language_strings) -}} + {% endif %} + </li> + {%- endfor -%} + </ul> +</div> + +{% endblock main_content %} diff --git a/sysret.org/themes/tabi-lean/templates/tags/single.html b/sysret.org/themes/tabi-lean/templates/tags/single.html new file mode 100644 index 0000000..2f25fd2 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/tags/single.html @@ -0,0 +1,22 @@ +{% extends "index.html" %} + +{% block main_content %} + +{#- Feed icon -#} +{%- set generate_feed = feed_utils::get_generate_feed() == "true" -%} +{%- set feed_url = feed_utils::get_feed_url() -%} +{%- set feed_pre_conditions = generate_feed and feed_url and taxonomy.feed -%} +{%- set show_feed_icon = feed_pre_conditions and term.pages | filter(attribute="date") -%} + +{{ macros_page_header::page_header(title=term.name, show_feed_icon=show_feed_icon) }} + +{% set max = section.extra.max_posts | default(value=999999) %} +{{ macros_list_posts::list_posts(posts=term.pages, max=max, language_strings=language_strings) }} + +<ul class="pagination"> + <li class="page-item"> + <a class="all-tags" href="{{ get_url(path="tags", lang=lang) }}/"><span class="arrow">←</span> {{- macros_translate::translate(key="all_tags", default="All tags", language_strings=language_strings) -}}</a> + </li> +</ul> + +{% endblock main_content %} diff --git a/sysret.org/themes/tabi-lean/templates/taxonomy_list.html b/sysret.org/themes/tabi-lean/templates/taxonomy_list.html new file mode 100644 index 0000000..b13e1b9 --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/taxonomy_list.html @@ -0,0 +1,40 @@ +{% extends "index.html" %} + +{% block main_content %} + +{%- set title = macros_translate::translate(key=taxonomy.name, default=taxonomy.name, language_strings=language_strings) -%} + +{{ macros_page_header::page_header(title=title)}} + +{% set tag_count = terms | length %} +{% if config.extra.tag_sorting == "frequency" %} + {% set terms = terms | sort(attribute="pages") | reverse %} +{% elif config.extra.tag_sorting != "name" %} + {{ throw (message="Invalid tag_sorting option: " ~ config.extra.tag_sorting ~ ". Valid options are 'name' and 'frequency'.") }} +{% endif %} +<div id="tag-cloud" class="{% if tag_count > 16 %}three-columns{% elif tag_count > 8 %}two-columns{% endif %}"> + <ul class="tags"> + {%- for term in terms -%} + <li class="tags-item"> + {%- set number_of_posts = term.pages | length -%} + {% if config.extra.compact_tags %} + {# Shows the number of posts per tag as a superscript #} + <a href="{{ term.permalink | safe }}" + aria-label="{{ term.name }} – + {{ term.pages | length }} + {{- macros_translate::translate(key="posts", number=number_of_posts, default="$NUMBER posts", language_strings=language_strings) -}} + "> + {{ term.name }} + </a> <sup>{{ number_of_posts }}</sup> + {% else %} + <a href="{{ term.permalink | safe }}"> + {{ term.name }} </a> + <span> – </span> + {{- macros_translate::translate(key="posts", number=number_of_posts, default="$NUMBER posts", language_strings=language_strings) -}} + {% endif %} + </li> + {%- endfor -%} + </ul> +</div> + +{% endblock main_content %} diff --git a/sysret.org/themes/tabi-lean/templates/taxonomy_single.html b/sysret.org/themes/tabi-lean/templates/taxonomy_single.html new file mode 100644 index 0000000..ff09a3b --- /dev/null +++ b/sysret.org/themes/tabi-lean/templates/taxonomy_single.html @@ -0,0 +1,22 @@ +{% extends "index.html" %} + +{% block main_content %} + +{#- Feed icon -#} +{%- set generate_feed = feed_utils::get_generate_feed() == "true" -%} +{%- set feed_url = feed_utils::get_feed_url() -%} +{%- set feed_pre_conditions = generate_feed and feed_url and taxonomy.feed -%} +{%- set show_feed_icon = feed_pre_conditions and term.pages | filter(attribute="date") | length > 0 -%} + +{{ macros_page_header::page_header(title=term.name, show_feed_icon=show_feed_icon) }} + +{% set max = section.extra.max_posts | default(value=999999) %} +{{ macros_list_posts::list_posts(posts=term.pages, max=max, language_strings=language_strings) }} + +<ul class="pagination"> + <li class="page-item"> + <a class="all-tags" href="{{ get_url(path="tags", lang=lang) }}/"><span class="arrow">←</span> {{- macros_translate::translate(key=taxonomy.name, default=taxonomy.name, language_strings=language_strings) -}}</a> + </li> +</ul> + +{% endblock main_content %} |
