Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

mako template refactoring to use functions.

  • Loading branch information...
commit 6c203e48b4085cda892139b187afef25ae7102ed 1 parent 31fe1fc
@schettino72 schettino72 authored
View
26 nikola/data/themes/default/templates/index.tmpl
@@ -1,4 +1,5 @@
## -*- coding: utf-8 -*-
+<%namespace name="helper" file="index_helper.tmpl"/>
<%inherit file="base.tmpl"/>
<%block name="content">
% for post in posts:
@@ -9,28 +10,9 @@
</small></h1>
<hr>
${post.text(lang, index_teasers)}
- <p>
- %if disqus_forum:
- <a href="${post.permalink()}#disqus_thread">Comments</a>
- %endif
+ ${helper.html_disqus_link(post)}
</div>
% endfor
- <div>
-<ul class="pager">
- %if prevlink:
- <li class="previous">
- <a href="${prevlink}">&larr; ${messages[lang]["Newer posts"]}</a>
- </li>
- %endif
- %if nextlink:
- <li class="next">
- <a href="${nextlink}">${messages[lang]["Older posts"]} &rarr;</a>
- </li>
- %endif
-</ul>
-
- </div>
- %if disqus_forum:
- <script type="text/javascript">var disqus_shortname="${disqus_forum}";(function(){var a=document.createElement("script");a.async=true;a.type="text/javascript";a.src="http://"+disqus_shortname+".disqus.com/count.js";(document.getElementsByTagName("HEAD")[0]||document.getElementsByTagName("BODY")[0]).appendChild(a)}());</script>
- %endif
+ ${helper.html_pager()}
+ ${helper.html_disqus_script()}
</%block>
View
31 nikola/data/themes/default/templates/index_helper.tmpl
@@ -0,0 +1,31 @@
+<%def name="html_pager()">
+<div>
+<ul class="pager">
+ %if prevlink:
+ <li class="previous">
+ <a href="${prevlink}">&larr; ${messages[lang]["Newer posts"]}</a>
+ </li>
+ %endif
+ %if nextlink:
+ <li class="next">
+ <a href="${nextlink}">${messages[lang]["Older posts"]} &rarr;</a>
+ </li>
+ %endif
+</ul>
+</div>
+</%def>
+
+
+<%def name="html_disqus_link(post)">
+ <p>
+ %if disqus_forum:
+ <a href="${post.permalink()}#disqus_thread">Comments</a>
+ %endif
+</%def>
+
+
+<%def name="html_disqus_script()">
+ %if disqus_forum:
+ <script type="text/javascript">var disqus_shortname="${disqus_forum}";(function(){var a=document.createElement("script");a.async=true;a.type="text/javascript";a.src="http://"+disqus_shortname+".disqus.com/count.js";(document.getElementsByTagName("HEAD")[0]||document.getElementsByTagName("BODY")[0]).appendChild(a)}());</script>
+ %endif
+</%def>
View
28 nikola/data/themes/default/templates/post.tmpl
@@ -3,30 +3,14 @@
<%inherit file="base.tmpl"/>
<%block name="content">
<div class="postbox">
- <h1><a href='${permalink}'>${title}</a></h1>
- % if link:
- <p><a href='${link}'>${messages[lang]["Original site"]}</a></p>
- % endif
+ ${helper.html_title()}
<hr>
<small>
- ${messages[lang]["Posted"]}: ${post.date.strftime(date_format)}&nbsp;&nbsp;|&nbsp;&nbsp;
-
- %if len(translations) > 1:
- %for langname in translations.keys():
- %if langname != lang:
- <a href="${post.permalink(langname)}">${messages[langname][u"Read in English"]}</a>
- &nbsp;&nbsp;|&nbsp;&nbsp;
- %endif
- %endfor
- %endif
-
- <a href="${post.pagenames[lang]+".txt"}">${messages[lang]["Source"]}</a>
- %if post.tags:
- &nbsp;&nbsp;|&nbsp;&nbsp;${messages[lang]["More posts about"]}
- %for tag in post.tags:
- <a href="${_link("tag", tag, lang)}"><span class="badge badge-info">${tag}</span></a>
- %endfor
- %endif
+ ${messages[lang]["Posted"]}: ${post.date.strftime(date_format)}
+ ${helper.html_translations()}
+ &nbsp;&nbsp;|&nbsp;&nbsp;
+ <a href="${post.pagenames[lang]+'.txt'}">${messages[lang]["Source"]}</a>
+ ${helper.html_tags()}
</small>
<hr>
${post.text(lang)}
View
30 nikola/data/themes/default/templates/post_helper.tmpl
@@ -1,3 +1,32 @@
+<%def name="html_title()">
+ <h1>${title}</h1>
+ % if link:
+ <p><a href='${link}'>${messages[lang]["Original site"]}</a></p>
+ % endif
+</%def>
+
+
+<%def name="html_translations()">
+ %if len(translations) > 1:
+ %for langname in translations.keys():
+ %if langname != lang:
+ &nbsp;&nbsp;|&nbsp;&nbsp;
+ <a href="${post.permalink(langname)}">${messages[langname]["Read in English"]}</a>
+ %endif
+ %endfor
+ %endif
+</%def>
+
+
+<%def name="html_tags()">
+ %if post.tags:
+ &nbsp;&nbsp;|&nbsp;&nbsp;${messages[lang]["More posts about"]}
+ %for tag in post.tags:
+ <a href="${_link('tag', tag, lang)}"><span class="badge badge-info">${tag}</span></a>
+ %endfor
+ %endif
+</%def>
+
<%def name="html_disqus()">
%if disqus_forum:
@@ -8,6 +37,7 @@
%endif
</%def>
+
<%def name="html_pager()">
<ul class="pager">
%if post.prev_post:
View
22 nikola/data/themes/site/templates/post.tmpl
@@ -3,28 +3,12 @@
<%inherit file="base.tmpl"/>
<%block name="content">
<div class="postbox">
- <h1>${title}</h1>
- % if link:
- <p><a href='${link}'>${messages[lang]["Original site"]}</a></p>
- % endif
+ ${helper.html_title()}
<hr>
<small>
${messages[lang]["Posted"]}: ${post.date.strftime(date_format)}
-
- %if len(translations) > 1:
- %for langname in translations.keys():
- %if langname != lang:
- &nbsp;&nbsp;|&nbsp;&nbsp;
- <a href="${post.permalink(langname)}">${messages[langname]["Read in English"]}</a>
- %endif
- %endfor
- %endif
- %if post.tags:
- &nbsp;&nbsp;|&nbsp;&nbsp;${messages[lang]["More posts about"]}
- %for tag in post.tags:
- <a href="${_link("tag", tag, lang)}"><span class="badge badge-info">${tag}</span></a>
- %endfor
- %endif
+ ${helper.html_translations()}
+ ${helper.html_tags()}
</small>
<hr>
${post.text(lang)}
Please sign in to comment.
Something went wrong with that request. Please try again.