diff options
Diffstat (limited to 'templates')
| -rw-r--r-- | templates/base.html | 10 | ||||
| -rw-r--r-- | templates/index.html | 28 | ||||
| -rw-r--r-- | templates/macros/head.html | 71 | ||||
| -rw-r--r-- | templates/posts.html | 27 |
4 files changed, 100 insertions, 36 deletions
diff --git a/templates/base.html b/templates/base.html index cb8d73f..31db9bf 100644 --- a/templates/base.html +++ b/templates/base.html @@ -66,6 +66,11 @@ </a></h2> </li> {%- endfor -%} {%- endif -%} + {%- if js_switcher -%} + {%- set icon_adjust=config.extra.icon_adjust | default(value="svgs adjust") -%} + <li class="js">{%- if icon_adjust -%}<i type="reset" id="mode" class="{{ icon_adjust }}"></i>{%- else -%}<i type="reset" id="mode" class="mode">☀</i>{%- endif -%}</li> + {%- endif -%} + {%- endif -%} {%- set language_count = 1 -%} {%- for language_name, language in config.languages -%} {%- set_global language_count = language_count + 1 -%} @@ -87,11 +92,6 @@ {%- endif %} </div></li> {%- endif -%} - {%- if js_switcher -%} - {%- set icon_adjust=config.extra.icon_adjust | default(value="svgs adjust") -%} - <li class="js">{%- if icon_adjust -%}<i type="reset" id="mode" class="{{ icon_adjust }}"></i>{%- else -%}<i type="reset" id="mode" class="mode">☀</i>{%- endif -%}</li> - {%- endif -%} - {%- endif -%} </ul> </div> {%- if config.build_search_index %} diff --git a/templates/index.html b/templates/index.html index 84314b1..ce224c0 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,3 +1,8 @@ +{# +This Page Shows the Posts with a short summary on the index: example.com/ +This Template can also be used as the rendering template for Sections, eg: example.com/blog/ example.com/software/ +#} + {%- extends "base.html" %} {%- block seo %} @@ -54,12 +59,25 @@ {%- endfor %} {{- macros::pagination(paginator=paginator, config=config) }} </div> - {%- if lang == config.default_language %} - {%- set section_item = get_section(path="_index.md") %} - {%- else %} - {%- set section_item = get_section(path="_index." ~ lang ~ ".md") %} - {%- endif %} {%- if config.extra.recent | default(value=true) %} + {#- The following line is checking if the template is being used for the root or a section #} + {%- if current_path is matching("^(/[[:alpha:]][[:alpha:]])?(/page/[[:digit:]]+)?/$") %} + {%- set sec = "" %} + {%- else %} + {%- if lang == config.default_language %} + {%- set sec = current_path | trim_start_matches(pat="/") | split(pat="/page/") | slice(end=1) | join(sep="") | trim_end_matches(pat="/") %} + {%- set sec = sec ~ "/" %} + {%- else %} + {%- set sec = current_path | trim_start_matches(pat="/" ~ lang ~ "/") | split(pat="/page/") | slice(end=1) | join(sep="") | trim_end_matches(pat="/") %} + {%- set sec = sec ~ "/" %} + {%- endif %} + {%- endif %} + + {%- if lang == config.default_language %} + {%- set section_item = get_section(path=sec ~ "_index.md") %} + {%- else %} + {%- set section_item = get_section(path=sec ~ "_index." ~ lang ~ ".md") %} + {%- endif %} <div class="toc"> <div class="toc-sticky"> <h1><span class="s70">{%- if lang != config.default_language %}{{ trans(key="Recent_Posts" | safe, lang=lang) }}{% else %}Recent Posts{% endif %}</span></h1> diff --git a/templates/macros/head.html b/templates/macros/head.html index 8aa2128..5a7221c 100644 --- a/templates/macros/head.html +++ b/templates/macros/head.html @@ -1,7 +1,7 @@ {#- Theme Switcher Button to toggle between dark/light #} {%- macro theme(config) %} {%- if config.extra.js_switcher | default(value=true) %} - {%- set js_theme=config.extra.js_theme | default(value="theme.min.js") -%} + {%- set js_theme=config.extra.js_theme | default(value="js/theme.min.js") -%} {%- if js_theme %} <script src="{{ get_url(path=js_theme, trailing_slash=false) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=js_theme, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} @@ -80,54 +80,81 @@ {%- if config.extra.js_bundle %} - <script defer src="{{ get_url(path='abridge.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='abridge.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + <script defer src="{{ get_url(path='js/abridge.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/abridge.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + + {%- if config.build_search_index %} + {%- if search_library == "elasticlunr" %} + {%- if lang != "en" %} + <script defer src="{{get_url(path='js/lunr.stemmer.support.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/lunr.stemmer.support.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + <script defer src="{{get_url(path='js/lunr.' ~ lang ~ '.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/lunr.' ~ lang ~ '.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- endif %} + {%- endif %} + {%- endif %} {%- else %} {%- if preStyle == true %} - {%- set js_prestyle=config.extra.js_prestyle | default(value="prestyle.js") -%} + {%- set js_prestyle=config.extra.js_prestyle | default(value="js/prestyle.js") -%} {%- if js_prestyle %} <script defer src="{{ get_url(path=js_prestyle, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=js_prestyle, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} {%- endif %} {%- if config.extra.js_switcher | default(value=true) %} - {%- set js_theme=config.extra.js_theme | default(value="theme.min.js") -%} + {%- set js_theme=config.extra.js_theme | default(value="js/theme.min.js") -%} {%- if js_theme %} - {%- set js_themeButton=config.extra.js_themeButton | default(value="theme_button.js") -%} + {%- set js_themeButton=config.extra.js_themeButton | default(value="js/theme_button.js") -%} {%- if js_themeButton %} <script defer src="{{ get_url(path=js_themeButton, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=js_themeButton, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} {%- endif %} {%- endif %} - {%- set js_email=config.extra.js_email | default(value="email.js") -%} + {%- set js_email=config.extra.js_email | default(value="js/email.js") -%} {%- if js_email %} {%- if config.extra.mail_encode | default(value=true) %} <script defer src="{{ get_url(path=js_email, trzailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=js_email, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} {%- endif %} - {%- set js_codecopy=config.extra.js_codecopy | default(value="codecopy.js") -%} + {%- set js_codecopy=config.extra.js_codecopy | default(value="js/codecopy.js") -%} {%- if js_codecopy %} <script defer src="{{ get_url(path=js_codecopy, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=js_codecopy, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - {%- if config.build_search_index %} {%- if search_library == "tinysearch" %} - <script defer type="module" src="{{ get_url(path='tinysearch.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='tinysearch.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> + <script defer type="module" src="{{ get_url(path='js/search_tinysearch.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/search_tinysearch.min.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- elif search_library == "stork" %} - <script defer type="module" src="{{ get_url(path='search_stork.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='search_stork.min.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- else %} - <script defer src="{{ get_url(path='elasticlunr.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='elasticlunr.min.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> - <script defer src="{{ get_url(path='search.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='search.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> + <script defer type="module" src="{{ get_url(path='js/search_stork.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/search_stork.min.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- elif config.build_search_index %} - {%- if lang != "en" %} - <script defer src="{{ get_url(path='lunr.stemmer.support.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='lunr.stemmer.support.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> - <script defer src="{{ get_url(path='lunr.' ~ lang ~ '.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='lunr.' ~ lang ~ '.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- set search_index_format="elasticlunr_json" -%} + {%- if config.search.index_format %} + {%- if config.search.index_format == "elasticlunr_javascript" %} + {%- set search_index_format="elasticlunr_javascript" -%} + {%- endif %} {%- endif %} + {%- set uglyurls=config.extra.uglyurls | default(value=false) -%} + {%- if search_index_format == "elasticlunr_javascript" %} + <script defer src="{{ get_url(path='js/elasticlunr.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/elasticlunr.min.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> + <script defer src="{{ get_url(path='search_index.' ~ lang ~ '.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='search_index.' ~ lang ~ '.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> + + {%- if uglyurls %} + <script defer src="{{ get_url(path='js/searchjavaugly.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/searchjavaugly.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- else %} + <script defer src="{{ get_url(path='js/searchjava.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/searchjava.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- endif %} + + {%- else %} + <script defer src="{{ get_url(path='js/search_elasticlunr.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/search_elasticlunr.min.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} + + {%- if lang != "en" %} + <script defer src="{{ get_url(path='js/lunr.stemmer.support.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/lunr.stemmer.support.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + <script defer src="{{ get_url(path='js/lunr.' ~ lang ~ '.min.js' , trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path='js/lunr.' ~ lang ~ '.min.js' , sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- endif %} + {%- endif %} {%- endif %} @@ -138,19 +165,19 @@ {#- https://github.com/KaTeX/KaTeX/tree/main/contrib/mathtex-script-type/ #} {%- if config.extra.math or page.extra.math %} -{%- set katex_bundle=config.extra.katex_bundle | default(value="katexbundle.min.js") -%} +{%- set katex_bundle=config.extra.katex_bundle | default(value="js/katexbundle.min.js") -%} {%- if katex_bundle %} <script defer src="{{ get_url(path=katex_bundle, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=katex_bundle, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- else %} - {%- set katex_js=config.extra.katex_js | default(value="katex.min.js") -%} + {%- set katex_js=config.extra.katex_js | default(value="js/katex.min.js") -%} {%- if katex_js %}{%- if katex_js is matching("^http[s]?://") %} <script defer src="{{ katex_js | safe }}"{%- if config.extra.integrity | default(value=true) and config.extra.katex_js_integrity %} integrity="{{ config.extra.katex_js_integrity | safe }}"{%- endif %} crossorigin="anonymous"></script> {%- else %} <script defer src="{{ get_url(path=katex_js, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=katex_js, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %}{%- endif %} - {%- set mathtex_js=config.extra.mathtex_js | default(value="mathtex-script-type.min.js") -%} + {%- set mathtex_js=config.extra.mathtex_js | default(value="js/mathtex-script-type.min.js") -%} {%- if mathtex_js %}{%- if mathtex_js is matching("^http[s]?://") %} <script defer src="{{ mathtex_js | safe }}"{%- if config.extra.integrity | default(value=true) and config.extra.mathtex_js_integrity %} integrity="{{ config.extra.mathtex_js_integrity | safe }}"{%- endif %} crossorigin="anonymous"></script> {%- else %} @@ -158,7 +185,7 @@ {%- endif %}{%- endif %} {%- if config.extra.math_auto_render or page.extra.math_auto_render %} - {%- set katex_autorender_js=config.extra.katex_autorender_js | default(value="katex-auto-render.min.js") -%} + {%- set katex_autorender_js=config.extra.katex_autorender_js | default(value="js/katex-auto-render.min.js") -%} {%- if katex_autorender_js %} {%- if katex_autorender_js is matching("^http[s]?://") %} <script defer src="{{ katex_autorender_js | safe }}"{%- if config.extra.integrity | default(value=true) and config.extra.katex_autorender_js_integrity %} integrity="{{ config.extra.katex_autorender_js_integrity | safe }}"{%- endif %} crossorigin="anonymous"></script> @@ -166,7 +193,7 @@ <script defer src="{{ get_url(path=katex_autorender_js, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=katex_autorender_js, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} {%- endif %} - {%- set katex_options=config.extra.katex_options | default(value="katexoptions.js") -%} + {%- set katex_options=config.extra.katex_options | default(value="js/katexoptions.js") -%} {%- if katex_options %} <script defer src="{{ get_url(path=katex_options, trailing_slash=false, cachebust=true) }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=katex_options, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} @@ -226,7 +253,7 @@ {#- page_images: using for the blog single template page -#} {#- page_section: the blog single template page have to pass the parameter -#} {#- is_404: using for the 404.html template -#} -{%- macro seo( config, title="", title_addition="", description="", type="website", is_home=false, is_404=false, is_page=false, page_images="", page_section="", created_time="2021-07-04T07:07:00-07:00", updated_time="2021-07-04T07:07:00-07:00" ) %} +{%- macro seo( config, title="", title_addition="", description="", type="website", is_home=false, is_404=false, is_page=false, page_images="", page_section="", created_time="2023-05-15T07:07:00-07:00", updated_time="2023-05-15T07:07:00-07:00" ) %} {%- if is_404 -%} <meta name="robots" content="noindex, follow" /> {%- else -%} diff --git a/templates/posts.html b/templates/posts.html index 92c07dc..13dc274 100644 --- a/templates/posts.html +++ b/templates/posts.html @@ -1,4 +1,7 @@ -{# This Page Shows the Posts Grouped by Year: example.com/posts/ #} +{# +This Page Shows the Posts Grouped by Year: example.com/posts/ +This Template can also be used as the rendering template for Sections, eg: example.com/blog/ example.com/software/ +#} {% extends "base.html" %} @@ -18,14 +21,30 @@ {%- endblock seo %} {%- block content %} + {#- The following line is checking if the template is being used for the posts page or a section #} + {%- if current_path is matching("^(/[[:alpha:]][[:alpha:]])?/posts/$") %} + {%- set sec = "" %} + {%- else %} + {%- set langpath = "/" %} + {%- if lang != config.default_language %} + {%- set langpath = "/" ~ lang ~ "/" %} + {%- endif %} + + {%- set sec = current_path | trim_start_matches(pat=langpath) | split(pat="/page/") | slice(end=1) | join(sep="") | trim_end_matches(pat="/") %} + {%- set sec = sec ~ "/" %} + {%- endif %} + {%- if lang == config.default_language %} - {%- set section_item = get_section(path="_index.md") %} + {%- set section_item = get_section(path=sec ~ "_index.md") %} {%- else %} - {%- set section_item = get_section(path="_index." ~ lang ~ ".md") %} + {%- set section_item = get_section(path=sec ~ "_index." ~ lang ~ ".md") %} {%- endif %} <div> + {%- if section_item.title %} + <h2>{{ section_item.title }}</h2> + {%- endif %} {%- for year, posts in section_item.pages | group_by(attribute="year") %} - <h2>{{ year }}</h2> + {%- if section_item.title %}<h3>{{ year }}</h3>{%- else %}<h2>{{ year }}</h2>{%- endif %} {%- for post in posts %} <p><a href="{{ post.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ post.title }}</a> - <time datetime="{{ post.date }}">{{ post.date | date(format="%F") }}</time></p> {%- endfor %} |
