Skip to content

Commit aa3f967

Browse files
committedJan 17, 2015
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>
1 parent 90b5782 commit aa3f967

File tree

14 files changed

+29
-15
lines changed

14 files changed

+29
-15
lines changed
 

‎CHANGES.txt

+4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ New in master
44
Features
55
--------
66

7+
* Added ``root`` path handler (via Issues #1008, #1573)
8+
79
Bugfixes
810
--------
911

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

1216
New in v7.3.0

‎nikola/data/themes/base-jinja/templates/base_header.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{% endmacro %}
1717

1818
{% macro html_site_title() %}
19-
<h1 id="brand"><a href="{{ abs_link('/') }}" title="{{ blog_title }}" rel="home">
19+
<h1 id="brand"><a href="{{ abs_link(_link("root", None, lang)) }}" title="{{ blog_title }}" rel="home">
2020
{% if logo_url %}
2121
<img src="{{ logo_url }}" alt="{{ blog_title }}" id="logo">
2222
{% endif %}

‎nikola/data/themes/base-jinja/templates/base_helper.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ lang="{{ lang }}">
9999
<ul class="translations">
100100
{% for langname in translations.keys() %}
101101
{% if langname != lang %}
102-
<li><a href="{{ _link("index", None, langname) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
102+
<li><a href="{{ abs_link(_link("root", None, langname)) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
103103
{% endif %}
104104
{% endfor %}
105105
</ul>

‎nikola/data/themes/base/templates/base_header.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</%def>
1717

1818
<%def name="html_site_title()">
19-
<h1 id="brand"><a href="${abs_link('/')}" title="${blog_title}" rel="home">
19+
<h1 id="brand"><a href="${abs_link(_link("root", None, lang))}" title="${blog_title}" rel="home">
2020
%if logo_url:
2121
<img src="${logo_url}" alt="${blog_title}" id="logo">
2222
%endif

‎nikola/data/themes/base/templates/base_helper.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ lang="${lang}">
9999
<ul class="translations">
100100
%for langname in translations.keys():
101101
%if langname != lang:
102-
<li><a href="${_link("index", None, langname)}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
102+
<li><a href="${abs_link(_link("root", None, langname))}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
103103
%endif
104104
%endfor
105105
</ul>

‎nikola/data/themes/bootstrap-jinja/templates/base.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<span class="icon-bar"></span>
2525
</a>
2626

27-
<a class="brand" href="{{ abs_link('/') }}">
27+
<a class="brand" href="{{ abs_link(_link("root", None, lang)) }}">
2828
{% if logo_url %}
2929
<img src="{{ logo_url }}" alt="{{ blog_title }}" id="logo">
3030
{% endif %}

‎nikola/data/themes/bootstrap-jinja/templates/base_helper.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ lang="{{ lang }}">
165165
{% macro html_translations() %}
166166
{% for langname in translations.keys() %}
167167
{% if langname != lang %}
168-
<li><a href="{{ _link("index", None, langname) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
168+
<li><a href="{{ abs_link(_link("root", None, langname)) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
169169
{% endif %}
170170
{% endfor %}
171171
{% endmacro %}

‎nikola/data/themes/bootstrap/templates/base.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ${template_hooks['extra_head']()}
2424
<span class="icon-bar"></span>
2525
</a>
2626

27-
<a class="brand" href="${abs_link('/')}">
27+
<a class="brand" href="${abs_link(_link("root", None, lang))}">
2828
%if logo_url:
2929
<img src="${logo_url}" alt="${blog_title}" id="logo">
3030
%endif

‎nikola/data/themes/bootstrap/templates/base_helper.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ lang="${lang}">
165165
<%def name="html_translations()">
166166
%for langname in translations.keys():
167167
%if langname != lang:
168-
<li><a href="${_link("index", None, langname)}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
168+
<li><a href="${abs_link(_link("root", None, langname))}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
169169
%endif
170170
%endfor
171171
</%def>

‎nikola/data/themes/bootstrap3-jinja/templates/base.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<span class="icon-bar"></span>
2323
<span class="icon-bar"></span>
2424
</button>
25-
<a class="navbar-brand" href="{{ abs_link('/') }}">
25+
<a class="navbar-brand" href="{{ abs_link(_link("root", None, lang)) }}">
2626
{% if logo_url %}
2727
<img src="{{ logo_url }}" alt="{{ blog_title }}" id="logo">
2828
{% endif %}

‎nikola/data/themes/bootstrap3-jinja/templates/base_helper.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ lang="{{ lang }}">
162162
{% macro html_translations() %}
163163
{% for langname in translations.keys() %}
164164
{% if langname != lang %}
165-
<li><a href="{{ _link("index", None, langname) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
165+
<li><a href="{{ abs_link(_link("root", None, langname)) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
166166
{% endif %}
167167
{% endfor %}
168168
{% endmacro %}

‎nikola/data/themes/bootstrap3/templates/base.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ${template_hooks['extra_head']()}
2222
<span class="icon-bar"></span>
2323
<span class="icon-bar"></span>
2424
</button>
25-
<a class="navbar-brand" href="${abs_link('/')}">
25+
<a class="navbar-brand" href="${abs_link(_link("root", None, lang))}">
2626
%if logo_url:
2727
<img src="${logo_url}" alt="${blog_title}" id="logo">
2828
%endif

‎nikola/data/themes/bootstrap3/templates/base_helper.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ lang="${lang}">
162162
<%def name="html_translations()">
163163
%for langname in translations.keys():
164164
%if langname != lang:
165-
<li><a href="${_link("index", None, langname)}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
165+
<li><a href="${abs_link(_link("root", None, langname))}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
166166
%endif
167167
%endfor
168168
</%def>

‎nikola/nikola.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ def __init__(self, **config):
234234
self.path_handlers = {
235235
'slug': self.slug_path,
236236
'post_path': self.post_path,
237+
'root': self.root_path,
237238
'filename': self.filename_path,
238239
}
239240

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

1155+
def root_path(self, name, lang):
1156+
"""root_path path handler"""
1157+
d = self.config['TRANSLATIONS'][lang]
1158+
if d:
1159+
return [d, '']
1160+
else:
1161+
return []
1162+
11531163
def slug_path(self, name, lang):
11541164
"""slug path handler"""
11551165
results = [p for p in self.timeline if p.meta('slug') == name]

0 commit comments

Comments
 (0)
Please sign in to comment.