Skip to content

Commit

Permalink
Idea to avoid repeating ourselves so much in templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Sep 4, 2015
1 parent 096cd9f commit fefd6a1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,7 @@ New in master
Features
--------

* Allow inheriting templates with theme name (Issue #1814)
* Display post counts for archive links (Issue #2011)
* Document link/path handlers (Issue #2008)

Expand Down
33 changes: 3 additions & 30 deletions nikola/data/themes/bootstrap3/templates/base_helper.tmpl
@@ -1,5 +1,5 @@
## -*- coding: utf-8 -*-

<%inherit file="base/templates/base_helper.tmpl"/>
<%namespace name="notes" file="annotation_helper.tmpl" import="*" />
<%def name="html_headstart()">
<!DOCTYPE html>
Expand Down Expand Up @@ -155,33 +155,6 @@ lang="${lang}">
%endfor
</%def>

<%def name="html_feedlinks()">
%if rss_link:
${rss_link}
%elif generate_rss:
%if len(translations) > 1:
%for language in sorted(translations):
<link rel="alternate" type="application/rss+xml" title="RSS (${language})" href="${_link('rss', None, language)}">
%endfor
%else:
<link rel="alternate" type="application/rss+xml" title="RSS" href="${_link('rss', None)}">
%endif
%endif
%if generate_atom:
%if len(translations) > 1:
%for language in sorted(translations):
<link rel="alternate" type="application/atom+xml" title="Atom (${language})" href="${_link('index_atom', None, language)}">
%endfor
%else:
<link rel="alternate" type="application/atom+xml" title="Atom" href="${_link('index_atom', None)}">
%endif
%endif
</%def>
<%def name="html_feedlinks()"/>
<%def name="html_translations()"/>

<%def name="html_translations()">
%for langname in sorted(translations):
%if langname != lang:
<li><a href="${abs_link(_link("root", None, langname))}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
%endif
%endfor
</%def>
7 changes: 5 additions & 2 deletions nikola/nikola.py
Expand Up @@ -1006,8 +1006,11 @@ def _get_template_system(self):
"plugin\n".format(template_sys_name))
sys.exit(1)
self._template_system = pi.plugin_object
lookup_dirs = ['templates'] + [os.path.join(utils.get_theme_path(name), "templates")
for name in self.THEMES]
lookup_dirs = ['templates'] + \
[os.path.join(utils.get_theme_path(name), "templates") for name in self.THEMES] +\
list(set([os.path.dirname(utils.get_theme_path(name)) for name in self.THEMES]))

print(lookup_dirs)
self._template_system.set_directories(lookup_dirs,
self.config['CACHE_FOLDER'])
self._template_system.set_site(self)
Expand Down

0 comments on commit fefd6a1

Please sign in to comment.