A new Riff-radio.org site with a static approach.

post_helper.tmpl.py 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. # -*- coding:utf-8 -*-
  2. from mako import runtime, filters, cache
  3. UNDEFINED = runtime.UNDEFINED
  4. STOP_RENDERING = runtime.STOP_RENDERING
  5. __M_dict_builtin = dict
  6. __M_locals_builtin = locals
  7. _magic_number = 10
  8. _modified_time = 1676236796.0826142
  9. _enable_loop = True
  10. _template_filename = '/home/thomas/.local/lib/python3.9/site-packages/nikola/data/themes/base/templates/post_helper.tmpl'
  11. _template_uri = 'post_helper.tmpl'
  12. _source_encoding = 'utf-8'
  13. _exports = ['meta_translations', 'html_tags', 'html_pager', 'open_graph_metadata', 'twitter_card_information', 'mathjax_script']
  14. def _mako_get_namespace(context, name):
  15. try:
  16. return context.namespaces[(__name__, name)]
  17. except KeyError:
  18. _mako_generate_namespaces(context)
  19. return context.namespaces[(__name__, name)]
  20. def _mako_generate_namespaces(context):
  21. ns = runtime.TemplateNamespace('math', context._clean_inheritance_tokens(), templateuri='math_helper.tmpl', callables=None, calling_uri=_template_uri)
  22. context.namespaces[(__name__, 'math')] = ns
  23. def render_body(context,**pageargs):
  24. __M_caller = context.caller_stack._push_frame()
  25. try:
  26. __M_locals = __M_dict_builtin(pageargs=pageargs)
  27. __M_writer = context.writer()
  28. __M_writer('\n\n')
  29. __M_writer('\n\n')
  30. __M_writer('\n\n')
  31. __M_writer('\n\n')
  32. __M_writer('\n\n')
  33. __M_writer('\n\n')
  34. __M_writer('\n')
  35. return ''
  36. finally:
  37. context.caller_stack._pop_frame()
  38. def render_meta_translations(context,post):
  39. __M_caller = context.caller_stack._push_frame()
  40. try:
  41. lang = context.get('lang', UNDEFINED)
  42. len = context.get('len', UNDEFINED)
  43. translations = context.get('translations', UNDEFINED)
  44. sorted = context.get('sorted', UNDEFINED)
  45. __M_writer = context.writer()
  46. __M_writer('\n')
  47. if len(translations) > 1:
  48. for langname in sorted(translations):
  49. if langname != lang and ((not post.skip_untranslated) or post.is_translation_available(langname)):
  50. __M_writer(' <link rel="alternate" hreflang="')
  51. __M_writer(str(langname))
  52. __M_writer('" href="')
  53. __M_writer(str(post.permalink(langname)))
  54. __M_writer('">\n')
  55. return ''
  56. finally:
  57. context.caller_stack._pop_frame()
  58. def render_html_tags(context,post):
  59. __M_caller = context.caller_stack._push_frame()
  60. try:
  61. hidden_tags = context.get('hidden_tags', UNDEFINED)
  62. _link = context.get('_link', UNDEFINED)
  63. __M_writer = context.writer()
  64. __M_writer('\n')
  65. if post.tags:
  66. __M_writer(' <ul itemprop="keywords" class="tags">\n')
  67. for tag in post.tags:
  68. if tag not in hidden_tags:
  69. __M_writer(' <li><a class="tag p-category" href="')
  70. __M_writer(str(_link('tag', tag)))
  71. __M_writer('" rel="tag">')
  72. __M_writer(filters.html_escape(str(tag)))
  73. __M_writer('</a></li>\n')
  74. __M_writer(' </ul>\n')
  75. return ''
  76. finally:
  77. context.caller_stack._pop_frame()
  78. def render_html_pager(context,post):
  79. __M_caller = context.caller_stack._push_frame()
  80. try:
  81. messages = context.get('messages', UNDEFINED)
  82. __M_writer = context.writer()
  83. __M_writer('\n')
  84. if post.prev_post or post.next_post:
  85. __M_writer(' <ul class="pager hidden-print">\n')
  86. if post.prev_post:
  87. __M_writer(' <li class="previous">\n <a href="')
  88. __M_writer(str(post.prev_post.permalink()))
  89. __M_writer('" rel="prev" title="')
  90. __M_writer(filters.html_escape(str(post.prev_post.title())))
  91. __M_writer('">')
  92. __M_writer(str(messages("Previous post")))
  93. __M_writer('</a>\n </li>\n')
  94. if post.next_post:
  95. __M_writer(' <li class="next">\n <a href="')
  96. __M_writer(str(post.next_post.permalink()))
  97. __M_writer('" rel="next" title="')
  98. __M_writer(filters.html_escape(str(post.next_post.title())))
  99. __M_writer('">')
  100. __M_writer(str(messages("Next post")))
  101. __M_writer('</a>\n </li>\n')
  102. __M_writer(' </ul>\n')
  103. return ''
  104. finally:
  105. context.caller_stack._pop_frame()
  106. def render_open_graph_metadata(context,post):
  107. __M_caller = context.caller_stack._push_frame()
  108. try:
  109. url_replacer = context.get('url_replacer', UNDEFINED)
  110. permalink = context.get('permalink', UNDEFINED)
  111. blog_title = context.get('blog_title', UNDEFINED)
  112. abs_link = context.get('abs_link', UNDEFINED)
  113. lang = context.get('lang', UNDEFINED)
  114. __M_writer = context.writer()
  115. __M_writer('\n<meta property="og:site_name" content="')
  116. __M_writer(filters.html_escape(str(blog_title)))
  117. __M_writer('">\n<meta property="og:title" content="')
  118. __M_writer(filters.html_escape(str(post.title()[:70])))
  119. __M_writer('">\n<meta property="og:url" content="')
  120. __M_writer(str(abs_link(permalink)))
  121. __M_writer('">\n')
  122. if post.description():
  123. __M_writer(' <meta property="og:description" content="')
  124. __M_writer(filters.html_escape(str(post.description()[:200])))
  125. __M_writer('">\n')
  126. else:
  127. __M_writer(' <meta property="og:description" content="')
  128. __M_writer(filters.html_escape(str(post.text(strip_html=True)[:200])))
  129. __M_writer('">\n')
  130. if post.previewimage:
  131. __M_writer(' <meta property="og:image" content="')
  132. __M_writer(str(url_replacer(permalink, post.previewimage, lang, 'absolute')))
  133. __M_writer('">\n')
  134. __M_writer('<meta property="og:type" content="article">\n')
  135. if post.date.isoformat():
  136. __M_writer(' <meta property="article:published_time" content="')
  137. __M_writer(str(post.formatted_date('webiso')))
  138. __M_writer('">\n')
  139. if post.tags:
  140. for tag in post.tags:
  141. __M_writer(' <meta property="article:tag" content="')
  142. __M_writer(filters.html_escape(str(tag)))
  143. __M_writer('">\n')
  144. return ''
  145. finally:
  146. context.caller_stack._pop_frame()
  147. def render_twitter_card_information(context,post):
  148. __M_caller = context.caller_stack._push_frame()
  149. try:
  150. twitter_card = context.get('twitter_card', UNDEFINED)
  151. __M_writer = context.writer()
  152. __M_writer('\n')
  153. if twitter_card and twitter_card['use_twitter_cards']:
  154. __M_writer(' <meta name="twitter:card" content="')
  155. __M_writer(filters.html_escape(str(twitter_card.get('card', 'summary'))))
  156. __M_writer('">\n')
  157. if 'site:id' in twitter_card:
  158. __M_writer(' <meta name="twitter:site:id" content="')
  159. __M_writer(str(twitter_card['site:id']))
  160. __M_writer('">\n')
  161. elif 'site' in twitter_card:
  162. __M_writer(' <meta name="twitter:site" content="')
  163. __M_writer(str(twitter_card['site']))
  164. __M_writer('">\n')
  165. if 'creator:id' in twitter_card:
  166. __M_writer(' <meta name="twitter:creator:id" content="')
  167. __M_writer(str(twitter_card['creator:id']))
  168. __M_writer('">\n')
  169. elif 'creator' in twitter_card:
  170. __M_writer(' <meta name="twitter:creator" content="')
  171. __M_writer(str(twitter_card['creator']))
  172. __M_writer('">\n')
  173. return ''
  174. finally:
  175. context.caller_stack._pop_frame()
  176. def render_mathjax_script(context,post):
  177. __M_caller = context.caller_stack._push_frame()
  178. try:
  179. math = _mako_get_namespace(context, 'math')
  180. __M_writer = context.writer()
  181. __M_writer('\n ')
  182. __M_writer(str(math.math_scripts_ifpost(post)))
  183. __M_writer('\n')
  184. return ''
  185. finally:
  186. context.caller_stack._pop_frame()
  187. """
  188. __M_BEGIN_METADATA
  189. {"filename": "/home/thomas/.local/lib/python3.9/site-packages/nikola/data/themes/base/templates/post_helper.tmpl", "uri": "post_helper.tmpl", "source_encoding": "utf-8", "line_map": {"23": 2, "26": 0, "31": 2, "32": 12, "33": 24, "34": 41, "35": 68, "36": 84, "37": 89, "43": 4, "51": 4, "52": 5, "53": 6, "54": 7, "55": 8, "56": 8, "57": 8, "58": 8, "59": 8, "65": 14, "71": 14, "72": 15, "73": 16, "74": 17, "75": 18, "76": 19, "77": 19, "78": 19, "79": 19, "80": 19, "81": 22, "87": 26, "92": 26, "93": 27, "94": 28, "95": 29, "96": 30, "97": 31, "98": 31, "99": 31, "100": 31, "101": 31, "102": 31, "103": 34, "104": 35, "105": 36, "106": 36, "107": 36, "108": 36, "109": 36, "110": 36, "111": 39, "117": 43, "126": 43, "127": 44, "128": 44, "129": 45, "130": 45, "131": 46, "132": 46, "133": 47, "134": 48, "135": 48, "136": 48, "137": 49, "138": 50, "139": 50, "140": 50, "141": 52, "142": 53, "143": 53, "144": 53, "145": 55, "146": 60, "147": 61, "148": 61, "149": 61, "150": 63, "151": 64, "152": 65, "153": 65, "154": 65, "160": 70, "165": 70, "166": 71, "167": 72, "168": 72, "169": 72, "170": 73, "171": 74, "172": 74, "173": 74, "174": 75, "175": 76, "176": 76, "177": 76, "178": 78, "179": 79, "180": 79, "181": 79, "182": 80, "183": 81, "184": 81, "185": 81, "191": 87, "196": 87, "197": 88, "198": 88, "204": 198}}
  190. __M_END_METADATA
  191. """