Skip to content

Commit

Permalink
Code deduplication.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Jun 8, 2017
1 parent f2ad9b3 commit 4b6f57a
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 96 deletions.
14 changes: 2 additions & 12 deletions nikola/data/themes/base-jinja/templates/index.tmpl
Expand Up @@ -3,6 +3,7 @@
{% import 'math_helper.tmpl' as math with context %}
{% import 'comments_helper.tmpl' as comments with context %}
{% import 'pagination_helper.tmpl' as pagination with context %}
{% import 'translation_link_helper.tmpl' as translation_links with context %}
{% extends 'base.tmpl' %}

{% block extra_head %}
Expand All @@ -15,18 +16,7 @@

{% block content %}
{% block content_header %}
{% if has_other_languages and other_languages %}
<div class="translationslist translations">
<h3 class="translationslist-intro">{{ messages("Also available in:") }}</h3>
{% for language, classification, name in other_languages %}
<p><a href="{{ _link(kind, classification, language) }}" rel="alternate">{{ messages("LANGUAGE", language) }}
{% if kind != 'archive' %}
({{ name|e }})
{% endif %}
</a></p>
{% endfor %}
</div>
{% endif %}
{{ translation_links.translation_link() }}
{% endblock %}
{% if 'main_index' in pagekind %}
{{ front_index_header }}
Expand Down
14 changes: 2 additions & 12 deletions nikola/data/themes/base-jinja/templates/list.tmpl
@@ -1,25 +1,15 @@
{# -*- coding: utf-8 -*- #}
{% extends 'base.tmpl' %}
{% import 'archive_navigation_helper.tmpl' as archive_nav with context %}
{% import 'translation_link_helper.tmpl' as translation_links with context %}

{% block content %}
<article class="listpage">
<header>
<h1>{{ title|e }}</h1>
</header>
{{ archive_nav.archive_navigation() }}
{% if has_other_languages and other_languages %}
<div class="translationslist translations">
<h3 class="translationslist-intro">{{ messages("Also available in:") }}</h3>
{% for language, classification, name in other_languages %}
<p><a href="{{ _link(kind, classification, language) }}" rel="alternate">{{ messages("LANGUAGE", language) }}
{% if kind != 'archive' %}
({{ name|e }})
{% endif %}
</a></p>
{% endfor %}
</div>
{% endif %}
{{ translation_links.translation_link() }}
{% if items %}
<ul class="postlist">
{% for text, link, count in items %}
Expand Down
14 changes: 2 additions & 12 deletions nikola/data/themes/base-jinja/templates/list_post.tmpl
@@ -1,25 +1,15 @@
{# -*- coding: utf-8 -*- #}
{% extends 'base.tmpl' %}
{% import 'archive_navigation_helper.tmpl' as archive_nav with context %}
{% import 'translation_link_helper.tmpl' as translation_links with context %}

{% block content %}
<article class="listpage">
<header>
<h1>{{ title|e }}</h1>
</header>
{{ archive_nav.archive_navigation() }}
{% if has_other_languages and other_languages %}
<div class="translationslist translations">
<h3 class="translationslist-intro">{{ messages("Also available in:") }}</h3>
{% for language, classification, name in other_languages %}
<p><a href="{{ _link(kind, classification, language) }}" rel="alternate">{{ messages("LANGUAGE", language) }}
{% if kind != 'archive' %}
({{ name|e }})
{% endif %}
</a></p>
{% endfor %}
</div>
{% endif %}
{{ translation_links.translation_link() }}
{% if posts %}
<ul class="postlist">
{% for post in posts %}
Expand Down
13 changes: 1 addition & 12 deletions nikola/data/themes/base-jinja/templates/tag.tmpl
Expand Up @@ -26,18 +26,7 @@
<div class="metadata">
{{ translation_links.link(tag) }}
</div>
{% if has_other_languages and other_languages %}
<div class="translationslist translations">
<h3 class="translationslist-intro">{{ messages("Also available in:") }}</h3>
{% for language, classification, name in other_languages %}
<p><a href="{{ _link(kind, classification, language) }}" rel="alternate">{{ messages("LANGUAGE", language) }}
{% if kind != 'archive' %}
({{ name|e }})
{% endif %}
</a></p>
{% endfor %}
</div>
{% endif %}
{{ translation_links.translation_link() }}
</header>
{% if posts %}
<ul class="postlist">
Expand Down
Expand Up @@ -72,3 +72,18 @@
{% endif %}
{% endif %}
{% endmacro %}

{% macro translation_link() %}
{% if has_other_languages and other_languages %}
<div class="translationslist translations">
<h3 class="translationslist-intro">{{ messages("Also available in:") }}</h3>
{% for language, classification, name in other_languages %}
<p><a href="{{ _link(kind, classification, language) }}" rel="alternate">{{ messages("LANGUAGE", language) }}
{% if kind != 'archive' %}
({{ name|e }})
{% endif %}
</a></p>
{% endfor %}
</div>
{% endif %}
{% endmacro %}
14 changes: 2 additions & 12 deletions nikola/data/themes/base/templates/index.tmpl
Expand Up @@ -3,6 +3,7 @@
<%namespace name="math" file="math_helper.tmpl"/>
<%namespace name="comments" file="comments_helper.tmpl"/>
<%namespace name="pagination" file="pagination_helper.tmpl"/>
<%namespace name="translation_links" file="translation_link_helper.tmpl" import="*"/>
<%inherit file="base.tmpl"/>

<%block name="extra_head">
Expand All @@ -15,18 +16,7 @@

<%block name="content">
<%block name="content_header">
%if has_other_languages and other_languages:
<div class="translationslist translations">
<h3 class="translationslist-intro">${messages("Also available in:")}</h3>
%for language, classification, name in other_languages:
<p><a href="${_link(kind, classification, language)}" rel="alternate">${messages("LANGUAGE", language)}
%if kind != 'archive':
(${name|h})
%endif
</a></p>
%endfor
</div>
%endif
${translation_links.translation_link()}
</%block>
% if 'main_index' in pagekind:
${front_index_header}
Expand Down
14 changes: 2 additions & 12 deletions nikola/data/themes/base/templates/list.tmpl
@@ -1,25 +1,15 @@
## -*- coding: utf-8 -*-
<%inherit file="base.tmpl"/>
<%namespace name="archive_nav" file="archive_navigation_helper.tmpl" import="*"/>
<%namespace name="translation_links" file="translation_link_helper.tmpl" import="*"/>

<%block name="content">
<article class="listpage">
<header>
<h1>${title|h}</h1>
</header>
${archive_nav.archive_navigation()}
%if has_other_languages and other_languages:
<div class="translationslist translations">
<h3 class="translationslist-intro">${messages("Also available in:")}</h3>
%for language, classification, name in other_languages:
<p><a href="${_link(kind, classification, language)}" rel="alternate">${messages("LANGUAGE", language)}
%if kind != 'archive':
(${name|h})
%endif
</a></p>
%endfor
</div>
%endif
${translation_links.translation_link()}
%if items:
<ul class="postlist">
% for text, link, count in items:
Expand Down
14 changes: 2 additions & 12 deletions nikola/data/themes/base/templates/list_post.tmpl
@@ -1,25 +1,15 @@
## -*- coding: utf-8 -*-
<%inherit file="base.tmpl"/>
<%namespace name="archive_nav" file="archive_navigation_helper.tmpl" import="*"/>
<%namespace name="translation_links" file="translation_link_helper.tmpl" import="*"/>

<%block name="content">
<article class="listpage">
<header>
<h1>${title|h}</h1>
</header>
${archive_nav.archive_navigation()}
%if has_other_languages and other_languages:
<div class="translationslist translations">
<h3 class="translationslist-intro">${messages("Also available in:")}</h3>
%for language, classification, name in other_languages:
<p><a href="${_link(kind, classification, language)}" rel="alternate">${messages("LANGUAGE", language)}
%if kind != 'archive':
(${name|h})
%endif
</a></p>
%endfor
</div>
%endif
${translation_links.translation_link()}
%if posts:
<ul class="postlist">
% for post in posts:
Expand Down
13 changes: 1 addition & 12 deletions nikola/data/themes/base/templates/tag.tmpl
Expand Up @@ -26,18 +26,7 @@
<div class="metadata">
${translation_links.link(tag)}
</div>
%if has_other_languages and other_languages:
<div class="translationslist translations">
<h3 class="translationslist-intro">${messages("Also available in:")}</h3>
%for language, classification, name in other_languages:
<p><a href="${_link(kind, classification, language)}" rel="alternate">${messages("LANGUAGE", language)}
%if kind != 'archive':
(${name|h})
%endif
</a></p>
%endfor
</div>
%endif
${translation_links.translation_link()}
</header>
%if posts:
<ul class="postlist">
Expand Down
15 changes: 15 additions & 0 deletions nikola/data/themes/base/templates/translation_link_helper.tmpl
Expand Up @@ -72,3 +72,18 @@
% endif
% endif
</%def>

<%def name="translation_link()">
%if has_other_languages and other_languages:
<div class="translationslist translations">
<h3 class="translationslist-intro">${messages("Also available in:")}</h3>
%for language, classification, name in other_languages:
<p><a href="${_link(kind, classification, language)}" rel="alternate">${messages("LANGUAGE", language)}
%if kind != 'archive':
(${name|h})
%endif
</a></p>
%endfor
</div>
%endif
</%def>

0 comments on commit 4b6f57a

Please sign in to comment.