Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix #1008, fix #1573
* Links to languages point to site root and not the blog (Issue #1008)
* Brand link is now language-specific (Issue #1573)

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 17, 2015
1 parent 90b5782 commit aa3f967
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Expand Up @@ -4,9 +4,13 @@ New in master
Features
--------

* Added ``root`` path handler (via Issues #1008, #1573)

Bugfixes
--------

* Links to languages point to site root and not the blog (Issue #1008)
* Brand link is now language-specific (Issue #1573)
* Fixed compatibility with IPython 3.x (Issue #1581)

New in v7.3.0
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/base-jinja/templates/base_header.tmpl
Expand Up @@ -16,7 +16,7 @@
{% endmacro %}

{% macro html_site_title() %}
<h1 id="brand"><a href="{{ abs_link('/') }}" title="{{ blog_title }}" rel="home">
<h1 id="brand"><a href="{{ abs_link(_link("root", None, lang)) }}" title="{{ blog_title }}" rel="home">
{% if logo_url %}
<img src="{{ logo_url }}" alt="{{ blog_title }}" id="logo">
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/base-jinja/templates/base_helper.tmpl
Expand Up @@ -99,7 +99,7 @@ lang="{{ lang }}">
<ul class="translations">
{% for langname in translations.keys() %}
{% if langname != lang %}
<li><a href="{{ _link("index", None, langname) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
<li><a href="{{ abs_link(_link("root", None, langname)) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
{% endif %}
{% endfor %}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/base/templates/base_header.tmpl
Expand Up @@ -16,7 +16,7 @@
</%def>

<%def name="html_site_title()">
<h1 id="brand"><a href="${abs_link('/')}" title="${blog_title}" rel="home">
<h1 id="brand"><a href="${abs_link(_link("root", None, lang))}" title="${blog_title}" rel="home">
%if logo_url:
<img src="${logo_url}" alt="${blog_title}" id="logo">
%endif
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/base/templates/base_helper.tmpl
Expand Up @@ -99,7 +99,7 @@ lang="${lang}">
<ul class="translations">
%for langname in translations.keys():
%if langname != lang:
<li><a href="${_link("index", None, langname)}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
<li><a href="${abs_link(_link("root", None, langname))}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
%endif
%endfor
</ul>
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/bootstrap-jinja/templates/base.tmpl
Expand Up @@ -24,7 +24,7 @@
<span class="icon-bar"></span>
</a>

<a class="brand" href="{{ abs_link('/') }}">
<a class="brand" href="{{ abs_link(_link("root", None, lang)) }}">
{% if logo_url %}
<img src="{{ logo_url }}" alt="{{ blog_title }}" id="logo">
{% endif %}
Expand Down
Expand Up @@ -165,7 +165,7 @@ lang="{{ lang }}">
{% macro html_translations() %}
{% for langname in translations.keys() %}
{% if langname != lang %}
<li><a href="{{ _link("index", None, langname) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
<li><a href="{{ abs_link(_link("root", None, langname)) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
{% endif %}
{% endfor %}
{% endmacro %}
2 changes: 1 addition & 1 deletion nikola/data/themes/bootstrap/templates/base.tmpl
Expand Up @@ -24,7 +24,7 @@ ${template_hooks['extra_head']()}
<span class="icon-bar"></span>
</a>

<a class="brand" href="${abs_link('/')}">
<a class="brand" href="${abs_link(_link("root", None, lang))}">
%if logo_url:
<img src="${logo_url}" alt="${blog_title}" id="logo">
%endif
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/bootstrap/templates/base_helper.tmpl
Expand Up @@ -165,7 +165,7 @@ lang="${lang}">
<%def name="html_translations()">
%for langname in translations.keys():
%if langname != lang:
<li><a href="${_link("index", None, langname)}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
<li><a href="${abs_link(_link("root", None, langname))}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
%endif
%endfor
</%def>
2 changes: 1 addition & 1 deletion nikola/data/themes/bootstrap3-jinja/templates/base.tmpl
Expand Up @@ -22,7 +22,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{ abs_link('/') }}">
<a class="navbar-brand" href="{{ abs_link(_link("root", None, lang)) }}">
{% if logo_url %}
<img src="{{ logo_url }}" alt="{{ blog_title }}" id="logo">
{% endif %}
Expand Down
Expand Up @@ -162,7 +162,7 @@ lang="{{ lang }}">
{% macro html_translations() %}
{% for langname in translations.keys() %}
{% if langname != lang %}
<li><a href="{{ _link("index", None, langname) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
<li><a href="{{ abs_link(_link("root", None, langname)) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
{% endif %}
{% endfor %}
{% endmacro %}
2 changes: 1 addition & 1 deletion nikola/data/themes/bootstrap3/templates/base.tmpl
Expand Up @@ -22,7 +22,7 @@ ${template_hooks['extra_head']()}
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="${abs_link('/')}">
<a class="navbar-brand" href="${abs_link(_link("root", None, lang))}">
%if logo_url:
<img src="${logo_url}" alt="${blog_title}" id="logo">
%endif
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/bootstrap3/templates/base_helper.tmpl
Expand Up @@ -162,7 +162,7 @@ lang="${lang}">
<%def name="html_translations()">
%for langname in translations.keys():
%if langname != lang:
<li><a href="${_link("index", None, langname)}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
<li><a href="${abs_link(_link("root", None, langname))}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
%endif
%endfor
</%def>
16 changes: 13 additions & 3 deletions nikola/nikola.py
Expand Up @@ -234,6 +234,7 @@ def __init__(self, **config):
self.path_handlers = {
'slug': self.slug_path,
'post_path': self.post_path,
'root': self.root_path,
'filename': self.filename_path,
}

Expand Down Expand Up @@ -1093,12 +1094,13 @@ def generic_rss_renderer(self, lang, title, link, description, timeline, output_
def path(self, kind, name, lang=None, is_link=False):
"""Build the path to a certain kind of page.
These are mostly defined by plugins by registering via
the register_path_handler method, except for slug and
post_path which are defined in this class' init method.
These are mostly defined by plugins by registering via the
register_path_handler method, except for slug, post_path, root
and filename which are defined in this class' init method.
Here's some of the others, for historical reasons:
* root (name is ignored)
* tag_index (name is ignored)
* tag (and name is the tag name)
* tag_rss (name is the tag name)
Expand Down Expand Up @@ -1150,6 +1152,14 @@ def post_path(self, name, lang):
os.path.dirname(name),
self.config['INDEX_FILE']] if _f]

def root_path(self, name, lang):
"""root_path path handler"""
d = self.config['TRANSLATIONS'][lang]
if d:
return [d, '']
else:
return []

def slug_path(self, name, lang):
"""slug path handler"""
results = [p for p in self.timeline if p.meta('slug') == name]
Expand Down

0 comments on commit aa3f967

Please sign in to comment.