index.twig 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. {# tooltip contains non-breaking spaces between fluffy and cloud #}{%- set search_tooltip = 'The search function is primitive. It only searches for the literal string as entered. "fluffy cloud" will only search the exact string "fluffy cloud", and not "fluffy" OR "cloud". Search is case insensitive, HTML tags and some special characters are stripped.' -%}
  2. {# only needed for the og: meta properties in <head> #}
  3. {%- if config.tagblog.site_url is defined -%}
  4. {%- set tb_site_url = config.tagblog.site_url -%}{%- else -%}{%- set tb_site_url = config.base_url -%}
  5. {%- endif -%}<!DOCTYPE html>
  6. <html>
  7. <head>
  8. <meta http-equiv="content-type" content="text/html; charset=utf-8"><meta charset="utf-8" />
  9. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
  10. <title>{%- if meta.title -%}{{- meta.title }} | {% endif %}{{- site_title -}}</title>
  11. <link rel="icon" type="image/x-icon" href="/favicon.ico">
  12. {%- if meta.description -%}<meta name="description" content="{{- meta.description -}}"/>
  13. {# i don't understand what og:... is good for. i hope i'm doing this right. #}
  14. <meta property="og:description" content="{{- meta.description -}}"/>{%- endif -%}
  15. {%- if meta.robots -%}
  16. <meta name="robots" content="{{- meta.robots -}}">{%- endif -%}
  17. {# i don't understand what og:... is good for. i hope i'm doing this right. #}
  18. <meta property="og:type" content="{{- current_page.meta.template|default("index or other") -}}"/>
  19. <meta property="og:title" content="{{- current_page.title }} | {{ site_title -}}"/>
  20. <meta property="og:url" content="{{- tb_site_url -}}{{- current_page.id -}}"/>
  21. <meta property="og:site_name" content="{{- site_title -}}"/>
  22. {%- if current_page -%}
  23. <link rel="canonical" href="{{- tb_site_url -}}{{- current_page.id -}}" />
  24. {%- endif -%}
  25. <link rel="stylesheet" href="{{-theme_url-}}/css/style.css" type="text/css" />
  26. {# Loading color stylesheets #}<style>
  27. {%- if config.tagblog.colors -%}
  28. {%- set style = config.tagblog.colors ~ ".css" -%}
  29. {%- include [ ( 'css/generated/custom-' ~ style ), ( 'css/custom-' ~ style ), ( 'css/generated/' ~ style ), ( 'css/' ~ style ) ] ignore missing -%}
  30. {%- endif -%}
  31. {%- if config.tagblog.scrollbar_colors -%}
  32. html {
  33. scrollbar-color: var(--base0d,#0073b5) #00000000
  34. }
  35. ::-webkit-scrollbar-thumb {
  36. background: var(--base02,#d8d4cb)
  37. }
  38. {%- endif -%}
  39. @media screen and (min-width:768px){nav#menu-icon{background:unset}}{%- include theme_url ~ 'css/custom.css' ignore missing -%}</style>
  40. {%- if meta.css_extra -%}<link rel="stylesheet" href="{{- base_url -}}{{- meta.css_extra -}}" type="text/css" />{%- endif -%}
  41. {%- if config.tagblog.custom_header -%}{%- include config.tagblog.custom_header -%}{%- endif -%}
  42. </head>
  43. <body>
  44. <header>
  45. <div class="inner flexbox">
  46. {%- include 'includes/topmenu.twig' ignore missing -%}
  47. {%- include 'includes/sitelogo.twig' ignore missing -%}
  48. <div class="title">
  49. <a href="{{- base_url -}}/">{{- site_title -}}</a>
  50. </div>
  51. </div>
  52. </header>
  53. <div class="inner">
  54. <section id="sidebar">
  55. {# looping over all pages to pick out what we need (i.e. pages with tags) #}
  56. {%- set tag_count = {} -%} {# tag_count contains: tag : count of occurences #}
  57. {%- set tag_pages = {} -%} {# tag_pages contains: tag : page ids of occurences hash '#' separated #}
  58. {%- set aut_count = {} -%} {# aut_count contains: author : count of occurences #}
  59. {%- set aut_pages = {} -%} {# aut_pages contains: author : page ids of occurences hash '#' separated #}
  60. {%- set tbpages = {} -%} {# contains ALL pages to be considered, saves some cycles later on #}
  61. {%- for page in pages if page.meta.tags or page.meta.author -%}
  62. {%- if page.meta.tags -%}
  63. {%- set tbpages = tbpages|merge([page]) -%}
  64. {%- for tag in page.meta.tags|split(',') -%}
  65. {# tag_count contains: tag : count of occurences #}
  66. {%- set tag_count = tag_count|merge({(tag):(tag_count[tag] + 1)}) -%}
  67. {# tag_pages contains: tag : page ids of occurences hash '#' separated #}
  68. {%- set tag_pages = tag_pages|merge( { (tag) : (tag_pages[tag] ~ '#' ~ page.id) } ) -%}
  69. {%- endfor -%}
  70. {%- endif -%}
  71. {%- if page.meta.author -%}
  72. {%- set aut_count = aut_count|merge({(page.meta.author):(aut_count[page.meta.author] + 1)}) -%}
  73. {%- set aut_pages = aut_pages|merge({(page.meta.author):(aut_pages[page.meta.author]~'#'~page.id)}) -%}
  74. {%- endif -%}
  75. {%- endfor -%}
  76. {# sort tag_count into tag_sorting, according to config options #}
  77. {%- set tag_sorting = {} -%}
  78. {%- if config.tagblog.tagsort.method == 'numerical' -%}
  79. {%- set tag_sorting = tag_count|sort -%}
  80. {%- elseif config.tagblog.tagsort.method == 'alphabetical' -%}
  81. {%- for tag in tag_count|keys|sort -%}
  82. {%- set tag_sorting = tag_sorting|merge({(tag): tag_count[tag] }) -%}
  83. {%- endfor -%}
  84. {%- endif -%}
  85. {# ... and sort it back into tag_count array #}
  86. {%- if config.tagblog.tagsort.reverse -%}
  87. {%- set tag_count = tag_sorting|reverse -%}
  88. {%- else -%}
  89. {%- set tag_count = tag_sorting -%}
  90. {%- endif -%}
  91. <input id="menu-icon" type="checkbox"/>
  92. <label for="menu-icon">Menu</label>
  93. <nav id="menu-icon"> {# this nav's visibility is controled by the checkbox above! (mobile only) #}
  94. {%- include 'includes/sidebar-top.twig' ignore missing -%}
  95. {# Tag List #}
  96. {%- if config.tagblog.taglist.enabled and tag_count -%}
  97. <div class="tag_list">
  98. {%- if config.tagblog.taglist.title -%}<div>{{- config.tagblog.taglist.title -}}</div>{%- endif -%}
  99. <ul>
  100. {%- for tag,total in tag_count -%}
  101. <li>
  102. <a href="{{- base_url -}}/tags?q={{- tag -}}">{{- tag -}}{%- if config.tagblog.tagcount.enabled -%}<span> ({{- total -}})</span>{%- endif -%}</a>
  103. </li>
  104. {%- endfor -%}
  105. </ul>
  106. </div>
  107. {%- endif -%}
  108. {# Tag Cloud #}
  109. {%- if config.tagblog.tagcloud.enabled and tag_count -%}
  110. {# Levels Validation #}
  111. {%- if max(tag_count) < config.tagblog.tagcloud.maxoccur -%}
  112. {%- set tagmaxoccur = max(tag_count) -%}
  113. {%- else -%}
  114. {%- set tagmaxoccur = config.tagblog.tagcloud.maxoccur -%}
  115. {%- endif -%}
  116. {# Render Tag Cloud #}
  117. <div class="tag_cloud">
  118. {%- if config.tagblog.tagcloud.title -%}<div>{{- config.tagblog.tagcloud.title -}}</div>{%- endif -%}
  119. <ul>
  120. {%- for tag,total in tag_count -%}
  121. {%- if total > tagmaxoccur -%}{%- set size = tagmaxoccur -%}{%- else -%}{%- set size = total -%}
  122. {%- endif -%}
  123. {%- if size == 1 -%}{%- set fontsize = config.tagblog.tagcloud.fontsizemin -%}{%- set lettersp = 0 -%}
  124. {%- else -%}
  125. {# calculate tag font size - https://stackoverflow.com/a/3717340 #}
  126. {%- set fontsize = ( (size / tagmaxoccur) * ( config.tagblog.tagcloud.fontsizemax - config.tagblog.tagcloud.fontsizemin ) + config.tagblog.tagcloud.fontsizemin ) -%}
  127. {%- set lettersp = ( fontsize/15 )|round(2) -%}
  128. {%- endif -%}
  129. <li>
  130. <a href="{{- base_url -}}/tags?q={{- tag -}}"><span style="font-size:{{- fontsize -}}rem;letter-spacing:-{{- lettersp -}}rem">{{- tag -}}</span>{%- if config.tagblog.tagcount.enabled -%}<span>{{- total -}}</span>{%- endif -%}</a></li>
  131. {%- endfor -%}
  132. </ul>
  133. </div>
  134. {%- endif -%}
  135. <hr />
  136. <div class="clearfix">
  137. {%- if config.tagblog.search.enabled -%}
  138. {# searches go to the /search.md page #}
  139. <form class="search paragraph" id="search_form" action="/search">
  140. {# <label for="search_input">Search» </label> #}
  141. <span><input title='{{- search_tooltip -}}' class="submit" type="submit" value="Search" /></span>
  142. <span><input pattern=".{0{{- config.tagblog.search.minlength -}},}" required title="{{- config.tagblog.search.minlength }} characters minimum" type="text" id="search_input" name="q" /></span>
  143. <input id="titlesonly" type="checkbox" name="titlesonly" />
  144. <label for="titlesonly">Titles only</label>
  145. </form>
  146. {%- endif -%}
  147. {%- if config.tagblog.feed.enabled -%}
  148. <div class="rss paragraph"><a href="{{- base_url -}}/feed">RSS Feed</a></div>
  149. {%- endif -%}
  150. {%- include 'includes/sidebar-bottom.twig' ignore missing -%}
  151. </div>
  152. <div class="desktop-device"><hr></div>
  153. <div class="desktop-device back_up"><a href="#">{{ config.tagblog.home|default('Top') }}</a></div>
  154. </nav>
  155. </section>
  156. <section class="content">
  157. {%- block content -%}
  158. {%- set count = tbpages|length -%}
  159. <h3>All Articles ({{- count -}})</h3>
  160. {%- set paging_url_base = current_page.url ~ '?' -%}
  161. {%- set paging_array = tbpages -%}
  162. {%- include 'includes/paging.twig' -%}
  163. {%- endblock -%}
  164. </section>
  165. </div>
  166. <footer>
  167. {%- include 'includes/footer.twig' ignore missing -%}
  168. </footer>
  169. </body>
  170. <!-- made with https://{notabug,framagit}.org/ohnonot/tagblog -->
  171. </html>