categories.html 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {% extends 'base.html' %}
  2. {% block title %}
  3. All Categories · {{ super() }}
  4. {% endblock title %}
  5. {% block head_description %}
  6. All categories of the {{ SITENAME|striptags|e }} blog.
  7. {% endblock head_description %}
  8. {% block meta_tags_in_head %}
  9. {{ super() }}
  10. <meta property="og:title" content="All Categories · {{ SITENAME|striptags|e }}"/>
  11. <meta name="twitter:title" content="All Categories · {{ SITENAME|striptags|e }}">
  12. <meta property="og:url" content="{{ SITEURL }}/categories.html" />
  13. <meta property="og:description" content="All categories of the {{ SITENAME|striptags|e }} blog" />
  14. <meta name="twitter:description" content="All categories of the {{ SITENAME|striptags|e }} blog">
  15. <meta property="og:site_name" content="{{ SITENAME|striptags|e }}" />
  16. <meta property="og:article:author" content="{{ AUTHOR }}" />
  17. {% from '_includes/_defaults.html' import FEATURED_IMAGE with context %}
  18. {% if FEATURED_IMAGE %}
  19. <meta property="og:image" content="{{FEATURED_IMAGE}}" />
  20. <meta name="twitter:image" content="{{FEATURED_IMAGE}}" >
  21. {% endif %}
  22. {% endblock meta_tags_in_head %}
  23. {% block feed_links %}
  24. {{ super() }}
  25. {% include '_includes/feeds_categories.html' %}
  26. {% endblock feed_links %}
  27. {% block content %}
  28. <div class="row">
  29. <header class="page-header col-md-10 col-md-offset-2">
  30. <h1><a href="{{ SITEURL }}/categories.html">All Categories</a></h1>
  31. </header>
  32. </div>
  33. <div class="row">
  34. <div class="col-md-8 col-md-offset-2">
  35. <div class="panel-group" id="accordion role="tablist" aria-multiselectable="true"">
  36. {% for category, articles in categories %}
  37. {# ~ is used for concatenation. I have added an empty string "" because without it Jinja
  38. does not convert second operand into string #}
  39. {% set collapse_id = category.slug ~ '-ref' ~ "" %}
  40. {% set collapse_ref = '#' ~ collapse_id ~ "" %}
  41. {% set heading_id = "heading-" ~ category.slug ~ "" %}
  42. <div class="panel panel-default">
  43. <div class="panel-heading" role="tab" id="{{ heading_id }}" data-toggle="collapse" data-parent="#accordion" aria-expanded="false" aria-controls="{{ collapse_id }}" data-target="{{ collapse_ref }}">
  44. <a class="list-of-categories collapsed" href="{{ collapse_ref }}">
  45. {% set num = articles|count %}
  46. {{ category }}<span>{{ num }}</span>
  47. </a>
  48. </div>
  49. <div id="{{ collapse_id }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="{{ heading_id }}">
  50. <div class="panel-body">
  51. <ul class="list-articles-category">
  52. {% for article in articles %}
  53. <li><time pubdate="pubdate" datetime="{{ article.date.isoformat() }}">{{ article.locale_date }}</time><a href="{{ SITEURL }}/{{ article.url }}">{{ article.title }} {%if article.subtitle %} <small> {{ article.subtitle }} </small> {% endif %} </a></li>
  54. {% endfor %}
  55. </ul>
  56. </div>
  57. </div>
  58. </div>
  59. {% endfor %}
  60. </div>
  61. </div>
  62. </div>
  63. {% endblock content %}
  64. {% block script %}
  65. {{ super() }}
  66. <script language="javascript" type="text/javascript">
  67. function uncollapse() {
  68. $(window.location.hash).collapse({
  69. toggle: true
  70. })
  71. }
  72. </script>
  73. <script type="text/javascript" language="JavaScript">
  74. uncollapse();
  75. </script>
  76. {% endblock script %}