Skip to content

Commit

Permalink
Forgot jinjify.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Jun 16, 2017
1 parent 1bb186b commit 87fa92c
Showing 1 changed file with 25 additions and 10 deletions.
@@ -1,20 +1,35 @@
{# -*- coding: utf-8 -*- #}

{% macro _append_language(language) %}{{ " (" + language + ")" if translations|length > 1 else "" }}{% endmacro %}
{% macro _append_name(name, kind) %}{{ (" (" + name + ")" if name and kind != "archive" and kind != "author" else "") | h }}{% endmacro %}
{% macro _append_name_language_proper(language, kind, name) %}{{ (" (" + name + ", " + language + ")" if name and kind != "archive" and kind != "author" else " (" + language + ")") | h }}{% endmacro %}
{% macro _append_name_language(language, kind, name=None) %}{{ _append_name_language_proper(language, kind, name) if translations|length > 1 else _append_name(name, kind) }}{% endmacro %}

{% macro _head_feed_link(link_type, link_name, link_postfix, classification, kind, language) %}
<link rel="alternate" type="{{ link_type }}" title="{{ link_name|e }}{{ _append_language(language) }}" hreflang="{{ language }}" href="{{ _link(kind + '_' + link_postfix, classification, language) }}">
{% if translations|length > 1 %}
<link rel="alternate" type="{{ link_type }}" title="{{ link_name|e }} ({{ language }})" hreflang="{{ language }}" href="{{ _link(kind + '_' + link_postfix, classification, language) }}">
{% else %}
<link rel="alternate" type="{{ link_type }}" title="{{ link_name|e }}" hreflang="{{ language }}" href="{{ _link(kind + '_' + link_postfix, classification, language) }}">
{% endif %}
{% endmacro %}

{% macro _html_feed_link(link_type, link_name, link_postfix, classification, kind, language, name=None) %}
<a href="{{ _link(kind + '_' + link_postfix, classification, language) }}" hreflang="{{ language }}" type="{{ link_type }}">{{ messages(link_name, language) }} {{ _append_name_language(language, kind, name) }}</a>
{% if translations|length > 1 %}
{% if name and kind != "archive" and kind != "author" %}
<a href="{{ _link(kind + '_' + link_postfix, classification, language) }}" hreflang="{{ language }}" type="{{ link_type }}">{{ messages(link_name, language) }} ({{ name|e }}, {{ language }})</a>
{% else %}
<a href="{{ _link(kind + '_' + link_postfix, classification, language) }}" hreflang="{{ language }}" type="{{ link_type }}">{{ messages(link_name, language) }} ({{ language }})</a>
{% endif %}
{% else %}
{% if name and kind != "archive" and kind != "author" %}
<a href="{{ _link(kind + '_' + link_postfix, classification, language) }}" hreflang="{{ language }}" type="{{ link_type }}">{{ messages(link_name, language) }} ({{ name|e }})</a>
{% else %}
<a href="{{ _link(kind + '_' + link_postfix, classification, language) }}" hreflang="{{ language }}" type="{{ link_type }}">{{ messages(link_name, language) }}</a>
{% endif %}
{% endif %}
{% endmacro %}

{% macro _html_translation_link(classification, kind, language, name=None) %}
<a href="{{ _link(kind, classification, language) }}" hreflang="{{ language }}" rel="alternate">{{ messages("LANGUAGE", language) }}{{ _append_name(name, kind) }}</a>
{% if name and kind != "archive" and kind != "author" %}
<a href="{{ _link(kind, classification, language) }}" hreflang="{{ language }}" rel="alternate">{{ messages("LANGUAGE", language) }} ({{ name|e }})</a>
{% else %}
<a href="{{ _link(kind, classification, language) }}" hreflang="{{ language }}" rel="alternate">{{ messages("LANGUAGE", language) }}</a>
{% endif %}
{% endmacro %}

{% macro _head_rss(classification=None, kind='index', rss_override=True) %}
Expand All @@ -28,7 +43,7 @@
{% endfor %}
{% else %}
{% for language in translations|sort %}
{% if classification and kind != 'index' %}
{% if (classification or classification == '') and kind != 'index' %}
{{ _head_feed_link('application/rss+xml', 'RSS for ' + kind + ' ' + classification, 'rss', classification, kind, language) }}
{% else %}
{{ _head_feed_link('application/rss+xml', 'RSS', 'rss', classification, 'index', language) }}
Expand All @@ -46,7 +61,7 @@
{% endfor %}
{% else %}
{% for language in translations|sort %}
{% if classification and kind != 'index' %}
{% if (classification or classification == '') and kind != 'index' %}
{{ _head_feed_link('application/atom+xml', 'Atom for ' + kind + ' ' + classification, 'atom', classification, kind, language) }}
{% else %}
{{ _head_feed_link('application/atom+xml', 'Atom', 'atom', classification, 'index', language) }}
Expand Down

0 comments on commit 87fa92c

Please sign in to comment.