index.twig 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. {% spaceless %}
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
  7. <title>
  8. {% if meta.title %}
  9. {{ meta.title }} |
  10. {% endif %}
  11. {{ site_title }}
  12. </title>
  13. <link rel="icon" type="image/x-icon" href="/favicon.ico">
  14. {% if meta.description %}
  15. <meta name="description" content="{{ meta.description }}"/>
  16. {# i don't understand what og:... is good for. i hope i'm doing this right. #}
  17. <meta property="og:description" content="{{ meta.description }}"/>
  18. {% endif %}
  19. {% if meta.robots %}
  20. <meta name="robots" content="{{ meta.robots }}">
  21. {% endif %}
  22. {# i don't understand what og:... is good for. i hope i'm doing this right. #}
  23. <meta property="og:type" content="{{current_page.meta.template}}"/>
  24. <meta property="og:title"
  25. content="{{ current_page.title }} | {{ site_title }}"/>
  26. <meta property="og:url" content="{{ current_page.url }}"/>
  27. <meta property="og:site_name" content="{{ site_title }}"/>
  28. {% if current_page %}
  29. <link rel="canonical" href="{{ current_page.url }}" />
  30. {% endif %}
  31. <link rel="stylesheet" href="{{ theme_url }}/css/style.css" type="text/css" />
  32. <link rel="stylesheet" href="{{ theme_url }}/css/colors-{{ config.tagblog.colors }}.css" type="text/css" />
  33. {% if meta.template == 404 %}<link rel="stylesheet" href="{{ theme_url }}/css/404.css" type="text/css" />{% endif %}
  34. {% if meta.template == config.TableOfContent.template or not config.TableOfContent.template %}<link rel="stylesheet" href="{{ theme_url }}/css/TableOfContent.css" type="text/css" />{% endif %}
  35. </head>
  36. <body>
  37. <header>
  38. <div class="inner flexbox">
  39. {% include 'includes/topmenu.twig' ignore missing %}
  40. <a href="{{ "index"|link }}"><img src="{{ config.tagblog.site_logo }}" alt="{{- site_title -}}"></a>
  41. <div class="title">
  42. <a href="{{ "index"|link }}">{{ site_title }}</a>
  43. </div>
  44. </div>
  45. </header>
  46. <div class="inner">
  47. <section id="sidebar">
  48. {# looping over all pages to pick out what we need (i.e. pages with tags) #}
  49. {% set tag_count = {} %} {# tag_count contains: tag : count of occurences #}
  50. {% set tag_pages = {} %} {# tag_pages contains: tag : page ids of occurences hash '#' separated #}
  51. {% set aut_count = {} %} {# aut_count contains: author : count of occurences #}
  52. {% set aut_pages = {} %} {# aut_pages contains: author : page ids of occurences hash '#' separated #}
  53. {% set tbpages = {} %} {# contains ALL pages to be considered, saves some cycles later on #}
  54. {% for page in pages if page.meta.tags or page.meta.author %}
  55. {% if page.meta.tags %}
  56. {% set tbpages = tbpages|merge([page]) %}
  57. {% for tag in page.meta.tags|split(',') %}
  58. {# tag_count contains: tag : count of occurences #}
  59. {% set tag_count = tag_count|merge({(tag):(tag_count[tag] + 1)}) %}
  60. {# tag_pages contains: tag : page ids of occurences hash '#' separated #}
  61. {% set tag_pages = tag_pages|merge( { (tag) : (tag_pages[tag] ~ '#' ~ page.id) } ) %}
  62. {% endfor %}
  63. {% endif %}
  64. {% if page.meta.author %}
  65. {% set aut_count = aut_count|merge({(page.meta.author):(aut_count[page.meta.author] + 1)}) %}
  66. {% set aut_pages = aut_pages|merge({(page.meta.author):(aut_pages[page.meta.author]~'#'~page.id)}) %}
  67. {% endif %}
  68. {% endfor %}
  69. {# sort tag_count into tag_sorting, according to config options #}
  70. {% set tag_sorting = {} %}
  71. {% if config.tagblog.tagsort.method == 'numerical' %}
  72. {% set tag_sorting = tag_count|sort %}
  73. {% elseif config.tagblog.tagsort.method == 'alphabetical' %}
  74. {% for tag in tag_count|keys|sort %}
  75. {% set tag_sorting = tag_sorting|merge({(tag): tag_count[tag] }) %}
  76. {% endfor %}
  77. {% endif %}
  78. {# ... and sort it back into tag_count array #}
  79. {% if config.tagblog.tagsort.reverse %}
  80. {% set tag_count = tag_sorting|reverse %}
  81. {% else %}
  82. {% set tag_count = tag_sorting %}
  83. {% endif %}
  84. <input id="menu-icon" type="checkbox"/>
  85. <label for="menu-icon">≡<span> menu</span></label>
  86. <nav id="menu-icon"> {# this nav's visibility is controled by the checkbox above! #}
  87. {% include 'includes/sidebar-top.twig' ignore missing %}
  88. {# Tag List #}
  89. {% if config.tagblog.taglist.enabled and tag_count %}
  90. <div class="tag_list">
  91. {% if config.tagblog.taglist.title %}<h2>{{ config.tagblog.taglist.title }}</h2>{% endif %}
  92. <ul>
  93. {% for tag,total in tag_count %}
  94. <li>
  95. <a href="/tags?q={{tag}}">{{ tag }}{% if config.tagblog.tagcount.enabled %}<span> ({{ total }})</span>{% endif %}</a>
  96. </li>
  97. {% endfor %}
  98. </ul>
  99. </div>
  100. {% endif %}
  101. {# Tag Cloud #}
  102. {% if config.tagblog.tagcloud.enabled and tag_count %}
  103. {# Levels Validation #}
  104. {% if max(tag_count) < config.tagblog.tagcloud.maxoccur %}
  105. {% set tagmaxoccur = max(tag_count) %}
  106. {% else %}
  107. {% set tagmaxoccur = config.tagblog.tagcloud.maxoccur %}
  108. {% endif %}
  109. {# Render Tag Cloud #}
  110. <div class="tag_cloud">
  111. {% if config.tagblog.tagcloud.title %}<div>{{ config.tagblog.tagcloud.title }}</div>{% endif %}
  112. <ul>
  113. {% for tag,total in tag_count %}
  114. {% if total > tagmaxoccur %}{% set size = tagmaxoccur %}{% else %}{% set size = total %}
  115. {% endif %}
  116. {% if size == 1 %}{% set fontsize = config.tagblog.tagcloud.fontsizemin %}
  117. {% else %}
  118. {# calculate tag font size - https://stackoverflow.com/a/3717340 #}
  119. {% set fontsize = ( (size / tagmaxoccur) * ( config.tagblog.tagcloud.fontsizemax - config.tagblog.tagcloud.fontsizemin ) + config.tagblog.tagcloud.fontsizemin ) %}
  120. {% endif %}
  121. <li style="font-size:{{ fontsize }}rem;">
  122. <a href="/tags?q={{tag}}">{{ tag }}{% if config.tagblog.tagcount.enabled %}<span>{{ total }}</span>{% endif %}</a></li>
  123. {% endfor %}
  124. </ul>
  125. </div>
  126. {% endif %}
  127. <hr />
  128. <div class="clearfix">
  129. {% if config.tagblog.search.enabled %}
  130. {# searches go to the /search.md page #}
  131. <form class="search paragraph" id="search_form" action="/search">
  132. {# <label for="search_input">Search» </label> #}
  133. <span><input title='The search function is primitive. It only searches for the literal string as entered.
  134. » fluffy cloud
  135. will search only the exact string
  136. » "fluffy cloud".
  137. Searches are case insensitive. Tags and some special characters are stripped.' class="submit" type="submit" value="Search" /></span>
  138. <span><input pattern=".{0{{config.tagblog.search.minlength}},}" required title="{{config.tagblog.search.minlength}} characters minimum" size="15" type="text" id="search_input" name="q" /></span>
  139. </form>
  140. {% endif %}
  141. {% if config.tagblog.feed.enabled %}
  142. <div class="rss paragraph"><a href="/feed">RSS Feed</a></div>
  143. {% endif %}
  144. {% include 'includes/sidebar-bottom.twig' ignore missing %}
  145. </div>
  146. </nav>
  147. </section>
  148. <section id="content">
  149. {% endspaceless %}
  150. {% block content %}
  151. {% set length = tbpages|length %}
  152. <article><h3>All Articles ({{length}})</h3></article>
  153. {% if config.tagblog.paging > 0 and length > config.tagblog.paging %}
  154. {# Paginate over all pages with tags #}
  155. {% set p = url_param('p','int',1) %}
  156. {% set offset = (p - 1) * config.tagblog.paging %}
  157. {% set lastpage = length//config.tagblog.paging %}
  158. {% if length%config.tagblog.paging > 0 %}{% set lastpage = lastpage + 1 %}{% endif %}
  159. {% for page in tbpages|slice(offset,config.tagblog.paging) %}
  160. {% include 'includes/postlistitem.twig' %}
  161. {% endfor %}
  162. <div class="pagination clearfix">
  163. {% if offset >= config.tagblog.paging %}
  164. <div class="previous"><a href="{{current_page.url}}?p={{ p - 1 }}">&lt;Previous Page</a></div>
  165. {% endif %}
  166. {# {% if offset >= config.tagblog.paging and offset + config.tagblog.paging < length %} | {% endif %} #}
  167. <div class="current">- {{ p }}/{{ lastpage }} -</div>
  168. {% if offset + config.tagblog.paging < length %}
  169. <div class="next"><a href="{{current_page.url}}?p={{ p + 1 }}">Next Page&gt;</a></div>
  170. {% endif %}
  171. </div>
  172. {% else %}
  173. {# just list all pages #}
  174. {% for page in tbpages %}
  175. {% include 'includes/postlistitem.twig' %}
  176. {% endfor %}
  177. {% endif %}
  178. {% endblock %}
  179. {% spaceless %}
  180. </section>
  181. </div>
  182. <footer>
  183. {% include 'includes/footer.twig' ignore missing %}
  184. </footer>
  185. </body>
  186. </html>
  187. {% endspaceless %}