README.rst 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. Put ``disqus_static.py`` plugin in ``plugins`` folder in pelican installation
  10. and use the following in your settings::
  11. PLUGINS = [u"pelican.plugins.disqus_static"]
  12. DISQUS_SITENAME = u'YOUR_SITENAME'
  13. DISQUS_SECRET_KEY = u'YOUR_SECRET_KEY'
  14. DISQUS_PUBLIC_KEY = u'YOUR_PUBLIC_KEY'
  15. Usage
  16. -----
  17. Example use of the comments in templates:
  18. .. code-block:: html+jinja
  19. {% if article.disqus_comments %}
  20. <div id="disqus_static_comments">
  21. <h4>{{ article.disqus_comments|length }} comments</h4>
  22. <ul class="post-list">
  23. {% for comment in article.disqus_comments %}
  24. <li class="post">
  25. <div data-role="post-content" class="post-content">
  26. <div class="avatar hovercard">
  27. <img alt="Avatar" src="{{ comment.author.avatar.small.cache }}">
  28. </div>
  29. <div class="post-body">
  30. <header>
  31. <span class="publisher-anchor-color">{{ comment.author.name }}</span>
  32. <span class="time-ago" title="{{ comment.createdAt }}">{{ comment.createdAt }}</span>
  33. </header>
  34. <div class="post-message-container" data-role="message-container">
  35. <div data-role="message-content">
  36. <div class="post-message publisher-anchor-color " data-role="message">
  37. {{ comment.message }}
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </li>
  44. {% endfor %}
  45. </ul>
  46. </div>
  47. {% endif %}
  48. TODO
  49. -----
  50. - handle replies to comments properly and maintain parent-child relationships
  51. - test for sites with over 100 comments (I think disqus API only returns 100 items per request)