aboutsummaryrefslogtreecommitdiff
path: root/src/koszko_org_website/templates/__base.html.jinja
diff options
context:
space:
mode:
Diffstat (limited to 'src/koszko_org_website/templates/__base.html.jinja')
-rw-r--r--src/koszko_org_website/templates/__base.html.jinja253
1 files changed, 253 insertions, 0 deletions
diff --git a/src/koszko_org_website/templates/__base.html.jinja b/src/koszko_org_website/templates/__base.html.jinja
new file mode 100644
index 0000000..c05a0a1
--- /dev/null
+++ b/src/koszko_org_website/templates/__base.html.jinja
@@ -0,0 +1,253 @@
+{#
+SPDX-License-Identifier: CC0-1.0
+
+koszko.org website base page template.
+
+Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
+#}
+
+{% macro same_lang_url(page_path) -%}
+ {{ url_for('.show_page_in_' ~ lang_short, page_path=page_path) }}
+{%- endmacro %}
+
+{%
+ set section_ns = namespace(
+ in_section = false,
+ id = none,
+ linked = false,
+ first = true
+ )
+%}
+
+{% macro maybe_link(to, link=true) %}
+ {%- if to is not none and link -%}
+ <a href="{{ to }}">{{ caller() }}</a>
+ {%- else -%}
+ {{ caller() }}
+ {%- endif -%}
+{% endmacro %}
+
+{% macro header(level, text='', link_to_section=true) %}
+ <h{{ level }}{{ header_attrs|default({})|xmlattr }}>
+ {%
+ set should_link = section_ns.in_section and
+ link_to_section and
+ not section_ns.linked and
+ section_ns.id is not none
+ %}
+ {% set section_ns.linked = section_ns.linked or should_link %}
+ {% set caller_markup = caller() if caller is defined else '' %}
+ {% call maybe_link('#' ~ section_ns.id, link=should_link) -%}
+ {{ text }}{{ caller_markup }}
+ {%- endcall %}
+ </h{{ level }}>
+{% endmacro %}
+
+{% macro section(id=none) %}
+ {% set attrs = {} %}
+ {% do attrs.update(section_attrs|default({})) %}
+ {% if section_ns.first %}
+ {% set section_ns.first = false %}
+ {% set classes = attrs.get('class') %}
+ {% set classes = (classes ~ ' ' if classes else '') ~ 'first-section' %}
+ {% do attrs.update({'class': classes}) %}
+ {% endif %}
+ <section{{ attrs|xmlattr }}>
+ {% if id is not none %}
+ <div{{ {'class': 'section-anchor', 'id': id}|xmlattr }}></div>
+ {% endif %}
+ {% if section_ns.in_section %}
+ {{ raise_exception('Section defined inside another section.') }}
+ {% else %}
+ {% set section_ns.in_section = true %}
+ {% set section_ns.id = id %}
+ {% set section_ns.linked = false %}
+ {% endif %}
+ {{ caller() }}
+ {% set section_ns.in_section = false %}
+ </section>
+{% endmacro %}
+
+{% macro para(ensure_containing_section=true) %}
+ {% if section_ns.in_section or not ensure_containing_section %}
+ <p>
+ {{ caller() }}
+ </p>
+ {% else %}
+ {% set caller_snapshot = caller %}
+ {% call section() %}
+ <p>
+ {{ caller_snapshot() }}
+ </p>
+ {% endcall %}
+ {% endif %}
+{% endmacro %}
+
+{% macro link(to, text='') -%}
+ <a href="{{ to }}">{{ text }}
+ {%- if caller is defined -%}
+ {{ caller() }}
+ {%- endif -%}
+ </a>
+{%- endmacro %}
+
+{% macro bold(text='') -%}
+ <span class="bold">{{ text }}
+ {%- if caller is defined -%}
+ {{ caller() }}
+ {%- endif -%}
+ </span>
+{%- endmacro %}
+
+{% macro italic(text='') -%}
+ <span class="italic">{{ text }}
+ {%- if caller is defined -%}
+ {{ caller() }}
+ {%- endif -%}
+ </span>
+{%- endmacro %}
+
+{% macro unordered_list() %}
+ <ul>
+ {{ caller() }}
+ </ul>
+{% endmacro %}
+
+{% macro list_entry() %}
+ <li>
+ {{ caller() }}
+ </li>
+{% endmacro %}
+
+{% macro descriptions() %}
+ <dl>
+ {{ caller() }}
+ </dl>
+{% endmacro %}
+
+{% macro desc_term(text='') %}
+ {{ '<div>'|safe }}
+ <dt>{{ text }}
+ {%- if caller is defined -%}
+ {{ caller() }}
+ {%- endif -%}
+ </dt>
+{% endmacro %}
+
+{% macro desc_desc(text='') %}
+ <dd>{{ text }}
+ {%- if caller is defined -%}
+ {{ caller() }}
+ {%- endif -%}
+ </dd>
+ {{ '</div>'|safe }}
+{% endmacro %}
+
+{% macro img(url, alt_text, extra_classes=[]) %}
+ {% set attrs = {'class': (['pure-img'] + extra_classes)|join(' ')} %}
+ {% do attrs.update({'src': url, 'alt': alt_text, 'draggable': false}) %}
+ <img {{ attrs|xmlattr }}>
+{% endmacro %}
+
+{% macro aside(text='') %}
+ <aside>{{ text }}
+ {%- if caller is defined -%}
+ {{ caller() }}
+ {%- endif -%}
+ </aside>
+{% endmacro %}
+
+{% macro sup(text='') -%}
+ <sup>{{ text }}
+ {%- if caller is defined -%}
+ {{ caller() }}
+ {%- endif -%}
+ </sup>
+{%- endmacro %}
+
+{% set numberlinks_ns = namespace(next_num=1, nums={}) %}
+
+{% macro numberlink(link_url) -%}
+ {%- if link_url not in numberlinks_ns.nums -%}
+ {%- do numberlinks_ns.nums.update({link_url: numberlinks_ns.next_num}) -%}
+ {%- set numberlinks_ns.next_num = numberlinks_ns.next_num + 1 -%}
+ {%- endif -%}
+ {%- call sup() -%}
+ {{ link(link_url, '[' ~ numberlinks_ns.nums[link_url] ~ ']') }}
+ {%- endcall -%}
+{%- endmacro %}
+
+{% macro newline() %}
+ <br>
+{% endmacro %}
+
+{% macro nbsp() -%}
+ &nbsp;
+{%- endmacro %}
+
+{% macro unicode(code) -%}
+ &#{{ code }};
+{%- endmacro %}
+
+<!DOCTYPE html>
+<html>
+ <head>
+ {% block head %}
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta http-equiv="Content-Security-Policy" content="script-src 'none'">
+ <title>
+ {% block title %}
+ {% endblock %}
+ </title>
+ {% block external_css %}
+ <link rel="stylesheet" href="/static/normalize.css">
+ <link rel="stylesheet" href="/static/pure-base.css">
+ <link rel="stylesheet" href="/static/pure-tables.css">
+ <link rel="stylesheet" href="/static/pure-menus-core.css">
+ <link rel="stylesheet" href="/static/pure-menus-skin.css">
+ {% endblock %}
+ <style>
+ {% block style %}
+ .bold {
+ font-weight: bold;
+ }
+
+ .italic {
+ font-style: italic;
+ }
+
+ h1 a, h2 a, h1 a:visited, h2 a:visited {
+ text-decoration: none;
+ color: inherit;
+ }
+
+ .section-anchor {
+ position: relative;
+ }
+
+ section > p, section > dl {
+ margin-left: 20px;
+ }
+
+ section > .center_text {
+ margin-left: 0px;
+ }
+
+ .center-text {
+ text-align: center;
+ }
+
+ .pure-menu {
+ user-select: none;
+ }
+ {% endblock %}
+ </style>
+ {% endblock %}
+ </head>
+ <body>
+ {% block body %}
+ Kocham Asię Ɛ>
+ {% endblock %}
+ </body>
+</html>