diff options
| author | 2021-02-03 19:17:00 -0500 | |
|---|---|---|
| committer | 2021-02-03 19:17:00 -0500 | |
| commit | 3a0d66f07b112b6d2bdc2b57bbf717a89a351ce6 (patch) | |
| tree | a7cf56282e54f05785243bc1e903d6594f2c06ba /nikola/data/themes/base/templates | |
| parent | 787b97a4cb24330b36f11297c6d3a7a473a907d0 (diff) | |
New upstream version 8.1.2.upstream/8.1.2
Diffstat (limited to 'nikola/data/themes/base/templates')
41 files changed, 717 insertions, 300 deletions
diff --git a/nikola/data/themes/base/templates/archive.tmpl b/nikola/data/themes/base/templates/archive.tmpl new file mode 100644 index 0000000..d6f107c --- /dev/null +++ b/nikola/data/themes/base/templates/archive.tmpl @@ -0,0 +1 @@ +<%inherit file="list_post.tmpl"/> diff --git a/nikola/data/themes/base/templates/archive_navigation_helper.tmpl b/nikola/data/themes/base/templates/archive_navigation_helper.tmpl new file mode 100644 index 0000000..506629f --- /dev/null +++ b/nikola/data/themes/base/templates/archive_navigation_helper.tmpl @@ -0,0 +1,27 @@ +## -*- coding: utf-8 -*- + +<%def name="archive_navigation()"> +%if 'archive_page' in pagekind: + %if has_archive_navigation: + <nav class="archivenav"> + <ul class="pager"> + %if previous_archive: + <li class="previous"><a href="${previous_archive}" rel="prev">${messages("Previous")}</a></li> + %else: + <li class="previous disabled"><a href="#" rel="prev">${messages("Previous")}</a></li> + % endif + %if up_archive: + <li class="up"><a href="${up_archive}" rel="up">${messages("Up")}</a></li> + %else: + <li class="up disabled"><a href="#" rel="up">${messages("Up")}</a></li> + %endif + %if next_archive: + <li class="next"><a href="${next_archive}" rel="next">${messages("Next")}</a></li> + %else: + <li class="next disabled"><a href="#" rel="next">${messages("Next")}</a></li> + %endif + </ul> + </nav> + %endif +% endif +</%def> diff --git a/nikola/data/themes/base/templates/archiveindex.tmpl b/nikola/data/themes/base/templates/archiveindex.tmpl index 8c58f13..eb4dd27 100644 --- a/nikola/data/themes/base/templates/archiveindex.tmpl +++ b/nikola/data/themes/base/templates/archiveindex.tmpl @@ -1,13 +1,20 @@ ## -*- coding: utf-8 -*- <%inherit file="index.tmpl"/> +<%namespace name="archive_nav" file="archive_navigation_helper.tmpl" import="*"/> +<%namespace name="feeds_translations" file="feeds_translations_helper.tmpl" import="*"/> <%block name="extra_head"> ${parent.extra_head()} - %if len(translations) > 1 and generate_atom: - %for language in sorted(translations): - <link rel="alternate" type="application/atom+xml" title="Atom for the ${archive_name} section (${language})" href="${_link("archive_atom", archive_name, language)}"> - %endfor - %elif generate_atom: - <link rel="alternate" type="application/atom+xml" title="Atom for the ${archive_name} archive" href="${_link("archive_atom", archive_name)}"> - %endif + ${feeds_translations.head(archive_name, kind, rss_override=False)} +</%block> + +<%block name="content_header"> + <header> + <h1>${title|h}</h1> + ${archive_nav.archive_navigation()} + <div class="metadata"> + ${feeds_translations.feed_link(archive, kind)} + ${feeds_translations.translation_link(kind)} + </div> + </header> </%block> diff --git a/nikola/data/themes/base/templates/author.tmpl b/nikola/data/themes/base/templates/author.tmpl new file mode 100644 index 0000000..983f118 --- /dev/null +++ b/nikola/data/themes/base/templates/author.tmpl @@ -0,0 +1,28 @@ +## -*- coding: utf-8 -*- +<%inherit file="list_post.tmpl"/> +<%namespace name="feeds_translations" file="feeds_translations_helper.tmpl" import="*"/> + +<%block name="extra_head"> + ${feeds_translations.head(author, kind, rss_override=False)} +</%block> + +<%block name="content"> +<article class="authorpage"> + <header> + <h1>${title|h}</h1> + %if description: + <p>${description}</p> + %endif + <div class="metadata"> + ${feeds_translations.feed_link(author, kind)} + </div> + </header> + %if posts: + <ul class="postlist"> + % for post in posts: + <li><time class="listdate" datetime="${post.formatted_date('webiso')}" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time> <a href="${post.permalink()}" class="listtitle">${post.title()|h}</a></li> + % endfor + </ul> + %endif +</article> +</%block> diff --git a/nikola/data/themes/base/templates/authorindex.tmpl b/nikola/data/themes/base/templates/authorindex.tmpl new file mode 100644 index 0000000..fe9d39e --- /dev/null +++ b/nikola/data/themes/base/templates/authorindex.tmpl @@ -0,0 +1,21 @@ +## -*- coding: utf-8 -*- +<%inherit file="index.tmpl"/> +<%namespace name="feeds_translations" file="feeds_translations_helper.tmpl" import="*"/> + +<%block name="content_header"> + <header> + <h1>${title|h}</h1> + %if description: + <p>${description}</p> + %endif + <div class="metadata"> + ${feeds_translations.feed_link(author, kind)} + ${feeds_translations.translation_link(kind)} + </div> + </header> +</%block> + +<%block name="extra_head"> + ${parent.extra_head()} + ${feeds_translations.head(author, kind, rss_override=False)} +</%block> diff --git a/nikola/data/themes/base/templates/authors.tmpl b/nikola/data/themes/base/templates/authors.tmpl new file mode 100644 index 0000000..8503bd4 --- /dev/null +++ b/nikola/data/themes/base/templates/authors.tmpl @@ -0,0 +1,25 @@ +## -*- coding: utf-8 -*- +<%inherit file="base.tmpl"/> +<%namespace name="feeds_translations" file="feeds_translations_helper.tmpl" import="*"/> + +<%block name="extra_head"> + ${feeds_translations.head(kind=kind, feeds=False)} +</%block> + +<%block name="content"> +<article class="authorindex"> + %if items: + <h2>${messages("Authors")}</h2> + <div class="metadata"> + ${feeds_translations.translation_link(kind)} + </div> + <ul class="postlist"> + % for text, link in items: + % if text not in hidden_authors: + <li><a class="reference listtitle" href="${link}">${text|h}</a></li> + % endif + % endfor + </ul> + %endif +</article> +</%block> diff --git a/nikola/data/themes/base/templates/base.tmpl b/nikola/data/themes/base/templates/base.tmpl index 2b0cbfd..f071c95 100644 --- a/nikola/data/themes/base/templates/base.tmpl +++ b/nikola/data/themes/base/templates/base.tmpl @@ -2,8 +2,8 @@ <%namespace name="base" file="base_helper.tmpl" import="*"/> <%namespace name="header" file="base_header.tmpl" import="*"/> <%namespace name="footer" file="base_footer.tmpl" import="*"/> -<%namespace name="annotations" file="annotation_helper.tmpl"/> ${set_locale(lang)} +### <html> tag is included by base.html_headstart ${base.html_headstart()} <%block name="extra_head"> ### Leave this block alone. @@ -11,16 +11,29 @@ ${base.html_headstart()} ${template_hooks['extra_head']()} </head> <body> -<a href="#content" class="sr-only sr-only-focusable">${messages("Skip to main content")}</a> + <a href="#content" class="sr-only sr-only-focusable">${messages("Skip to main content")}</a> <div id="container"> - ${header.html_header()} - <main id="content"> + ${header.html_header()} + <main id="content"> <%block name="content"></%block> - </main> - ${footer.html_footer()} + </main> + ${footer.html_footer()} </div> ${base.late_load_js()} + % if date_fanciness != 0: + <!-- fancy dates --> + <script> + luxon.Settings.defaultLocale = "${luxon_locales[lang]}"; + fancydates(${date_fanciness}, ${luxon_date_format}); + </script> + <!-- end fancy dates --> + % endif <%block name="extra_js"></%block> + <script> + baguetteBox.run('div#content', { + ignoreClass: 'islink', + captions: function(element){var i=element.getElementsByTagName('img')[0];return i===undefined?'':i.alt;}}); + </script> ${body_end} ${template_hooks['body_end']()} </body> diff --git a/nikola/data/themes/base/templates/base_footer.tmpl b/nikola/data/themes/base/templates/base_footer.tmpl index cd41d37..7e44c75 100644 --- a/nikola/data/themes/base/templates/base_footer.tmpl +++ b/nikola/data/themes/base/templates/base_footer.tmpl @@ -1,5 +1,4 @@ ## -*- coding: utf-8 -*- -<%namespace name="base" file="base_helper.tmpl" import="*"/> <%def name="html_footer()"> %if content_footer: diff --git a/nikola/data/themes/base/templates/base_header.tmpl b/nikola/data/themes/base/templates/base_header.tmpl index e29e2b3..b45744a 100644 --- a/nikola/data/themes/base/templates/base_header.tmpl +++ b/nikola/data/themes/base/templates/base_header.tmpl @@ -16,13 +16,13 @@ </%def> <%def name="html_site_title()"> - <h1 id="brand"><a href="${abs_link(_link("root", None, lang))}" title="${blog_title}" rel="home"> + <h1 id="brand"><a href="${_link("root", None, lang)}" title="${blog_title|h}" rel="home"> %if logo_url: - <img src="${logo_url}" alt="${blog_title}" id="logo"> + <img src="${logo_url}" alt="${blog_title|h}" id="logo"> %endif % if show_blog_title: - <span id="blog-title">${blog_title}</span> + <span id="blog-title">${blog_title|h}</span> % endif </a></h1> </%def> @@ -30,13 +30,22 @@ <%def name="html_navigation_links()"> <nav id="menu"> <ul> - %for url, text in navigation_links[lang]: + ${html_navigation_links_entries(navigation_links)} + ${html_navigation_links_entries(navigation_alt_links)} + ${template_hooks['menu']()} + ${template_hooks['menu_alt']()} + </ul> + </nav> +</%def> + +<%def name="html_navigation_links_entries(navigation_links_source)"> + %for url, text in navigation_links_source[lang]: % if isinstance(url, tuple): <li> ${text} <ul> %for suburl, text in url: % if rel_link(permalink, suburl) == "#": - <li class="active"><a href="${permalink}">${text} <span class="sr-only">${messages("(active)", lang)}</span></a></li> + <li class="active"><a href="${permalink}">${text}<span class="sr-only"> ${messages("(active)", lang)}</span></a></li> %else: <li><a href="${suburl}">${text}</a></li> %endif @@ -44,16 +53,12 @@ </ul> % else: % if rel_link(permalink, url) == "#": - <li class="active"><a href="${permalink}">${text} <span class="sr-only">${messages("(active)", lang)}</span></a></li> + <li class="active"><a href="${permalink}">${text}<span class="sr-only"> ${messages("(active)", lang)}</span></a></li> %else: <li><a href="${url}">${text}</a></li> %endif % endif %endfor - ${template_hooks['menu']()} - ${template_hooks['menu_alt']()} - </ul> - </nav> </%def> <%def name="html_translation_header()"> diff --git a/nikola/data/themes/base/templates/base_helper.tmpl b/nikola/data/themes/base/templates/base_helper.tmpl index 948cfba..18801ed 100644 --- a/nikola/data/themes/base/templates/base_helper.tmpl +++ b/nikola/data/themes/base/templates/base_helper.tmpl @@ -1,29 +1,25 @@ ## -*- coding: utf-8 -*- +<%namespace name="feeds_translations" file="feeds_translations_helper.tmpl" import="*"/> <%def name="html_headstart()"> <!DOCTYPE html> <html \ -prefix='\ -%if use_open_graph or (twitter_card and twitter_card['use_twitter_cards']): -og: http://ogp.me/ns# article: http://ogp.me/ns/article# \ -%endif -%if comment_system == 'facebook': -fb: http://ogp.me/ns/fb# -%endif -' \ -%if use_open_graph or (twitter_card and twitter_card['use_twitter_cards']): -vocab="http://ogp.me/ns" \ -%endif + prefix='\ + og: http://ogp.me/ns# article: http://ogp.me/ns/article# \ + %if comment_system == 'facebook': + fb: http://ogp.me/ns/fb# \ + %endif + ' \ + vocab="http://ogp.me/ns" \ % if is_rtl: -dir="rtl" \ + dir="rtl" \ % endif \ lang="${lang}"> <head> <meta charset="utf-8"> - <base href="${abs_link(permalink)}"> %if description: - <meta name="description" content="${description}"> + <meta name="description" content="${description|h}"> %endif <meta name="viewport" content="width=device-width"> %if title == blog_title: @@ -33,7 +29,11 @@ lang="${lang}"> %endif ${html_stylesheets()} - ${html_feedlinks()} + <meta name="theme-color" content="${theme_color}"> + % if meta_generator_tag: + <meta name="generator" content="Nikola (getnikola.com)"> + % endif + ${feeds_translations.head(classification=None, kind='index', other=False)} <link rel="canonical" href="${abs_link(permalink)}"> %if favicons: @@ -53,29 +53,58 @@ lang="${lang}"> <link rel="next" href="${nextlink}" type="text/html"> %endif - ${mathjax_config} %if use_cdn: - <!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]--> + <!--[if lt IE 9]><script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script><![endif]--> %else: - <!--[if lt IE 9]><script src="${url_replacer(permalink, '/assets/js/html5.js', lang)}"></script><![endif]--> + <!--[if lt IE 9]><script src="${url_replacer(permalink, '/assets/js/html5shiv-printshiv.min.js', lang, url_type)}"></script><![endif]--> %endif ${extra_head_data} </%def> <%def name="late_load_js()"> + % if use_bundles: + % if use_cdn: + <script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.11.1/baguetteBox.min.js" integrity="sha256-ULQV01VS9LCI2ePpLsmka+W0mawFpEA0rtxnezUj4A4=" crossorigin="anonymous"></script> + <script src="/assets/js/all.js"></script> + % else: + <script src="/assets/js/all-nocdn.js"></script> + % endif + % else: + % if use_cdn: + <script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.11.1/baguetteBox.min.js" integrity="sha256-ULQV01VS9LCI2ePpLsmka+W0mawFpEA0rtxnezUj4A4=" crossorigin="anonymous"></script> + % else: + <script src="/assets/js/baguetteBox.min.js"></script> + % endif + % endif + % if date_fanciness != 0: + % if date_fanciness == 2: + <script src="https://polyfill.io/v3/polyfill.js?features=Intl.RelativeTimeFormat.%7Elocale.${luxon_locales[lang]}"></script> + % endif + % if use_cdn: + <script src="https://cdn.jsdelivr.net/npm/luxon@1.25.0/build/global/luxon.min.js" integrity="sha256-OVk2fwTRcXYlVFxr/ECXsakqelJbOg5WCj1dXSIb+nU=" crossorigin="anonymous"></script> + % else: + <script src="/assets/js/luxon.min.js"></script> + % endif + % if not use_bundles: + <script src="/assets/js/fancydates.min.js"></script> + % endif + % endif ${social_buttons_code} </%def> <%def name="html_stylesheets()"> %if use_bundles: %if use_cdn: + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.11.1/baguetteBox.min.css" integrity="sha256-cLMYWYYutHkt+KpNqjg7NVkYSQ+E2VbrXsEvOqU7mL0=" crossorigin="anonymous"> <link href="/assets/css/all.css" rel="stylesheet" type="text/css"> %else: <link href="/assets/css/all-nocdn.css" rel="stylesheet" type="text/css"> %endif %else: - <link href="/assets/css/rst.css" rel="stylesheet" type="text/css"> + <link href="/assets/css/baguetteBox.min.css" rel="stylesheet" type="text/css"> + <link href="/assets/css/rst_base.css" rel="stylesheet" type="text/css"> + <link href="/assets/css/nikola_rst.css" rel="stylesheet" type="text/css"> <link href="/assets/css/code.css" rel="stylesheet" type="text/css"> <link href="/assets/css/theme.css" rel="stylesheet" type="text/css"> %if has_custom_css: @@ -88,34 +117,16 @@ lang="${lang}"> % endif </%def> +### This function is deprecated; use feed_helper directly. <%def name="html_feedlinks()"> - %if rss_link: - ${rss_link} - %elif generate_rss: - %if len(translations) > 1: - %for language in sorted(translations): - <link rel="alternate" type="application/rss+xml" title="RSS (${language})" href="${_link('rss', None, language)}"> - %endfor - %else: - <link rel="alternate" type="application/rss+xml" title="RSS" href="${_link('rss', None)}"> - %endif - %endif - %if generate_atom: - %if len(translations) > 1: - %for language in sorted(translations): - <link rel="alternate" type="application/atom+xml" title="Atom (${language})" href="${_link('index_atom', None, language)}"> - %endfor - %else: - <link rel="alternate" type="application/atom+xml" title="Atom" href="${_link('index_atom', None)}"> - %endif - %endif + ${feeds_translations.head(classification=None, kind='index', other=False)} </%def> <%def name="html_translations()"> <ul class="translations"> %for langname in sorted(translations): %if langname != lang: - <li><a href="${abs_link(_link("root", None, langname))}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li> + <li><a href="${_link("root", None, langname)}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li> %endif %endfor </ul> diff --git a/nikola/data/themes/base/templates/comments_helper.tmpl b/nikola/data/themes/base/templates/comments_helper.tmpl index 1459888..002499e 100644 --- a/nikola/data/themes/base/templates/comments_helper.tmpl +++ b/nikola/data/themes/base/templates/comments_helper.tmpl @@ -1,63 +1,63 @@ ## -*- coding: utf-8 -*- <%namespace name="disqus" file="comments_helper_disqus.tmpl"/> -<%namespace name="livefyre" file="comments_helper_livefyre.tmpl"/> <%namespace name="intensedebate" file="comments_helper_intensedebate.tmpl"/> <%namespace name="muut" file="comments_helper_muut.tmpl"/> -<%namespace name="googleplus" file="comments_helper_googleplus.tmpl"/> <%namespace name="facebook" file="comments_helper_facebook.tmpl"/> <%namespace name="isso" file="comments_helper_isso.tmpl"/> +<%namespace name="commento" file="comments_helper_commento.tmpl"/> +<%namespace name="utterances" file="comments_helper_utterances.tmpl"/> <%def name="comment_form(url, title, identifier)"> %if comment_system == 'disqus': ${disqus.comment_form(url, title, identifier)} - % elif comment_system == 'livefyre': - ${livefyre.comment_form(url, title, identifier)} % elif comment_system == 'intensedebate': ${intensedebate.comment_form(url, title, identifier)} % elif comment_system == 'muut': ${muut.comment_form(url, title, identifier)} - % elif comment_system == 'googleplus': - ${googleplus.comment_form(url, title, identifier)} % elif comment_system == 'facebook': ${facebook.comment_form(url, title, identifier)} % elif comment_system == 'isso': ${isso.comment_form(url, title, identifier)} + % elif comment_system == 'commento': + ${commento.comment_form(url, title, identifier)} + % elif comment_system == 'utterances': + ${utterances.comment_form(url, title, identifier)} %endif </%def> <%def name="comment_link(link, identifier)"> %if comment_system == 'disqus': ${disqus.comment_link(link, identifier)} - % elif comment_system == 'livefyre': - ${livefyre.comment_link(link, identifier)} % elif comment_system == 'intensedebate': ${intensedebate.comment_link(link, identifier)} % elif comment_system == 'muut': ${muut.comment_link(link, identifier)} - % elif comment_system == 'googleplus': - ${googleplus.comment_link(link, identifier)} % elif comment_system == 'facebook': ${facebook.comment_link(link, identifier)} % elif comment_system == 'isso': ${isso.comment_link(link, identifier)} + % elif comment_system == 'commento': + ${commento.comment_link(link, identifier)} + % elif comment_system == 'utterances': + ${utterances.comment_link(link, identifier)} %endif </%def> <%def name="comment_link_script()"> %if comment_system == 'disqus': ${disqus.comment_link_script()} - % elif comment_system == 'livefyre': - ${livefyre.comment_link_script()} % elif comment_system == 'intensedebate': ${intensedebate.comment_link_script()} % elif comment_system == 'muut': ${muut.comment_link_script()} - % elif comment_system == 'googleplus': - ${googleplus.comment_link_script()} % elif comment_system == 'facebook': ${facebook.comment_link_script()} % elif comment_system == 'isso': ${isso.comment_link_script()} + % elif comment_system == 'commento': + ${commento.comment_link_script()} + % elif comment_system == 'utterances': + ${utterances.comment_link_script()} %endif </%def> diff --git a/nikola/data/themes/base/templates/comments_helper_commento.tmpl b/nikola/data/themes/base/templates/comments_helper_commento.tmpl new file mode 100644 index 0000000..793a6d4 --- /dev/null +++ b/nikola/data/themes/base/templates/comments_helper_commento.tmpl @@ -0,0 +1,13 @@ +## -*- coding: utf-8 -*- +<%def name="comment_form(url, title, identifier)"> + <div id="commento"></div> + + <script defer src="${comment_system_id}/js/commento.js"></script> +</%def> + +<%def name="comment_link(link, identifier)"> + <a href="${link}#commento">${messages("Comments")}</a> +</%def> + +<%def name="comment_link_script()"> +</%def> diff --git a/nikola/data/themes/base/templates/comments_helper_disqus.tmpl b/nikola/data/themes/base/templates/comments_helper_disqus.tmpl index 6dd423c..f17777c 100644 --- a/nikola/data/themes/base/templates/comments_helper_disqus.tmpl +++ b/nikola/data/themes/base/templates/comments_helper_disqus.tmpl @@ -21,24 +21,24 @@ }; (function() { var dsq = document.createElement('script'); dsq.async = true; - dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; + dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); </script> - <noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript> - <a href="//disqus.com" class="dsq-brlink" rel="nofollow">Comments powered by <span class="logo-disqus">Disqus</span></a> + <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript> + <a href="https://disqus.com" class="dsq-brlink" rel="nofollow">Comments powered by <span class="logo-disqus">Disqus</span></a> %endif </%def> <%def name="comment_link(link, identifier)"> %if comment_system_id: - <a href="${link}#disqus_thread" data-disqus-identifier="${identifier}">Comments</a> + <a href="${link}#disqus_thread" data-disqus-identifier="${identifier}">${messages("Comments")}</a> %endif </%def> <%def name="comment_link_script()"> %if comment_system_id: - <script>var disqus_shortname="${comment_system_id}";(function(){var a=document.createElement("script");a.async=true;a.src="//"+disqus_shortname+".disqus.com/count.js";(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(a)}());</script> + <script>var disqus_shortname="${comment_system_id}";(function(){var a=document.createElement("script");a.async=true;a.src="https://"+disqus_shortname+".disqus.com/count.js";(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(a)}());</script> %endif </%def> diff --git a/nikola/data/themes/base/templates/comments_helper_facebook.tmpl b/nikola/data/themes/base/templates/comments_helper_facebook.tmpl index d6059a1..815f489 100644 --- a/nikola/data/themes/base/templates/comments_helper_facebook.tmpl +++ b/nikola/data/themes/base/templates/comments_helper_facebook.tmpl @@ -17,7 +17,7 @@ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; - js.src = "//connect.facebook.net/en_US/all.js"; + js.src = "https://connect.facebook.net/en_US/all.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> @@ -55,7 +55,7 @@ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; - js.src = "//connect.facebook.net/en_US/all.js"; + js.src = "https://connect.facebook.net/en_US/all.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> diff --git a/nikola/data/themes/base/templates/comments_helper_googleplus.tmpl b/nikola/data/themes/base/templates/comments_helper_googleplus.tmpl deleted file mode 100644 index 5a5c4d7..0000000 --- a/nikola/data/themes/base/templates/comments_helper_googleplus.tmpl +++ /dev/null @@ -1,17 +0,0 @@ -## -*- coding: utf-8 -*- -<%def name="comment_form(url, title, identifier)"> -<script src="https://apis.google.com/js/plusone.js"></script> -<div class="g-comments" - data-href="${url}" - data-first_party_property="BLOGGER" - data-view_type="FILTERED_POSTMOD"> -</div> -</%def> - -<%def name="comment_link(link, identifier)"> -<div class="g-commentcount" data-href="${link}"></div> -<script src="https://apis.google.com/js/plusone.js"></script> -</%def> - -<%def name="comment_link_script()"> -</%def> diff --git a/nikola/data/themes/base/templates/comments_helper_intensedebate.tmpl b/nikola/data/themes/base/templates/comments_helper_intensedebate.tmpl index c47b6c7..0a51328 100644 --- a/nikola/data/themes/base/templates/comments_helper_intensedebate.tmpl +++ b/nikola/data/themes/base/templates/comments_helper_intensedebate.tmpl @@ -6,7 +6,7 @@ var idcomments_post_id = "${identifier}"; var idcomments_post_url = "${url}"; </script> <span id="IDCommentsPostTitle" style="display:none"></span> -<script src='http://www.intensedebate.com/js/genericCommentWrapperV2.js'></script> +<script src="https://www.intensedebate.com/js/genericCommentWrapperV2.js"></script> </script> </%def> @@ -17,7 +17,7 @@ var idcomments_acct = '${comment_system_id}'; var idcomments_post_id = "${identifier}"; var idcomments_post_url = "${link}"; </script> -<script src="http://www.intensedebate.com/js/genericLinkWrapperV2.js"></script> +<script src="https://www.intensedebate.com/js/genericLinkWrapperV2.js"></script> </a> </%def> diff --git a/nikola/data/themes/base/templates/comments_helper_isso.tmpl b/nikola/data/themes/base/templates/comments_helper_isso.tmpl index 8dc95f5..c733bbe 100644 --- a/nikola/data/themes/base/templates/comments_helper_isso.tmpl +++ b/nikola/data/themes/base/templates/comments_helper_isso.tmpl @@ -1,20 +1,26 @@ ## -*- coding: utf-8 -*- <%def name="comment_form(url, title, identifier)"> %if comment_system_id: - <div data-title="${title|u}" id="isso-thread"></div> - <script src="${comment_system_id}js/embed.min.js" data-isso="${comment_system_id}"></script> + <div data-title="${title|h}" id="isso-thread"></div> + <script src="${comment_system_id}js/embed.min.js" data-isso="${comment_system_id}" data-isso-lang="${lang}" + % if isso_config: + % for k, v in isso_config.items(): + data-isso-${k}="${v}" + % endfor + % endif + ></script> %endif </%def> <%def name="comment_link(link, identifier)"> %if comment_system_id: - <a href="${link}#isso-thread">Comments</a> + <a href="${link}#isso-thread">${messages("Comments")}</a> %endif </%def> <%def name="comment_link_script()"> - %if comment_system_id: - <script src="${comment_system_id}js/count.min.js" data-isso="${comment_system_id}"></script> + %if comment_system_id and 'index' in pagekind: + <script src="${comment_system_id}js/count.min.js" data-isso="${comment_system_id}" data-isso-lang="${lang}"></script> %endif </%def> diff --git a/nikola/data/themes/base/templates/comments_helper_livefyre.tmpl b/nikola/data/themes/base/templates/comments_helper_livefyre.tmpl deleted file mode 100644 index 68d99e5..0000000 --- a/nikola/data/themes/base/templates/comments_helper_livefyre.tmpl +++ /dev/null @@ -1,33 +0,0 @@ -## -*- coding: utf-8 -*- -<%def name="comment_form(url, title, identifier)"> -<div id="livefyre-comments"></div> -<script src="http://zor.livefyre.com/wjs/v3.0/javascripts/livefyre.js"></script> -<script> -(function () { - var articleId = "${identifier}"; - fyre.conv.load({}, [{ - el: 'livefyre-comments', - network: "livefyre.com", - siteId: "${comment_system_id}", - articleId: articleId, - signed: false, - collectionMeta: { - articleId: articleId, - url: fyre.conv.load.makeCollectionUrl(), - } - }], function() {}); -}()); -</script> -</%def> - -<%def name="comment_link(link, identifier)"> - <a href="${link}"> - <span class="livefyre-commentcount" data-lf-site-id="${comment_system_id}" data-lf-article-id="${identifier}"> - 0 Comments - </span> -</%def> - - -<%def name="comment_link_script()"> -<script src="http://zor.livefyre.com/wjs/v1.0/javascripts/CommentCount.js"></script> -</%def> diff --git a/nikola/data/themes/base/templates/comments_helper_mustache.tmpl b/nikola/data/themes/base/templates/comments_helper_mustache.tmpl deleted file mode 100644 index 593d0aa..0000000 --- a/nikola/data/themes/base/templates/comments_helper_mustache.tmpl +++ /dev/null @@ -1,5 +0,0 @@ -## -*- coding: utf-8 -*- -<%namespace name="comments" file="comments_helper.tmpl"/> -% if not post.meta('nocomments'): - ${comments.comment_form(post.permalink(absolute=True), post.title(), post.base_path)} -% endif diff --git a/nikola/data/themes/base/templates/comments_helper_muut.tmpl b/nikola/data/themes/base/templates/comments_helper_muut.tmpl index 94532d9..e5e7c05 100644 --- a/nikola/data/themes/base/templates/comments_helper_muut.tmpl +++ b/nikola/data/themes/base/templates/comments_helper_muut.tmpl @@ -9,5 +9,5 @@ <%def name="comment_link_script()"> -<script src="//cdn.muut.com/1/moot.min.js"></script> +<script src="https://cdn.muut.com/1/moot.min.js"></script> </%def> diff --git a/nikola/data/themes/base/templates/comments_helper_utterances.tmpl b/nikola/data/themes/base/templates/comments_helper_utterances.tmpl new file mode 100644 index 0000000..9b68917 --- /dev/null +++ b/nikola/data/themes/base/templates/comments_helper_utterances.tmpl @@ -0,0 +1,23 @@ +## -*- coding: utf-8 -*- +<%def name="comment_form(url, title, identifier)"> + %if comment_system_id: + <div data-title="${title|h}" id="utterances-thread"></div> + <script src="https://utteranc.es/client.js" repo="${comment_system_id}" + % if utterances_config: + % for k, v in utterances_config.items(): + ${k}="${v}" + % endfor + % endif + ></script> + %endif +</%def> + +<%def name="comment_link(link, identifier)"> + %if comment_system_id: + <a href="${link}#utterances-thread">${messages("Comments")}</a> + %endif +</%def> + + +<%def name="comment_link_script()"> +</%def> diff --git a/nikola/data/themes/base/templates/feeds_translations_helper.tmpl b/nikola/data/themes/base/templates/feeds_translations_helper.tmpl new file mode 100644 index 0000000..10e704d --- /dev/null +++ b/nikola/data/themes/base/templates/feeds_translations_helper.tmpl @@ -0,0 +1,124 @@ +## -*- coding: utf-8 -*- + +<%def name="_head_feed_link(link_type, link_name, link_postfix, classification, kind, language)"> + % if len(translations) > 1: + <link rel="alternate" type="${link_type}" title="${link_name|h} (${language})" hreflang="${language}" href="${_link(kind + '_' + link_postfix, classification, language)}"> + % else: + <link rel="alternate" type="${link_type}" title="${link_name|h}" hreflang="${language}" href="${_link(kind + '_' + link_postfix, classification, language)}"> + % endif +</%def> + +<%def name="_html_feed_link(link_type, link_name, link_postfix, classification, kind, language, name=None)"> + % if len(translations) > 1: + % if name and kind != "archive" and kind != "author": + <a href="${_link(kind + '_' + link_postfix, classification, language)}" hreflang="${language}" type="${link_type}">${messages(link_name, language)} (${name|h}, ${language})</a> + % else: + <a href="${_link(kind + '_' + link_postfix, classification, language)}" hreflang="${language}" type="${link_type}">${messages(link_name, language)} (${language})</a> + % endif + % else: + % if name and kind != "archive" and kind != "author": + <a href="${_link(kind + '_' + link_postfix, classification, language)}" hreflang="${language}" type="${link_type}">${messages(link_name, language)} (${name|h})</a> + % else: + <a href="${_link(kind + '_' + link_postfix, classification, language)}" hreflang="${language}" type="${link_type}">${messages(link_name, language)}</a> + % endif + % endif +</%def> + +<%def name="_html_translation_link(classification, kind, language, name=None)"> + % if name and kind != "archive" and kind != "author": + <a href="${_link(kind, classification, language)}" hreflang="${language}" rel="alternate">${messages("LANGUAGE", language)} (${name|h})</a> + % else: + <a href="${_link(kind, classification, language)}" hreflang="${language}" rel="alternate">${messages("LANGUAGE", language)}</a> + % endif +</%def> + +<%def name="_head_rss(classification=None, kind='index', rss_override=True)"> + % if rss_link and rss_override: + ${rss_link} + % endif + % if generate_rss and not (rss_link and rss_override) and kind != 'archive': + % if len(translations) > 1 and has_other_languages and classification and kind != 'index': + % for language, classification, name in all_languages: + <link rel="alternate" type="application/rss+xml" title="RSS for ${kind} ${name|h} (${language})" hreflang="${language}" href="${_link(kind + "_rss", classification, language)}"> + % endfor + % else: + % for language in translations_feedorder: + % if (classification or classification == '') and kind != 'index': + ${_head_feed_link('application/rss+xml', 'RSS for ' + kind + ' ' + classification, 'rss', classification, kind, language)} + % else: + ${_head_feed_link('application/rss+xml', 'RSS', 'rss', classification, 'index', language)} + % endif + % endfor + % endif + % endif +</%def> + +<%def name="_head_atom(classification=None, kind='index')"> + % if generate_atom: + % if len(translations) > 1 and has_other_languages and classification and kind != 'index': + % for language, classification, name in all_languages: + <link rel="alternate" type="application/atom+xml" title="Atom for ${kind} ${name|h} (${language})" hreflang="${language}" href="${_link(kind + "_atom", classification, language)}"> + % endfor + % else: + % for language in translations_feedorder: + % if (classification or classification == '') and kind != 'index': + ${_head_feed_link('application/atom+xml', 'Atom for ' + kind + ' ' + classification, 'atom', classification, kind, language)} + % else: + ${_head_feed_link('application/atom+xml', 'Atom', 'atom', classification, 'index', language)} + % endif + % endfor + % endif + % endif +</%def> + +## Handles both feeds and translations +<%def name="head(classification=None, kind='index', feeds=True, other=True, rss_override=True, has_no_feeds=False)"> + % if feeds and not has_no_feeds: + ${_head_rss(classification, 'index' if (kind == 'archive' and rss_override) else kind, rss_override)} + ${_head_atom(classification, kind)} + % endif + % if other and has_other_languages and other_languages: + % for language, classification, _ in other_languages: + <link rel="alternate" hreflang="${language}" href="${_link(kind, classification, language)}"> + % endfor + % endif +</%def> + +<%def name="feed_link(classification, kind)"> + % if generate_atom or generate_rss: + % if len(translations) > 1 and has_other_languages and kind != 'index': + % for language, classification, name in all_languages: + <p class="feedlink"> + % if generate_atom: + ${_html_feed_link('application/atom+xml', 'Atom feed', 'atom', classification, kind, language, name)} + % endif + % if generate_rss and kind != 'archive': + ${_html_feed_link('application/rss+xml', 'RSS feed', 'rss', classification, kind, language, name)} + % endif + </p> + % endfor + % else: + % for language in translations_feedorder: + <p class="feedlink"> + % if generate_atom: + ${_html_feed_link('application/atom+xml', 'Atom feed', 'atom', classification, kind, language)} + % endif + % if generate_rss and kind != 'archive': + ${_html_feed_link('application/rss+xml', 'RSS feed', 'rss', classification, kind, language)} + % endif + </p> + % endfor + % endif + % endif +</%def> + +<%def name="translation_link(kind)"> + % if has_other_languages and other_languages: + <div class="translationslist translations"> + <h3 class="translationslist-intro">${messages("Also available in:")}</h3> + % for language, classification, name in other_languages: + <p>${_html_translation_link(classification, kind, language, name)}</p> + % endfor + </div> + % endif +</%def> diff --git a/nikola/data/themes/base/templates/gallery.tmpl b/nikola/data/themes/base/templates/gallery.tmpl index 0ee07ac..fef3a86 100644 --- a/nikola/data/themes/base/templates/gallery.tmpl +++ b/nikola/data/themes/base/templates/gallery.tmpl @@ -1,11 +1,12 @@ ## -*- coding: utf-8 -*- <%inherit file="base.tmpl"/> <%namespace name="comments" file="comments_helper.tmpl"/> -<%namespace name="ui" file="crumbs.tmpl" import="bar"/> +<%namespace name="ui" file="ui_helper.tmpl"/> +<%namespace name="post_helper" file="post_helper.tmpl"/> <%block name="sourcelink"></%block> <%block name="content"> - ${ui.bar(crumbs)} + ${ui.breadcrumbs(crumbs)} %if title: <h1>${title|h}</h1> %endif @@ -15,21 +16,39 @@ </p> %endif %if folders: - <ul> - % for folder, ftitle in folders: - <li><a href="${folder}"><i - class="icon-folder-open"></i> ${ftitle}</a></li> - % endfor - </ul> - %endif - %if photo_array: - <ul class="thumbnails"> - %for image in photo_array: - <li><a href="${image['url']}" class="thumbnail image-reference" title="${image['title']}"> - <img src="${image['url_thumb']}" alt="${image['title']}" /></a> - %endfor - </ul> - %endif + % if galleries_use_thumbnail: + % for (folder, ftitle, fpost) in folders: + <div class="thumnbnail-container"> + <a href="${folder}" class="thumbnail image-reference" title="${ftitle|h}"> + % if fpost and fpost.previewimage: + <img src="${fpost.previewimage}" alt="${ftitle|h}" loading="lazy" style="max-width:${thumbnail_size}px; max-height:${thumbnail_size}px;" /> + % else: + <div style="height: ${thumbnail_size}px; width: ${thumbnail_size}px; background-color: #eee;"></div> + % endif + <p class="thumbnail-caption">${ftitle|h}</p> + </a> + </div> + % endfor + % else: + <ul> + % for folder, ftitle in folders: + <li><a href="${folder}">📂 ${ftitle|h}</a></li> + % endfor + </ul> + % endif + % endif + +<div id="gallery_container"></div> +%if photo_array: +<noscript> +<ul class="thumbnails"> + %for image in photo_array: + <li><a href="${image['url']}" class="thumbnail image-reference" title="${image['title']|h}"> + <img src="${image['url_thumb']}" alt="${image['title']|h}" loading="lazy" /></a> + %endfor +</ul> +</noscript> +%endif %if site_has_comments and enable_comments: ${comments.comment_form(None, permalink, title)} %endif @@ -38,4 +57,35 @@ <%block name="extra_head"> ${parent.extra_head()} <link rel="alternate" type="application/rss+xml" title="RSS" href="rss.xml"> +<style type="text/css"> + #gallery_container { + position: relative; + } + .image-block { + position: absolute; + } +</style> +%if len(translations) > 1: + %for langname in translations.keys(): + %if langname != lang: + <link rel="alternate" hreflang="${langname}" href="${_link('gallery', gallery_path, langname)}"> + %endif + %endfor +%endif +<link rel="alternate" type="application/rss+xml" title="RSS" href="rss.xml"> +%if post: + ${post_helper.open_graph_metadata(post)} + ${post_helper.twitter_card_information(post)} +%endif +</%block> + +<%block name="extra_js"> +<script src="/assets/js/justified-layout.min.js"></script> +<script src="/assets/js/gallery.min.js"></script> +<script> +var jsonContent = ${photo_array_json}; +var thumbnailSize = ${thumbnail_size}; +renderGallery(jsonContent, thumbnailSize); +window.addEventListener('resize', function(){renderGallery(jsonContent, thumbnailSize)}); +</script> </%block> diff --git a/nikola/data/themes/base/templates/index.tmpl b/nikola/data/themes/base/templates/index.tmpl index 88bb25c..b8e4f8c 100644 --- a/nikola/data/themes/base/templates/index.tmpl +++ b/nikola/data/themes/base/templates/index.tmpl @@ -1,6 +1,9 @@ ## -*- coding: utf-8 -*- <%namespace name="helper" file="index_helper.tmpl"/> +<%namespace name="math" file="math_helper.tmpl"/> <%namespace name="comments" file="comments_helper.tmpl"/> +<%namespace name="pagination" file="pagination_helper.tmpl"/> +<%namespace name="feeds_translations" file="feeds_translations_helper.tmpl" import="*"/> <%inherit file="base.tmpl"/> <%block name="extra_head"> @@ -8,18 +11,45 @@ % if posts and (permalink == '/' or permalink == '/' + index_file): <link rel="prefetch" href="${posts[0].permalink()}" type="text/html"> % endif + ${math.math_styles_ifposts(posts)} </%block> <%block name="content"> -<%block name="content_header"></%block> +<%block name="content_header"> + ${feeds_translations.translation_link(kind)} +</%block> +% if 'main_index' in pagekind: + ${front_index_header} +% endif +% if page_links: + ${pagination.page_navigation(current_page, page_links, prevlink, nextlink, prev_next_links_reversed)} +% endif <div class="postindex"> % for post in posts: - <article class="h-entry post-${post.meta('type')}"> + <article class="h-entry post-${post.meta('type')}" itemscope="itemscope" itemtype="http://schema.org/Article"> <header> <h1 class="p-name entry-title"><a href="${post.permalink()}" class="u-url">${post.title()|h}</a></h1> <div class="metadata"> - <p class="byline author vcard"><span class="byline-name fn">${post.author()}</span></p> - <p class="dateline"><a href="${post.permalink()}" rel="bookmark"><time class="published dt-published" datetime="${post.formatted_date('webiso')}" title="${post.formatted_date(date_format)}">${post.formatted_date(date_format)}</time></a></p> + <p class="byline author vcard"><span class="byline-name fn" itemprop="author"> + % if author_pages_generated and multiple_authors_per_post: + % for author in post.authors(): + <a href="${_link('author', author)}">${author|h}</a> + % endfor + % elif author_pages_generated: + <a href="${_link('author', post.author())}">${post.author()|h}</a> + % else: + ${post.author()|h} + % endif + </span></p> + <p class="dateline"> + <a href="${post.permalink()}" rel="bookmark"> + <time class="published dt-published" datetime="${post.formatted_date('webiso')}" itemprop="datePublished" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time> + % if post.updated and post.updated != post.date: + <span class="updated"> (${messages("updated")} + <time class="dt-updated" datetime="${post.formatted_updated('webiso')}" itemprop="dateUpdated" title="${post.formatted_updated(date_format)|h}">${post.formatted_updated(date_format)|h}</time>)</span> + % endif + </a> + </p> % if not post.meta('nocomments') and site_has_comments: <p class="commentline">${comments.comment_link(post.permalink(), post._base_path)} % endif @@ -38,5 +68,5 @@ </div> ${helper.html_pager()} ${comments.comment_link_script()} -${helper.mathjax_script(posts)} +${math.math_scripts_ifposts(posts)} </%block> diff --git a/nikola/data/themes/base/templates/index_helper.tmpl b/nikola/data/themes/base/templates/index_helper.tmpl index 9331b93..e400e3b 100644 --- a/nikola/data/themes/base/templates/index_helper.tmpl +++ b/nikola/data/themes/base/templates/index_helper.tmpl @@ -1,4 +1,5 @@ ## -*- coding: utf-8 -*- +<%namespace name="math" file="math_helper.tmpl"/> <%def name="html_pager()"> %if prevlink or nextlink: <nav class="postindexpager"> @@ -18,10 +19,7 @@ %endif </%def> +### This function is deprecated; use math_helper directly. <%def name="mathjax_script(posts)"> - %if any(post.is_mathjax for post in posts): - <script type="text/x-mathjax-config"> - MathJax.Hub.Config({tex2jax: {inlineMath: [['$latex ','$'], ['\\(','\\)']]}});</script> - <script src="/assets/js/mathjax.js"></script> - %endif + ${math.math_scripts_ifposts(posts)} </%def> diff --git a/nikola/data/themes/base/templates/list.tmpl b/nikola/data/themes/base/templates/list.tmpl index 4082516..ca6c421 100644 --- a/nikola/data/themes/base/templates/list.tmpl +++ b/nikola/data/themes/base/templates/list.tmpl @@ -1,15 +1,26 @@ ## -*- coding: utf-8 -*- <%inherit file="base.tmpl"/> +<%namespace name="archive_nav" file="archive_navigation_helper.tmpl" import="*"/> +<%namespace name="feeds_translations" file="feeds_translations_helper.tmpl" import="*"/> + +<%block name="extra_head"> + ${feeds_translations.head(kind=kind, rss_override=False, has_no_feeds=has_no_feeds)} +</%block> <%block name="content"> <article class="listpage"> <header> - <h1>${title}</h1> + <h1>${title|h}</h1> </header> + ${archive_nav.archive_navigation()} + ${feeds_translations.translation_link(kind)} %if items: <ul class="postlist"> - % for text, link in items: - <li><a href="${link}">${text}</a> + % for text, link, count in items: + <li><a href="${link}">${text|h}</a> + % if count: + (${count}) + % endif % endfor </ul> %else: diff --git a/nikola/data/themes/base/templates/list_post.tmpl b/nikola/data/themes/base/templates/list_post.tmpl index 3335fa6..8cd9336 100644 --- a/nikola/data/themes/base/templates/list_post.tmpl +++ b/nikola/data/themes/base/templates/list_post.tmpl @@ -1,15 +1,23 @@ ## -*- coding: utf-8 -*- <%inherit file="base.tmpl"/> +<%namespace name="archive_nav" file="archive_navigation_helper.tmpl" import="*"/> +<%namespace name="feeds_translations" file="feeds_translations_helper.tmpl" import="*"/> + +<%block name="extra_head"> + ${feeds_translations.head(kind=kind, rss_override=False)} +</%block> <%block name="content"> <article class="listpage"> <header> - <h1>${title}</h1> + <h1>${title|h}</h1> </header> + ${archive_nav.archive_navigation()} + ${feeds_translations.translation_link(kind)} %if posts: <ul class="postlist"> % for post in posts: - <li><a href="${post.permalink()}" class="listtitle">${post.title()|h}</a> <time class="listdate" datetime="${post.formatted_date('webiso')}" title="${post.formatted_date(date_format)}">${post.formatted_date(date_format)}</time></li> + <li><time class="listdate" datetime="${post.formatted_date('webiso')}" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time> <a href="${post.permalink()}" class="listtitle">${post.title()|h}</a></li> % endfor </ul> %else: diff --git a/nikola/data/themes/base/templates/listing.tmpl b/nikola/data/themes/base/templates/listing.tmpl index e0bf91b..ef2dfd6 100644 --- a/nikola/data/themes/base/templates/listing.tmpl +++ b/nikola/data/themes/base/templates/listing.tmpl @@ -1,23 +1,24 @@ ## -*- coding: utf-8 -*- <%inherit file="base.tmpl"/> -<%namespace name="ui" file="crumbs.tmpl" import="bar"/> +<%namespace name="ui" file="ui_helper.tmpl"/> <%block name="content"> -${ui.bar(crumbs)} +${ui.breadcrumbs(crumbs)} %if folders or files: <ul> % for name in folders: - <li><a href="${name}"><i class="icon-folder-open"></i> ${name}</a> + <li><a href="${name|h}" class="listing-folder">${name|h}</a> % endfor % for name in files: - <li><a href="${name}.html"><i class="icon-file"></i> ${name}</a> + <li><a href="${name|h}.html" class="listing-file">${name|h}</a> % endfor </ul> %endif % if code: + <h1>${title} + % if source_link: + <small><a href="${source_link}">(${messages("Source")})</a></small> + % endif + </h1> ${code} % endif -% if source_link: - <p class="sourceline"><a href="${source_link}" id="sourcelink">${messages("Source")}</a></p> -% endif </%block> - diff --git a/nikola/data/themes/base/templates/math_helper.tmpl b/nikola/data/themes/base/templates/math_helper.tmpl new file mode 100644 index 0000000..961b7ce --- /dev/null +++ b/nikola/data/themes/base/templates/math_helper.tmpl @@ -0,0 +1,69 @@ +### Note: at present, MathJax and KaTeX do not respect the USE_CDN configuration option +<%def name="math_scripts()"> + %if use_katex: + <script src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.js" integrity="sha384-9Nhn55MVVN0/4OFx7EE5kpFBPsEMZxKTCnA+4fqDmg12eCTqGi6+BB2LjY8brQxJ" crossorigin="anonymous"></script> + <script src="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"></script> + % if katex_auto_render: + <script> + renderMathInElement(document.body, + { + ${katex_auto_render} + } + ); + </script> + % else: + <script> + renderMathInElement(document.body, + { + delimiters: [ + {left: "$$", right: "$$", display: true}, + {left: "\\[", right: "\\]", display: true}, + {left: "\\begin{equation*}", right: "\\end{equation*}", display: true}, + {left: "\\(", right: "\\)", display: false} + ] + } + ); + </script> + % endif + %else: +### Note: given the size of MathJax; nikola will retrieve MathJax from a CDN regardless of use_cdn configuration + <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" integrity="sha384-3lJUsx1TJHt7BA4udB5KPnDrlkO8T6J6v/op7ui0BbCjvZ9WqV4Xm6DTP6kQ/iBH" crossorigin="anonymous"></script> + % if mathjax_config: + ${mathjax_config} + % else: + <script type="text/x-mathjax-config"> + MathJax.Hub.Config({tex2jax: {inlineMath: [['$latex ','$'], ['\\(','\\)']]}}); + </script> + % endif + %endif +</%def> + +<%def name="math_styles()"> + % if use_katex: + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous"> + % endif +</%def> + +<%def name="math_scripts_ifpost(post)"> + %if post.has_math: + ${math_scripts()} + %endif +</%def> + +<%def name="math_scripts_ifposts(posts)"> + %if any(post.has_math for post in posts): + ${math_scripts()} + %endif +</%def> + +<%def name="math_styles_ifpost(post)"> + %if post.has_math: + ${math_styles()} + %endif +</%def> + +<%def name="math_styles_ifposts(posts)"> + %if any(post.has_math for post in posts): + ${math_styles()} + %endif +</%def> diff --git a/nikola/data/themes/base/templates/page.tmpl b/nikola/data/themes/base/templates/page.tmpl new file mode 100644 index 0000000..b2cd756 --- /dev/null +++ b/nikola/data/themes/base/templates/page.tmpl @@ -0,0 +1 @@ +<%inherit file="story.tmpl"/> diff --git a/nikola/data/themes/base/templates/pagination_helper.tmpl b/nikola/data/themes/base/templates/pagination_helper.tmpl new file mode 100644 index 0000000..91c1115 --- /dev/null +++ b/nikola/data/themes/base/templates/pagination_helper.tmpl @@ -0,0 +1,16 @@ +## -*- coding: utf-8 -*- +<%def name="page_navigation(current_page, page_links, prevlink, nextlink, prev_next_links_reversed, surrounding=5)"> +<div class="page-navigation"> + % for i, link in enumerate(page_links): + % if abs(i - current_page) <= surrounding or i == 0 or i == len(page_links) - 1: + % if i == current_page: + <span class="current-page">${i+1}</span> + % else: + <a href="${page_links[i]}">${i+1}</a> + % endif + % elif i == current_page - surrounding - 1 or i == current_page + surrounding + 1: + <span class="ellipsis">…</span> + % endif + % endfor +</div> +</%def> diff --git a/nikola/data/themes/base/templates/post.tmpl b/nikola/data/themes/base/templates/post.tmpl index cbb81ef..1f2f0a4 100644 --- a/nikola/data/themes/base/templates/post.tmpl +++ b/nikola/data/themes/base/templates/post.tmpl @@ -2,17 +2,15 @@ <%namespace name="helper" file="post_helper.tmpl"/> <%namespace name="pheader" file="post_header.tmpl"/> <%namespace name="comments" file="comments_helper.tmpl"/> +<%namespace name="math" file="math_helper.tmpl"/> <%inherit file="base.tmpl"/> <%block name="extra_head"> ${parent.extra_head()} % if post.meta('keywords'): - <meta name="keywords" content="${post.meta('keywords')|h}"> + <meta name="keywords" content="${smartjoin(', ', post.meta('keywords'))|h}"> % endif - %if post.description(): - <meta name="description" content="${post.description()}"> - %endif - <meta name="author" content="${post.author()}"> + <meta name="author" content="${post.author()|h}"> %if post.prev_post: <link rel="prev" href="${post.prev_post.permalink()}" title="${post.prev_post.title()|h}" type="text/html"> %endif @@ -25,6 +23,7 @@ ${helper.open_graph_metadata(post)} ${helper.twitter_card_information(post)} ${helper.meta_translations(post)} + ${math.math_styles_ifpost(post)} </%block> <%block name="content"> @@ -45,7 +44,7 @@ ${comments.comment_form(post.permalink(absolute=True), post.title(), post._base_path)} </section> % endif - ${helper.mathjax_script(post)} + ${math.math_scripts_ifpost(post)} </article> ${comments.comment_link_script()} </%block> diff --git a/nikola/data/themes/base/templates/post_header.tmpl b/nikola/data/themes/base/templates/post_header.tmpl index 75383cb..617a156 100644 --- a/nikola/data/themes/base/templates/post_header.tmpl +++ b/nikola/data/themes/base/templates/post_header.tmpl @@ -23,7 +23,7 @@ <%def name="html_sourcelink()"> % if show_sourcelink: - <p class="sourceline"><a href="${post.source_link()}" id="sourcelink">${messages("Source")}</a></p> + <p class="sourceline"><a href="${post.source_link()}" class="sourcelink">${messages("Source")}</a></p> % endif </%def> @@ -31,18 +31,33 @@ <header> ${html_title()} <div class="metadata"> - <p class="byline author vcard"><span class="byline-name fn">${post.author()}</span></p> - <p class="dateline"><a href="${post.permalink()}" rel="bookmark"><time class="published dt-published" datetime="${post.formatted_date('webiso')}" itemprop="datePublished" title="${post.formatted_date(date_format)}">${post.formatted_date(date_format)}</time></a></p> + <p class="byline author vcard p-author h-card"><span class="byline-name fn p-name" itemprop="author"> + % if author_pages_generated and multiple_authors_per_post: + % for author in post.authors(): + <a class="u-url" href="${_link('author', author)}">${author|h}</a> + % endfor + % elif author_pages_generated: + <a class="u-url" href="${_link('author', post.author())}">${post.author()|h}</a> + % else: + ${post.author()|h} + % endif + </span></p> + <p class="dateline"> + <a href="${post.permalink()}" rel="bookmark"> + <time class="published dt-published" datetime="${post.formatted_date('webiso')}" itemprop="datePublished" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time> + % if post.updated and post.updated != post.date: + <span class="updated"> (${messages("updated")} + <time class="updated dt-updated" datetime="${post.formatted_updated('webiso')}" itemprop="dateUpdated" title="${post.formatted_updated(date_format)|h}">${post.formatted_updated(date_format)|h}</time>)</span> + % endif + </a> + </p> % if not post.meta('nocomments') and site_has_comments: <p class="commentline">${comments.comment_link(post.permalink(), post._base_path)} % endif ${html_sourcelink()} % if post.meta('link'): - <p class="linkline"><a href='${post.meta('link')}'>${messages("Original site")}</a></p> + <p class="linkline"><a href="${post.meta('link')}">${messages("Original site")}</a></p> % endif - %if post.description(): - <meta name="description" itemprop="description" content="${post.description()}"> - %endif </div> ${html_translations(post)} </header> diff --git a/nikola/data/themes/base/templates/post_helper.tmpl b/nikola/data/themes/base/templates/post_helper.tmpl index 424d134..9ae4489 100644 --- a/nikola/data/themes/base/templates/post_helper.tmpl +++ b/nikola/data/themes/base/templates/post_helper.tmpl @@ -1,9 +1,10 @@ ## -*- coding: utf-8 -*- +<%namespace name="math" file="math_helper.tmpl"/> <%def name="meta_translations(post)"> %if len(translations) > 1: %for langname in sorted(translations): - %if langname != lang and post.is_translation_available(langname): + %if langname != lang and ((not post.skip_untranslated) or post.is_translation_available(langname)): <link rel="alternate" hreflang="${langname}" href="${post.permalink(langname)}"> %endif %endfor @@ -15,7 +16,7 @@ <ul itemprop="keywords" class="tags"> %for tag in post.tags: % if tag not in hidden_tags: - <li><a class="tag p-category" href="${_link('tag', tag)}" rel="tag">${tag}</a></li> + <li><a class="tag p-category" href="${_link('tag', tag)}" rel="tag">${tag|h}</a></li> % endif %endfor </ul> @@ -40,31 +41,29 @@ </%def> <%def name="open_graph_metadata(post)"> -%if use_open_graph: - <meta property="og:site_name" content="${blog_title|striphtml}"> - <meta property="og:title" content="${post.title()[:70]|h}"> - <meta property="og:url" content="${abs_link(permalink)}"> - %if post.description(): +<meta property="og:site_name" content="${blog_title|h}"> +<meta property="og:title" content="${post.title()[:70]|h}"> +<meta property="og:url" content="${abs_link(permalink)}"> +%if post.description(): <meta property="og:description" content="${post.description()[:200]|h}"> - %else: +%else: <meta property="og:description" content="${post.text(strip_html=True)[:200]|h}"> - %endif - %if post.previewimage: +%endif +%if post.previewimage: <meta property="og:image" content="${url_replacer(permalink, post.previewimage, lang, 'absolute')}"> - %endif - <meta property="og:type" content="article"> +%endif +<meta property="og:type" content="article"> ### Will only work with Pintrest and breaks everywhere else who expect a [Facebook] URI. ### %if post.author(): -### <meta property="article:author" content="${post.author()}"> +### <meta property="article:author" content="${post.author()|h}"> ### %endif - %if post.date.isoformat(): +%if post.date.isoformat(): <meta property="article:published_time" content="${post.formatted_date('webiso')}"> - %endif - %if post.tags: - %for tag in post.tags: - <meta property="article:tag" content="${tag}"> - %endfor - %endif +%endif +%if post.tags: + %for tag in post.tags: + <meta property="article:tag" content="${tag|h}"> + %endfor %endif </%def> @@ -84,10 +83,7 @@ %endif </%def> +### This function is deprecated; use math_helper directly. <%def name="mathjax_script(post)"> - %if post.is_mathjax: - <script type="text/x-mathjax-config"> - MathJax.Hub.Config({tex2jax: {inlineMath: [['$latex ','$'], ['\\(','\\)']]}});</script> - <script src="/assets/js/mathjax.js"></script> - %endif + ${math.math_scripts_ifpost(post)} </%def> diff --git a/nikola/data/themes/base/templates/post_list_directive.tmpl b/nikola/data/themes/base/templates/post_list_directive.tmpl index e080a81..4a1cf69 100644 --- a/nikola/data/themes/base/templates/post_list_directive.tmpl +++ b/nikola/data/themes/base/templates/post_list_directive.tmpl @@ -6,10 +6,10 @@ <ul class="post-list"> % for post in posts: <li class="post-list-item"> - ${post.formatted_date(date_format)} - - <a href="${post.permalink(lang)}">${post.title(lang)|h}</a> - </li> + ${post.formatted_date(date_format)|h} + + <a href="${post.permalink(lang)}">${post.title(lang)|h}</a> + </li> % endfor </ul> %endif diff --git a/nikola/data/themes/base/templates/slides.tmpl b/nikola/data/themes/base/templates/slides.tmpl deleted file mode 100644 index 048fb7e..0000000 --- a/nikola/data/themes/base/templates/slides.tmpl +++ /dev/null @@ -1,24 +0,0 @@ -<%block name="content"> -<div id="${carousel_id}" class="carousel slide"> - <ol class="carousel-indicators"> - % for i in range(len(slides_content)): - % if i == 0: - <li data-target="#${carousel_id}" data-slide-to="${i}" class="active"></li> - % else: - <li data-target="#${carousel_id}" data-slide-to="${i}"></li> - % endif - % endfor - </ol> - <div class="carousel-inner"> - % for i, image in enumerate(slides_content): - % if i == 0: - <div class="item active"><img src="${image}" alt="" style="margin: 0 auto 0 auto;"></div> - % else: - <div class="item"><img src="${image}" alt="" style="margin: 0 auto 0 auto;"></div> - % endif - % endfor - </div> - <a class="left carousel-control" href="#${carousel_id}" data-slide="prev">‹</a> - <a class="right carousel-control" href="#${carousel_id}" data-slide="next">›</a> -</div> -</%block> diff --git a/nikola/data/themes/base/templates/story.tmpl b/nikola/data/themes/base/templates/story.tmpl index 2737c4d..aeac04f 100644 --- a/nikola/data/themes/base/templates/story.tmpl +++ b/nikola/data/themes/base/templates/story.tmpl @@ -2,10 +2,11 @@ <%namespace name="helper" file="post_helper.tmpl"/> <%namespace name="pheader" file="post_header.tmpl"/> <%namespace name="comments" file="comments_helper.tmpl"/> +<%namespace name="math" file="math_helper.tmpl"/> <%inherit file="post.tmpl"/> <%block name="content"> -<article class="storypage" itemscope="itemscope" itemtype="http://schema.org/Article"> +<article class="post-${post.meta('type')} storypage" itemscope="itemscope" itemtype="http://schema.org/Article"> <header> ${pheader.html_title()} ${pheader.html_translations(post)} @@ -19,6 +20,6 @@ ${comments.comment_form(post.permalink(absolute=True), post.title(), post.base_path)} </section> %endif - ${helper.mathjax_script(post)} + ${math.math_scripts_ifpost(post)} </article> </%block> diff --git a/nikola/data/themes/base/templates/tag.tmpl b/nikola/data/themes/base/templates/tag.tmpl index 7509f3e..ac40876 100644 --- a/nikola/data/themes/base/templates/tag.tmpl +++ b/nikola/data/themes/base/templates/tag.tmpl @@ -1,51 +1,37 @@ ## -*- coding: utf-8 -*- <%inherit file="list_post.tmpl"/> +<%namespace name="feeds_translations" file="feeds_translations_helper.tmpl" import="*"/> <%block name="extra_head"> - ${parent.extra_head()} - %if len(translations) > 1 and generate_rss: - %for language in sorted(translations): - <link rel="alternate" type="application/rss+xml" type="application/rss+xml" title="RSS for ${kind} ${tag} (${language})" href="${_link(kind + "_rss", tag, language)}"> - %endfor - %elif generate_rss: - <link rel="alternate" type="application/rss+xml" type="application/rss+xml" title="RSS for ${kind} ${tag}" href="${_link(kind + "_rss", tag)}"> - %endif + ${feeds_translations.head(tag, kind, rss_override=False)} </%block> - <%block name="content"> <article class="tagpage"> <header> <h1>${title|h}</h1> %if description: - <p>${description}</p> + <p>${description}</p> %endif %if subcategories: ${messages('Subcategories:')} <ul> %for name, link in subcategories: - <li><a href="${link}">${name}</a></li> + <li><a href="${link}">${name|h}</a></li> %endfor </ul> %endif <div class="metadata"> - %if len(translations) > 1 and generate_rss: - %for language in sorted(translations): - <p class="feedlink"> - <a href="${_link(kind + "_rss", tag, language)}" hreflang="${language}" type="application/rss+xml">${messages('RSS feed', language)} (${language})</a> - </p> - %endfor - %elif generate_rss: - <p class="feedlink"><a href="${_link(kind + "_rss", tag)}" type="application/rss+xml">${messages('RSS feed')}</a></p> - %endif + ${feeds_translations.feed_link(tag, kind=kind)} </div> + ${feeds_translations.translation_link(kind)} </header> %if posts: - <ul class="postlist"> - % for post in posts: - <li><a href="${post.permalink()}" class="listtitle">${post.title()|h}</a> <time class="listdate" datetime="${post.formatted_date('webiso')}" title="${post.formatted_date(date_format)}">${post.formatted_date(date_format)}</time></li> - % endfor - </ul> + <ul class="postlist"> + % for post in posts: + <li><time class="listdate" datetime="${post.formatted_date('webiso')}" title="${post.formatted_date(date_format)|h}">${post.formatted_date(date_format)|h}</time> <a href="${post.permalink()}" class="listtitle">${post.title()|h}<a></li> + % endfor + </ul> %endif </article> </%block> diff --git a/nikola/data/themes/base/templates/tagindex.tmpl b/nikola/data/themes/base/templates/tagindex.tmpl index 0834411..232d093 100644 --- a/nikola/data/themes/base/templates/tagindex.tmpl +++ b/nikola/data/themes/base/templates/tagindex.tmpl @@ -1,24 +1,29 @@ ## -*- coding: utf-8 -*- <%inherit file="index.tmpl"/> +<%namespace name="feeds_translations" file="feeds_translations_helper.tmpl" import="*"/> <%block name="content_header"> - %if subcategories: - ${messages('Subcategories:')} - <ul> - %for name, link in subcategories: - <li><a href="${link}">${name}</a></li> - %endfor - </ul> - %endif + <header> + <h1>${title|h}</h1> + %if description: + <p>${description}</p> + %endif + %if subcategories: + ${messages('Subcategories:')} + <ul> + %for name, link in subcategories: + <li><a href="${link}">${name|h}</a></li> + %endfor + </ul> + %endif + <div class="metadata"> + ${feeds_translations.feed_link(tag, kind)} + ${feeds_translations.translation_link(kind)} + </div> + </header> </%block> <%block name="extra_head"> ${parent.extra_head()} - %if len(translations) > 1 and generate_atom: - %for language in sorted(translations): - <link rel="alternate" type="application/atom+xml" title="Atom for the ${tag} section (${language})" href="${_link(kind + "_atom", tag, language)}"> - %endfor - %elif generate_atom: - <link rel="alternate" type="application/atom+xml" title="Atom for the ${tag} section" href="${_link("tag" + "_atom", tag)}"> - %endif + ${feeds_translations.head(tag, kind, rss_override=False)} </%block> diff --git a/nikola/data/themes/base/templates/tags.tmpl b/nikola/data/themes/base/templates/tags.tmpl index a9d2dd7..c54559a 100644 --- a/nikola/data/themes/base/templates/tags.tmpl +++ b/nikola/data/themes/base/templates/tags.tmpl @@ -1,10 +1,18 @@ ## -*- coding: utf-8 -*- <%inherit file="base.tmpl"/> +<%namespace name="feeds_translations" file="feeds_translations_helper.tmpl" import="*"/> + +<%block name="extra_head"> + ${feeds_translations.head(kind=kind, feeds=False)} +</%block> <%block name="content"> <article class="tagindex"> <header> - <h1>${title}</h1> + <h1>${title|h}</h1> + <div class="metadata"> + ${feeds_translations.translation_link(kind)} + </div> </header> % if cat_items: % if items: @@ -33,7 +41,7 @@ <ul class="postlist"> % for text, link in items: % if text not in hidden_tags: - <li><a class="reference listtitle" href="${link}">${text}</a></li> + <li><a class="reference listtitle" href="${link}">${text|h}</a></li> % endif % endfor </ul> diff --git a/nikola/data/themes/base/templates/crumbs.tmpl b/nikola/data/themes/base/templates/ui_helper.tmpl index 49c5e1e..173027c 100644 --- a/nikola/data/themes/base/templates/crumbs.tmpl +++ b/nikola/data/themes/base/templates/ui_helper.tmpl @@ -1,6 +1,5 @@ ## -*- coding: utf-8 -*- - -<%def name="bar(crumbs)"> +<%def name="breadcrumbs(crumbs)"> %if crumbs: <nav class="breadcrumbs"> <ul class="breadcrumb"> |
