Skip to content
Permalink
Browse files
Forgot jinjify.
  • Loading branch information
felixfontein committed Jun 16, 2017
1 parent 1bb186b commit 87fa92cf3e06cedb28409f76e347b74b1d40ab5c
Showing with 25 additions and 10 deletions.
  1. +25 −10 nikola/data/themes/base-jinja/templates/feeds_translations_helper.tmpl
@@ -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) %}
@@ -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) }}
@@ -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) }}

0 comments on commit 87fa92c

Please sign in to comment.