summaryrefslogtreecommitdiffstats
path: root/nikola/data/themes/base/templates/disqus_helper.tmpl
diff options
context:
space:
mode:
Diffstat (limited to 'nikola/data/themes/base/templates/disqus_helper.tmpl')
-rw-r--r--nikola/data/themes/base/templates/disqus_helper.tmpl58
1 files changed, 58 insertions, 0 deletions
diff --git a/nikola/data/themes/base/templates/disqus_helper.tmpl b/nikola/data/themes/base/templates/disqus_helper.tmpl
new file mode 100644
index 0000000..211f27a
--- /dev/null
+++ b/nikola/data/themes/base/templates/disqus_helper.tmpl
@@ -0,0 +1,58 @@
+## -*- coding: utf-8 -*-
+<%!
+ import json
+ translations = {
+ 'es': 'es_ES',
+ }
+%>
+
+<%def name="comment_form(url, title, identifier)">
+ %if comment_system_id:
+ <div id="disqus_thread"></div>
+ <script type="text/javascript">
+ var disqus_shortname ="${comment_system_id}";
+ %if url:
+ var disqus_url="${url}";
+ %endif
+ var disqus_title=${json.dumps(title)};
+ var disqus_identifier="${identifier}";
+ var disqus_config = function () {
+ this.language = "${translations.get(lang, lang)}";
+ };
+ (function() {
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
+ dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
+ })();
+ </script>
+ <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
+ <a href="http://disqus.com" class="dsq-brlink">Comments powered by <span class="logo-disqus">Disqus</span></a>
+ %endif
+</%def>
+
+<%def name="comment_link(link, identifier)">
+ <p>
+ %if comment_system_id:
+ <a href="${link}#disqus_thread" data-disqus-identifier="${identifier}">Comments</a>
+ %endif
+</%def>
+
+
+<%def name="comment_link_script()">
+ %if comment_system_id:
+ <script type="text/javascript">var disqus_shortname="${comment_system_id}";(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>
+
+## FIXME: remove aliases in v7
+<%def name="html_disqus(url, title, identifier)">
+ ${comment_form(url, title, identifier)}
+</%def>
+
+<%def name="html_disqus_link(link, identifier)">
+ ${comment_link(link, identifier)}
+</%def>
+
+<%def name="html_disqus_script()">
+ ${comment_link_script()}
+</%def>