README.rst 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. Disqus static comment plugin for Pelican
  2. ====================================
  3. This plugin adds a disqus_comments property to all articles.
  4. Comments are fetched at generation time using disqus API.
  5. Installation
  6. ------------
  7. Because we use disqus API to retrieve the comments you need to create an application at
  8. http://disqus.com/api/applications/ which will provide you with a secret and public keys for the API.
  9. We use disqus-python package for communication with disqus API:
  10. ``pip install disqus-python``
  11. Put ``disqus_static.py`` plugin in ``plugins`` folder in pelican installation
  12. and use the following in your settings::
  13. PLUGINS = [u"disqus_static"]
  14. DISQUS_SITENAME = u'YOUR_SITENAME'
  15. DISQUS_SECRET_KEY = u'YOUR_SECRET_KEY'
  16. DISQUS_PUBLIC_KEY = u'YOUR_PUBLIC_KEY'
  17. Usage
  18. -----
  19. .. code-block:: html+jinja
  20. {% if article.disqus_comments %}
  21. <div id="disqus_static_comments">
  22. <h4>{{ article.disqus_comment_count }} comments</h4>
  23. <ul class="post-list">
  24. {% for comment in article.disqus_comments recursive %}
  25. <li class="post">
  26. <div class="post-content">
  27. <div class="avatar hovercard">
  28. <img alt="Avatar" src="{{ comment.author.avatar.small.cache }}">
  29. </div>
  30. <div class="post-body">
  31. <header>
  32. <span class="publisher-anchor-color">{{ comment.author.name }}</span>
  33. <span class="time-ago" title="{{ comment.createdAt }}">{{ comment.createdAt }}</span>
  34. </header>
  35. <div class="post-message-container">
  36. <div class="post-message publisher-anchor-color ">
  37. {{ comment.message }}
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. {% if comment.children %}
  43. <ul class="children">
  44. {{ loop(comment.children) }}
  45. </ul>
  46. {% endif %}
  47. </li>
  48. {% endfor %}
  49. </ul>
  50. </div>
  51. {% endif %}