Skip to content
Permalink
Browse files
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 aa3f967ccf8bdc41104b3c66528e7b27fc609fdf
@@ -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
@@ -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 %}
@@ -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>
@@ -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
@@ -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>
@@ -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 %}
@@ -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 %}
@@ -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
@@ -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>
@@ -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 %}
@@ -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 %}
@@ -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
@@ -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>
@@ -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,
}

@@ -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)
@@ -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]

0 comments on commit aa3f967

Please sign in to comment.