Initial version

This commit is contained in:
Fabian Hauser 2024-09-14 18:18:15 +03:00
commit 594b935570
29 changed files with 1992 additions and 0 deletions

0
src/templates/.gitkeep Normal file
View file

19
src/templates/home.html Normal file
View file

@ -0,0 +1,19 @@
{% extends "base.html" %}
{% block main_content %}
<main>
{% if section.extra.section_path -%}
{% set extra_section = get_section(path=section.extra.section_path) %}
{% endif -%}
{%- if section.extra.header %}
{%- include "partials/home_banner.html" -%}
{% endif -%}
</main>
{% if paginator %}
{%- include "partials/paginate.html" -%}
{% endif %}
{% endblock main_content %}

View file

@ -0,0 +1,27 @@
{% 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 -%}
{%- include "partials/journey_pages.html" -%}
</main>
{% if paginator %}
{%- include "partials/paginate.html" -%}
{% endif %}
{% endblock main_content %}

View file

@ -0,0 +1,42 @@
{%- set rel_attributes = macros_rel_attributes::rel_attributes() | trim -%}
<div class="cards">
{%- for page in show_pages %}
<div class="card">
{# Determine which URL to use, default is page.permalink #}
{%- if page.extra.link_to and config.markdown.external_links_target_blank -%}
{%- set blank_target = "target=_blank" -%}
{%- else -%}
{%- set blank_target = "" -%}
{%- endif -%}
{% set target_url = page.extra.link_to | default(value=page.permalink) %}
<a rel="{{ rel_attributes }}" {{ blank_target }} href="{{ target_url }}">
{% 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 %}
</a>
<div class="card-info">
<h2 class="card-title">
<a rel="{{ rel_attributes }}" {{ blank_target }} href="{{ target_url }}">{{ page.title }}</a>
</h2>
{% if journey.description %}
<p>{{ journey.description }}</p>
{% endif %}
<div class="card-description">
{% if page.description %}
{{ page.description }}
{% endif %}
</div>
</div>
</div>
{% endfor -%}
</div>

View file

@ -0,0 +1,54 @@
{# Set locale for date #}
{% set date_locale = macros_translate::translate(key="date_locale", default="en_GB", language_strings=language_strings) %}
<div class="archive">
<ul class="list-with-title">
{# Collect all pages and subsections #}
{% set_global journeys = [] %}
{% for journey_path in show_journeys %}
{% set_global journeys = journeys | concat(with=get_section(path=journey_path)) %}
{% endfor %}
{% for journey_page in show_pages %}
{% set_global journeys = journeys | concat(with=journey_page) %}
{% endfor %}
{% for year, yearly_journeys in journeys | group_by(attribute="extra.year") %}
<li>
<h2 class="listing-title">{{ year }}</h2>
<ul class="listing">
{% for journey in yearly_journeys | sort(attribute="extra.date") | reverse %}
<li class="listing-item">
<div class="post-time">
<span class="date">
{% if journey.extra.date %}
{# This is probably a section #}
{% set date_format = "%b" %}
{% else %}
{% set date_format = "%b %d" %}
{% endif %}
<h3>{{ journey.date | default(value=journey.extra.date) | date(format=date_format, locale=date_locale) }}</h3>
</span>
</div>
<div>
<h3><a href="{{ journey.permalink }}" title="{{ journey.title }}">{{ journey.title }}</a></h3>
{% if journey.description %}
<p>{{ journey.description }}</p>
{% endif %}
{% if journey.extra.local_image %}
{% set processed_image = resize_image(path=journey.extra.local_image, width=2000, op="fit_width", format="webp", quality=95) %}
<a href="{{ journey.permalink }}" title="{{ journey.title }}" style="margin-top: var(--paragraph-spacing);" class="no-hover-padding">
<img alt="{{ journey.title }}" src="{{ processed_image.url }}" style="max-width: 5rem;">
</a>
{% endif %}
</div>
</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</div>

View file

@ -0,0 +1,160 @@
{% extends "base.html" %}
{% block main_content %}
{%- set separator = config.extra.separator | default(value="•") -%}
{%- set rel_attributes = macros_rel_attributes::rel_attributes() | trim -%}
{%- if config.markdown.external_links_target_blank -%}
{%- set blank_target = "target=_blank" -%}
{%- else -%}
{%- set blank_target = "" -%}
{%- endif -%}
{# Debugging #}
{# {% set last_ancestor = page.ancestors | slice(start=-1) %}
{% set current_section = get_section(path=last_ancestor.0) %}
{% set settings_to_test = [
"footnote_backlinks",
"katex",
"quick_navigation_buttons",
"show_reading_time",
"show_remote_changes",
"toc",
] %}
<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> #}
{# {{ __tera_context }} #}
{# End debugging #}
<main>
<article>
{% if page.ancestors | length > 2 %}
<nav id="journey-links" class="navbar">
<div class="nav-navs">
{% set last_ancestor = page.ancestors | slice(start=-2, end=-1) %}
{% set current_section = get_section(path=page.ancestors.2) %}
<ul>
<li>{{ current_section.title }}:</li>
{%- for journey_page in current_section.pages | sort(attribute="date") %}
{% set target_url = journey_page.extra.link_to | default(value=journey_page.permalink) %}
<li><a class="nav-links no-hover-padding" href="{{ target_url }}">
{{journey_page.title}}
</a></li>
{% endfor -%}
</ul>
</div>
</nav>
{% endif %}
<h1 class="article-title">
{{ page.title }}
</h1>
<ul class="meta">
{% if page.draft %}
<li class="draft-label">{{ macros_translate::translate(key="draft", default="DRAFT", language_strings=language_strings) }}</li>
{% endif %}
{% if page.date %}
<li>{{ macros_format_date::format_date(date=page.date, short=true, language_strings=language_strings) }}</li>
{% endif %}
{# page settings override config settings #}
{% if macros_settings::evaluate_setting_priority(setting="show_reading_time", page=page, default_global_value=true) == "true" %}
{{ separator }} <li title="{{ page.word_count }} {{ macros_translate::translate(key="words", default="words", language_strings=language_strings) }}">{{ page.reading_time }}&nbsp;{{ macros_translate::translate(key="min_read", default="min read", language_strings=language_strings) }}</li>
{% endif %}
{%- if page.taxonomies and page.taxonomies.tags -%}
{{ separator }}&nbsp;<li>{{- macros_translate::translate(key="tags", default="tags", language_strings=language_strings) | capitalize -}}:&nbsp;</li>
{%- for tag in page.taxonomies.tags -%}
<li><a href={{ get_taxonomy_url(kind='tags', name=tag, lang=lang) | safe }}>{{ tag }}</a>
{%- if not loop.last -%}
,&nbsp;
{%- endif -%}
</li>
{%- endfor -%}
{%- endif -%}
{% if page.updated %}
</ul><ul class="meta last-updated"><li>{{ macros_translate::translate(key="last_updated_on", default="Last updated on", language_strings=language_strings) }} {{ macros_format_date::format_date(date=page.updated, short=true, language_strings=language_strings) }}</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" %}
{{ separator }}
<li><a href="{% include "partials/history_url.html" %}" {{ blank_target }} rel="{{ rel_attributes }}">{{ macros_translate::translate(key="see_changes", default="See changes", language_strings=language_strings) }}<small></small></a></li>
{% endif %}
{% endif %}
</ul>
{% if page.extra.tldr %}
<div class="tldr">
<h3>TL;DR:</h3>
<p>{{ page.extra.tldr }}</p>
</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 %}
<section class="body">
{# 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.content | replace(from="<!-- toc -->", to=macros_toc::toc(page=page, header=false, language_strings=language_strings)) | safe }}
</section>
{# 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 %}
</article>
</main>
{%- include "partials/extra_features.html" -%}
{% endblock main_content %}

29
src/templates/travel.html Normal file
View file

@ -0,0 +1,29 @@
{% 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_journeys = paginator.subsections -%}
{%- set show_pages = paginator.pages -%}
{% else %}
{%- set show_journeys = section.subsections -%}
{%- set show_pages = section.pages -%}
{% endif -%}
{%- include "partials/travel_listing.html" -%}
</main>
{% if paginator %}
{%- include "partials/paginate.html" -%}
{% endif %}
{% endblock main_content %}