Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taxonomy language link left-overs #2844

Merged
merged 19 commits into from Jun 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGES.txt
Expand Up @@ -5,12 +5,13 @@ Features
--------

* Use ``PRETTY_URLS`` by default on all sites (Issue #1838)
* Feed link generation is completely refactored (Issue #2844)

Bugfixes
--------
* Use Jupyter name more consistently in docs
* Support CODE_COLOR_SCHEME in Jupyter notebooks (Issue #2093)

* Language was not passed to title and link generation for page indexes

Removed features
----------------
Expand All @@ -19,6 +20,8 @@ Removed features
* Drop insecure post encryption feature
* Stop supporting all deprecated config options
* Drop annotations support (annotateit.org closed down in March 2017)
* Remove taxonomy option ``also_create_classifications_from_other_languages``
(Issue #2785)

New in v7.8.8
=============
Expand Down
12 changes: 9 additions & 3 deletions nikola/data/themes/base-jinja/templates/archiveindex.tmpl
Expand Up @@ -5,10 +5,16 @@

{% block extra_head %}
{{ super() }}
{{ feeds_translations.head(archive_name) }}
{{ feeds_translations.head(archive_name, kind, rss_override=False) }}
{% endblock %}

{% block content_header %}
{{ archive_nav.archive_navigation() }}
{{ parent.content_header() }}
<header>
<h1>{{ title|e }}</h1>
{{ archive_nav.archive_navigation() }}
<div class="metadata">
{{ feeds_translations.feed_link(archive, kind) }}
{{ feeds_translations.translation_link(kind) }}
</div>
</header>
{% endblock %}
6 changes: 2 additions & 4 deletions nikola/data/themes/base-jinja/templates/author.tmpl
Expand Up @@ -3,11 +3,9 @@
{% import 'feeds_translations_helper.tmpl' as feeds_translations with context %}

{% block extra_head %}
{{ super() }}
{{ feeds_translations.head(author) }}
{{ feeds_translations.head(author, kind, rss_override=False) }}
{% endblock %}


{% block content %}
<article class="authorpage">
<header>
Expand All @@ -16,7 +14,7 @@
<p>{{ description }}</p>
{% endif %}
<div class="metadata">
{{ feeds_translations.feed_link(author) }}
{{ feeds_translations.feed_link(author, kind) }}
</div>
</header>
{% if posts %}
Expand Down
15 changes: 14 additions & 1 deletion nikola/data/themes/base-jinja/templates/authorindex.tmpl
Expand Up @@ -2,7 +2,20 @@
{% extends 'index.tmpl' %}
{% import 'feeds_translations_helper.tmpl' as feeds_translations with context %}

{% block content_header %}
<header>
<h1>{{ title|e }}</h1>
{% if description %}
<p>{{ description }}</p>
{% endif %}
<div class="metadata">
{{ feeds_translations.feed_link(author, kind) }}
{{ feeds_translations.translation_link(kind) }}
</div>
</header>
{% endblock %}

{% block extra_head %}
{{ super() }}
{{ feeds_translations.head(author) }}
{{ feeds_translations.head(author, kind, rss_override=False) }}
{% endblock %}
8 changes: 8 additions & 0 deletions nikola/data/themes/base-jinja/templates/authors.tmpl
@@ -1,10 +1,18 @@
{# -*- coding: utf-8 -*- #}
{% extends 'base.tmpl' %}
{% import 'feeds_translations_helper.tmpl' as feeds_translations with context %}

{% block extra_head %}
{{ feeds_translations.head(kind=kind, feeds=False) }}
{% endblock %}

{% block content %}
<article class="authorindex">
{% if items %}
<h2>{{ messages("Authors") }}</h2>
<div class="metadata">
{{ feeds_translations.translation_link(kind) }}
</div>
<ul class="postlist">
{% for text, link in items %}
{% if text not in hidden_authors %}
Expand Down
4 changes: 2 additions & 2 deletions nikola/data/themes/base-jinja/templates/base_helper.tmpl
Expand Up @@ -42,7 +42,7 @@ lang="{{ lang }}">
{% if meta_generator_tag %}
<meta name="generator" content="Nikola (getnikola.com)">
{% endif %}
{{ feeds_translations.head() }}
{{ feeds_translations.head(classification=None, kind='index', other=False) }}
<link rel="canonical" href="{{ abs_link(permalink) }}">

{% if favicons %}
Expand Down Expand Up @@ -101,7 +101,7 @@ lang="{{ lang }}">

{# This function is deprecated; use feed_helper directly. #}
{% macro html_feedlinks() %}
{{ feeds_translations.head() }}
{{ feeds_translations.head(classification=None, kind='index', other=False) }}
{% endmacro %}

{% macro html_translations() %}
Expand Down
153 changes: 93 additions & 60 deletions nikola/data/themes/base-jinja/templates/feeds_translations_helper.tmpl
@@ -1,90 +1,123 @@
{# -*- coding: utf-8 -*- #}

{# Handles both feeds and translations #}
{% macro head(classification=None) %}
{% if rss_link %}
{{ rss_link }}
{% macro _head_feed_link(link_type, link_name, link_postfix, classification, kind, 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) %}
{% if translations|length > 1 %}
{% for language in translations|sort %}
{% if classification %}
{% if generate_atom %}
<link rel="alternate" type="application/atom+xml" title="Atom for {{ kind }} {{ classification|e }} ({{ language }})" href="{{ _link(kind + "_atom", classification, language) }}">
{% endif %}
{% if generate_rss and not rss_link %}
<link rel="alternate" type="application/rss+xml" title="RSS for {{ kind }} {{ classification|e }} ({{ language }})" href="{{ _link(kind + "_rss", classification, language) }}">
{% endif %}
{% else %}
{% if generate_atom %}
<link rel="alternate" type="application/atom+xml" title="Atom ({{ language }})" href="{{ _link("index_atom", None, language) }}">
{% endif %}
{% if generate_rss and not rss_link %}
<link rel="alternate" type="application/rss+xml" title="RSS ({{ language }})" href="{{ _link("rss", None, language) }}">
{% endif %}
{% endif %}
{% endfor %}
{% 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 classification %}
{% if generate_atom %}
<link rel="alternate" type="application/atom+xml" title="Atom for {{ kind }} {{ classification|e }}" href="{{ _link(kind + "_atom", classification) }}">
{% endif %}
{% if generate_rss and not rss_link %}
<link rel="alternate" type="application/rss+xml" title="RSS for {{ kind }} {{ classification|e }}" href="{{ _link(kind + "_rss", classification) }}">
{% endif %}
{% 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 %}
{% if generate_atom %}
<link rel="alternate" type="application/atom+xml" title="Atom" href="{{ _link("index_atom", None) }}">
{% endif %}
{% if generate_rss and not rss_link %}
<link rel="alternate" type="application/rss+xml" title="RSS" href="{{ _link("rss", None) }}">
{% endif %}
<a href="{{ _link(kind + '_' + link_postfix, classification, language) }}" hreflang="{{ language }}" type="{{ link_type }}">{{ messages(link_name, language) }}</a>
{% endif %}
{% endif %}
{% if has_other_languages and other_languages %}
{% endmacro %}

{% macro _html_translation_link(classification, kind, language, name=None) %}
{% 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) %}
{% if rss_link and rss_override %}
{{ rss_link }}
{% endif %}
{% if generate_rss and not (rss_link and rss_override) and kind != 'archive' %}
{% if translations|length > 1 and has_other_languages and classification and kind != 'index' %}
{% for language, classification, name in all_languages %}
<link rel="alternate" type="application/rss+xml" title="RSS for {{ kind }} {{ name|e }} ({{ language }})" hreflang="{{ language }}" href="{{ _link(kind + "_rss", classification, language) }}">
{% endfor %}
{% else %}
{% for language in translations|sort %}
{% 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) }}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endmacro %}

{% macro _head_atom(classification=None, kind='index') %}
{% if generate_atom %}
{% if translations|length > 1 and has_other_languages and classification and kind != 'index' %}
{% for language, classification, name in all_languages %}
<link rel="alternate" type="application/atom+xml" title="Atom for {{ kind }} {{ name|e }} ({{ language }})" hreflang="{{ language }}" href="{{ _link(kind + "_atom", classification, language) }}">
{% endfor %}
{% else %}
{% for language in translations|sort %}
{% 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) }}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endmacro %}

{# Handles both feeds and translations #}
{% macro head(classification=None, kind='index', feeds=True, other=True, rss_override=True, has_no_feeds=False) %}
{% if feeds and not has_no_feeds %}
{{ _head_rss(classification, 'index' if (kind == 'archive' and rss_override) else kind, rss_override) }}
{{ _head_atom(classification, kind) }}
{% endif %}
{% if other and has_other_languages and other_languages %}
{% for language, classification, _ in other_languages %}
<link rel="alternate" hreflang="{{ language }}" href="{{ _link(kind, classification, language) }}">
{% endfor %}
{% endif %}
{% endmacro %}

{% macro feed_link(classification) %}
{% if translations|length > 1 %}
{% for language in translations|sort %}
{% if generate_atom or generate_rss %}
{% macro feed_link(classification, kind) %}
{% if generate_atom or generate_rss %}
{% if translations|length > 1 and has_other_languages and kind != 'index' %}
{% for language, classification, name in all_languages %}
<p class="feedlink">
{% if generate_atom %}
<a href="{{ _link(kind + "_atom", classification, language) }}" hreflang="{{ language }}" type="application/atom+xml">{{ messages('Atom feed', language) }} ({{ language }})</a>
{{ _html_feed_link('application/atom+xml', 'Atom feed', 'atom', classification, kind, language, name) }}
{% endif %}
{% if generate_rss %}
<a href="{{ _link(kind + "_rss", classification, language) }}" hreflang="{{ language }}" type="application/rss+xml">{{ messages('RSS feed', language) }} ({{ language }})</a>
{% if generate_rss and kind != 'archive' %}
{{ _html_feed_link('application/rss+xml', 'RSS feed', 'rss', classification, kind, language, name) }}
{% endif %}
</p>
{% endif %}
{% endfor %}
{% else %}
{% if generate_atom or generate_rss %}
<p class="feedlink">
{% if generate_atom %}
<a href="{{ _link(kind + "_atom", classification) }}" type="application/atom+xml">{{ messages('Atom feed') }}</a>
{% endif %}
{% if generate_rss %}
<a href="{{ _link(kind + "_rss", classification) }}" type="application/rss+xml">{{ messages('RSS feed') }}</a>
{% endif %}
</p>
{% endfor %}
{% else %}
{% for language in translations|sort %}
<p class="feedlink">
{% if generate_atom %}
{{ _html_feed_link('application/atom+xml', 'Atom feed', 'atom', classification, kind, language) }}
{% endif %}
{% if generate_rss and kind != 'archive' %}
{{ _html_feed_link('application/rss+xml', 'RSS feed', 'rss', classification, kind, language) }}
{% endif %}
</p>
{% endfor %}
{% endif %}
{% endif %}
{% endmacro %}

{% macro translation_link() %}
{% macro translation_link(kind) %}
{% 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>
<p>{{ _html_translation_link(classification, kind, language, name) }}</p>
{% endfor %}
</div>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/base-jinja/templates/index.tmpl
Expand Up @@ -16,7 +16,7 @@

{% block content %}
{% block content_header %}
{{ feeds_translations.translation_link() }}
{{ feeds_translations.translation_link(kind) }}
{% endblock %}
{% if 'main_index' in pagekind %}
{{ front_index_header }}
Expand Down
6 changes: 5 additions & 1 deletion nikola/data/themes/base-jinja/templates/list.tmpl
Expand Up @@ -3,13 +3,17 @@
{% import 'archive_navigation_helper.tmpl' as archive_nav with context %}
{% import 'feeds_translations_helper.tmpl' as feeds_translations with context %}

{% block extra_head %}
{{ feeds_translations.head(kind=kind, rss_override=False, has_no_feeds=has_no_feeds) }}
{% endblock %}

{% block content %}
<article class="listpage">
<header>
<h1>{{ title|e }}</h1>
</header>
{{ archive_nav.archive_navigation() }}
{{ feeds_translations.translation_link() }}
{{ feeds_translations.translation_link(kind) }}
{% if items %}
<ul class="postlist">
{% for text, link, count in items %}
Expand Down
6 changes: 5 additions & 1 deletion nikola/data/themes/base-jinja/templates/list_post.tmpl
Expand Up @@ -3,13 +3,17 @@
{% import 'archive_navigation_helper.tmpl' as archive_nav with context %}
{% import 'feeds_translations_helper.tmpl' as feeds_translations with context %}

{% block extra_head %}
{{ feeds_translations.head(kind=kind, rss_override=False) }}
{% endblock %}

{% block content %}
<article class="listpage">
<header>
<h1>{{ title|e }}</h1>
</header>
{{ archive_nav.archive_navigation() }}
{{ feeds_translations.translation_link() }}
{{ feeds_translations.translation_link(kind) }}
{% if posts %}
<ul class="postlist">
{% for post in posts %}
Expand Down
7 changes: 5 additions & 2 deletions nikola/data/themes/base-jinja/templates/sectionindex.tmpl
Expand Up @@ -4,14 +4,17 @@

{% block extra_head %}
{{ super() }}
{{ feeds_translations.head(section) }}
{{ feeds_translations.head(section, kind, rss_override=False) }}
{% endblock %}

{% block content %}
<div class="sectionindex">
<header>
<h2><a href="{{ _link('section_index', section) }}">{{ title|e }}</a></h2>
{{ feeds_translations.feed_link(section) }}
<div class="metadata">
{{ feeds_translations.feed_link(section, kind) }}
{{ feeds_translations.translation_link(kind) }}
</div>
</header>
{{ super() }}
</div>
Expand Down