Skip to content
Permalink
Browse files

Idea to avoid repeating ourselves so much in templates

  • Loading branch information
ralsina committed Sep 4, 2015
1 parent 096cd9f commit fefd6a1210472c65147a0068a5adee963d605b9f
Showing with 9 additions and 32 deletions.
  1. +1 −0 CHANGES.txt
  2. +3 −30 nikola/data/themes/bootstrap3/templates/base_helper.tmpl
  3. +5 −2 nikola/nikola.py
@@ -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)

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

0 comments on commit fefd6a1

Please sign in to comment.