Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #201 from schettino72/more-template-helpers

More template helpers
  • Loading branch information...
commit 3a13a86ab22f3692b98c785d8f9d17c79f34a434 2 parents 31fe1fc + 2303236
Roberto Alsina authored December 26, 2012
1  AUTHORS.txt
... ...
@@ -1 +1,2 @@
1 1
 Roberto Alsina <ralsina@kde.org>
  2
+Eduardo Schettino <https://github.com/schettino72>
26  nikola/data/themes/default/templates/index.tmpl
... ...
@@ -1,4 +1,5 @@
1 1
 ## -*- coding: utf-8 -*-
  2
+<%namespace name="helper" file="index_helper.tmpl"/>
2 3
 <%inherit file="base.tmpl"/>
3 4
 <%block name="content">
4 5
     % for post in posts:
@@ -9,28 +10,9 @@
9 10
         </small></h1>
10 11
         <hr>
11 12
         ${post.text(lang, index_teasers)}
12  
-        <p>
13  
-        %if disqus_forum:
14  
-            <a href="${post.permalink()}#disqus_thread">Comments</a>
15  
-        %endif
  13
+        ${helper.html_disqus_link(post)}
16 14
         </div>
17 15
     % endfor
18  
-    <div>
19  
-<ul class="pager">
20  
-  %if prevlink:
21  
-    <li class="previous">
22  
-        <a href="${prevlink}">&larr; ${messages[lang]["Newer posts"]}</a>
23  
-    </li>
24  
-  %endif
25  
-  %if nextlink:
26  
-    <li class="next">
27  
-        <a href="${nextlink}">${messages[lang]["Older posts"]} &rarr;</a>
28  
-    </li>
29  
-  %endif
30  
-</ul>
31  
-
32  
-    </div>
33  
-    %if disqus_forum:
34  
-       <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>
35  
-    %endif
  16
+    ${helper.html_pager()}
  17
+    ${helper.html_disqus_script()}
36 18
 </%block>
31  nikola/data/themes/default/templates/index_helper.tmpl
... ...
@@ -0,0 +1,31 @@
  1
+<%def name="html_pager()">
  2
+<div>
  3
+<ul class="pager">
  4
+  %if prevlink:
  5
+    <li class="previous">
  6
+        <a href="${prevlink}">&larr; ${messages[lang]["Newer posts"]}</a>
  7
+    </li>
  8
+  %endif
  9
+  %if nextlink:
  10
+    <li class="next">
  11
+        <a href="${nextlink}">${messages[lang]["Older posts"]} &rarr;</a>
  12
+    </li>
  13
+  %endif
  14
+</ul>
  15
+</div>
  16
+</%def>
  17
+
  18
+
  19
+<%def name="html_disqus_link(post)">
  20
+    <p>
  21
+    %if disqus_forum:
  22
+        <a href="${post.permalink()}#disqus_thread">Comments</a>
  23
+    %endif
  24
+</%def>
  25
+
  26
+
  27
+<%def name="html_disqus_script()">
  28
+    %if disqus_forum:
  29
+       <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>
  30
+    %endif
  31
+</%def>
32  nikola/data/themes/default/templates/post.tmpl
@@ -3,34 +3,18 @@
3 3
 <%inherit file="base.tmpl"/>
4 4
 <%block name="content">
5 5
     <div class="postbox">
6  
-    <h1><a href='${permalink}'>${title}</a></h1>
7  
-    % if link:
8  
-            <p><a href='${link}'>${messages[lang]["Original site"]}</a></p>
9  
-    % endif
  6
+    ${helper.html_title()}
10 7
     <hr>
11 8
     <small>
12  
-        ${messages[lang]["Posted"]}: ${post.date.strftime(date_format)}&nbsp;&nbsp;|&nbsp;&nbsp;
13  
-
14  
-        %if len(translations) > 1:
15  
-            %for langname in translations.keys():
16  
-                %if langname != lang:
17  
-                    <a href="${post.permalink(langname)}">${messages[langname][u"Read in English"]}</a>
18  
-                    &nbsp;&nbsp;|&nbsp;&nbsp;
19  
-                %endif
20  
-            %endfor
21  
-        %endif
22  
-
23  
-        <a href="${post.pagenames[lang]+".txt"}">${messages[lang]["Source"]}</a>
24  
-        %if post.tags:
25  
-            &nbsp;&nbsp;|&nbsp;&nbsp;${messages[lang]["More posts about"]}
26  
-            %for tag in post.tags:
27  
-                <a href="${_link("tag", tag, lang)}"><span class="badge badge-info">${tag}</span></a>
28  
-            %endfor
29  
-        %endif
  9
+        ${messages[lang]["Posted"]}: ${post.date.strftime(date_format)}
  10
+        ${helper.html_translations(post)}
  11
+        &nbsp;&nbsp;|&nbsp;&nbsp;
  12
+        <a href="${post.pagenames[lang]+'.txt'}">${messages[lang]["Source"]}</a>
  13
+        ${helper.html_tags(post)}
30 14
     </small>
31 15
     <hr>
32 16
     ${post.text(lang)}
33  
-    ${helper.html_pager()}
34  
-    ${helper.html_disqus()}
  17
+    ${helper.html_pager(post)}
  18
+    ${helper.html_disqus(post)}
35 19
     </div>
36 20
 </%block>
34  nikola/data/themes/default/templates/post_helper.tmpl
... ...
@@ -1,5 +1,34 @@
  1
+<%def name="html_title()">
  2
+    <h1>${title}</h1>
  3
+    % if link:
  4
+            <p><a href='${link}'>${messages[lang]["Original site"]}</a></p>
  5
+    % endif
  6
+</%def>
  7
+
  8
+
  9
+<%def name="html_translations(post)">
  10
+    %if len(translations) > 1:
  11
+        %for langname in translations.keys():
  12
+            %if langname != lang:
  13
+                &nbsp;&nbsp;|&nbsp;&nbsp;
  14
+                <a href="${post.permalink(langname)}">${messages[langname]["Read in English"]}</a>
  15
+            %endif
  16
+        %endfor
  17
+    %endif
  18
+</%def>
  19
+
1 20
 
2  
-<%def name="html_disqus()">
  21
+<%def name="html_tags(post)">
  22
+    %if post.tags:
  23
+        &nbsp;&nbsp;|&nbsp;&nbsp;${messages[lang]["More posts about"]}
  24
+        %for tag in post.tags:
  25
+            <a class="tag" href="${_link('tag', tag, lang)}"><span class="badge badge-info">${tag}</span></a>
  26
+        %endfor
  27
+    %endif
  28
+</%def>
  29
+
  30
+
  31
+<%def name="html_disqus(post)">
3 32
     %if disqus_forum:
4 33
         <div id="disqus_thread"></div>
5 34
         <script type="text/javascript">var disqus_shortname="${disqus_forum}";var disqus_url="${post.permalink(absolute=True)}";(function(){var a=document.createElement("script");a.type="text/javascript";a.async=true;a.src="http://"+disqus_shortname+".disqus.com/embed.js";(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(a)})();        </script>
@@ -8,7 +37,8 @@
8 37
     %endif
9 38
 </%def>
10 39
 
11  
-<%def name="html_pager()">
  40
+
  41
+<%def name="html_pager(post)">
12 42
     <ul class="pager">
13 43
     %if post.prev_post:
14 44
         <li class="previous">
2  nikola/data/themes/default/templates/tags.tmpl
@@ -6,7 +6,7 @@
6 6
         <h1>${title}</h1>
7 7
         <ul class="unstyled">
8 8
         % for text, link in items:
9  
-            <li><a href="${link}"><span class="badge badge-info">${text}</span></a>
  9
+            <li><a class="tag" href="${link}"><span class="badge badge-info">${text}</span></a>
10 10
         % endfor
11 11
         </ul>
12 12
         <!--End of body content-->
26  nikola/data/themes/site/templates/post.tmpl
@@ -3,33 +3,17 @@
3 3
 <%inherit file="base.tmpl"/>
4 4
 <%block name="content">
5 5
     <div class="postbox">
6  
-    <h1>${title}</h1>
7  
-    % if link:
8  
-            <p><a href='${link}'>${messages[lang]["Original site"]}</a></p>
9  
-    % endif
  6
+    ${helper.html_title()}
10 7
     <hr>
11 8
     <small>
12 9
         ${messages[lang]["Posted"]}: ${post.date.strftime(date_format)}
13  
-
14  
-        %if len(translations) > 1:
15  
-            %for langname in translations.keys():
16  
-                %if langname != lang:
17  
-                    &nbsp;&nbsp;|&nbsp;&nbsp;
18  
-                    <a href="${post.permalink(langname)}">${messages[langname]["Read in English"]}</a>
19  
-                %endif
20  
-            %endfor
21  
-        %endif
22  
-        %if post.tags:
23  
-            &nbsp;&nbsp;|&nbsp;&nbsp;${messages[lang]["More posts about"]}
24  
-            %for tag in post.tags:
25  
-                <a href="${_link("tag", tag, lang)}"><span class="badge badge-info">${tag}</span></a>
26  
-            %endfor
27  
-        %endif
  10
+        ${helper.html_translations(post)}
  11
+        ${helper.html_tags(post)}
28 12
     </small>
29 13
     <hr>
30 14
     ${post.text(lang)}
31  
-    ${helper.html_pager()}
32  
-    ${helper.html_disqus()}
  15
+    ${helper.html_pager(post)}
  16
+    ${helper.html_disqus(post)}
33 17
     </div>
34 18
 </%block>
35 19
 

0 notes on commit 3a13a86

Please sign in to comment.
Something went wrong with that request. Please try again.