README.rst 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. tag_cloud
  2. =========
  3. This plugin generates a tag-cloud.
  4. Installation
  5. ------------
  6. In order to use to use this plugin, you have to edit(*) or create(+) the following files::
  7. blog/
  8. ├── pelicanconf.py *
  9. ├── content
  10. ├── plugins +
  11. │ └── tag_cloud.py +
  12. └── themes
  13. └── mytheme
  14. ├── templates
  15. │ └── base.html *
  16. └── static
  17. └── css
  18. └── style.css *
  19. In **pelicanconf.py** you have to activate the plugin::
  20. PLUGIN_PATHS = ["plugins"]
  21. PLUGINS = ["tag_cloud"]
  22. Into your **plugins** folder, you should add tag_cloud.py (from this repository).
  23. In your theme files, you should change **base.html** to apply formats (and sizes) defined in **style.css**, as specified in "Settings", below.
  24. Settings
  25. --------
  26. ================================================ =====================================================
  27. Setting name (followed by default value) What does it do?
  28. ================================================ =====================================================
  29. ``TAG_CLOUD_STEPS = 4`` Count of different font sizes in the tag
  30. cloud.
  31. ``TAG_CLOUD_MAX_ITEMS = 100`` Maximum number of tags in the cloud.
  32. ``TAG_CLOUD_SORTING = 'random'`` The tag cloud ordering scheme. Valid values:
  33. random, alphabetically, alphabetically-rev, size and
  34. size-rev
  35. ================================================ =====================================================
  36. The default theme does not include a tag cloud, but it is pretty easy to add one::
  37. <ul class="tagcloud">
  38. {% for tag in tag_cloud %}
  39. <li class="tag-{{ tag.1 }}"><a href="{{ SITEURL }}/{{ tag.0.url }}">{{ tag.0 }}</a></li>
  40. {% endfor %}
  41. </ul>
  42. You should then also define CSS styles with appropriate classes (tag-1 to tag-N,
  43. where N matches ``TAG_CLOUD_STEPS``), tag-1 being the most frequent, and
  44. define a ``ul.tagcloud`` class with appropriate list-style to create the cloud.
  45. For example::
  46. ul.tagcloud {
  47. list-style: none;
  48. padding: 0;
  49. }
  50. ul.tagcloud li {
  51. display: inline-block;
  52. }
  53. li.tag-1 {
  54. font-size: 150%;
  55. }
  56. li.tag-2 {
  57. font-size: 120%;
  58. }
  59. ...
  60. By default the tags in the cloud are sorted randomly, but if you prefers to have it alphabetically use the `alphabetically` (ascending) and `alphabetically-rev` (descending). Also is possible to sort the tags by it's size (number of articles with this specific tag) using the values `size` (ascending) and `size-rev` (descending).