comments_helper_disqus.tmpl 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ## -*- coding: utf-8 -*-
  2. <%! import json %>
  3. <%def name="comment_form(url, title, identifier)">
  4. %if comment_system_id:
  5. <div id="disqus_thread"></div>
  6. <script>
  7. var disqus_shortname ="${comment_system_id}",
  8. %if url:
  9. disqus_url="${url}",
  10. %endif
  11. disqus_title=${json.dumps(title)},
  12. disqus_identifier="${identifier}",
  13. disqus_config = function () {
  14. %if lang == 'es':
  15. this.language = "es_ES";
  16. %else:
  17. this.language = "${lang}";
  18. %endif
  19. };
  20. (function() {
  21. var dsq = document.createElement('script'); dsq.async = true;
  22. dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
  23. (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  24. })();
  25. </script>
  26. <noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
  27. <a href="//disqus.com" class="dsq-brlink" rel="nofollow">Comments powered by <span class="logo-disqus">Disqus</span></a>
  28. %endif
  29. </%def>
  30. <%def name="comment_link(link, identifier)">
  31. %if comment_system_id:
  32. <a href="${link}#disqus_thread" data-disqus-identifier="${identifier}">Comments</a>
  33. %endif
  34. </%def>
  35. <%def name="comment_link_script()">
  36. %if comment_system_id:
  37. <script>var disqus_shortname="${comment_system_id}";(function(){var a=document.createElement("script");a.async=true;a.src="//"+disqus_shortname+".disqus.com/count.js";(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(a)}());</script>
  38. %endif
  39. </%def>