From 009d3f90b1881530bd28003abe83cfc3735882be Mon Sep 17 00:00:00 2001 From: Jieiku Date: Fri, 25 Aug 2023 01:44:50 -0700 Subject: Refactor Documentation, PWA Fix, image shortcodes fix, simplify js script loading --- templates/macros/head.html | 75 ++++++++++++++------------------------ templates/page.html | 2 +- templates/shortcodes/img.html | 2 +- templates/shortcodes/imgswap.html | 4 +- templates/shortcodes/showdata.html | 8 ++++ 5 files changed, 40 insertions(+), 51 deletions(-) create mode 100644 templates/shortcodes/showdata.html (limited to 'templates') diff --git a/templates/macros/head.html b/templates/macros/head.html index 673954b..fe4eb53 100644 --- a/templates/macros/head.html +++ b/templates/macros/head.html @@ -1,26 +1,18 @@ {#- 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="") -%} - {%- if not js_theme %} - {%- set js_theme="js/theme.min.js" -%} - {%- if config.extra.js_switcher_default %}{%- if config.extra.js_switcher_default == "light" %} - {%- set js_theme="js/theme_light.min.js" -%} - {%- endif %}{%- endif %} + {%- set js_theme="js/theme.min.js" %} + {%- if config.extra.js_switcher_default %} + {%- if config.extra.js_switcher_default == "light" %}{% set js_theme="js/theme_light.min.js" %}{% endif %} {%- endif %} - + {%- endif %} {%- endmacro %} - {#- Service Worker for PWA #} {%- macro pwa(config) %} {%- if config.extra.pwa | default(value=false) %} - {%- set js_swload=config.extra.js_swload | default(value="") -%} - {%- if not js_swload %} - {%- set js_swload="js/sw_load.min.js" -%} - {%- endif %} - + {%- endif %} {%- endmacro %} @@ -28,7 +20,7 @@ {%- macro stylesheets(config) %} {%- set stylesheets=config.extra.stylesheets | default(value=[ "abridge.css" ]) -%} {%- if stylesheets %}{%- for i in stylesheets %} - + {%- endfor %}{%- endif %} {%- endmacro %} @@ -96,49 +88,38 @@ {%- if config.extra.js_bundle %} {%- if config.build_search_index %} - + {%- else %} - + {%- endif %} {%- if config.build_search_index %} {%- if search_library == "elasticlunr" %} {%- if lang != "en" %} - - + + {%- endif %} {%- endif %} {%- endif %} -{%- else %} +{%- else %}{#- Not js_bundle #} {%- if preStyle == true %} - {%- set js_prestyle=config.extra.js_prestyle | default(value="js/prestyle.js") -%} - {%- if js_prestyle %} - + {%- if config.extra.js_prestyle | default(value=true) %} + {%- endif %} {%- endif %} {%- if config.extra.js_switcher | default(value=true) %} - {%- 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="js/theme_button.js") -%} - {%- if js_themeButton %} - - {%- endif %} - {%- endif %} + {%- endif %} - {%- set js_email=config.extra.js_email | default(value="js/email.js") -%} - {%- if js_email %} - {%- if config.extra.mail_encode | default(value=true) %} - - {%- endif %} + {%- if config.extra.js_email_encode | default(value=true) %} + {%- endif %} - {%- set js_codecopy=config.extra.js_codecopy | default(value="js/codecopy.js") -%} - {%- if js_codecopy %} - + {%- if config.extra.js_copycode | default(value=true) %} + {%- endif %} {%- if search_library == "tinysearch" %} @@ -155,7 +136,7 @@ {%- endif %} {%- set uglyurls=config.extra.uglyurls | default(value=false) -%} - {%- if search_index_format == "elasticlunr_javascript" %} + {%- if search_index_format == "elasticlunr_javascript" %}{#- Javascript index format #} @@ -170,8 +151,8 @@ {%- endif %} {%- if lang != "en" %} - - + + {%- endif %} {%- endif %} @@ -186,35 +167,35 @@ {%- set katex_bundle=config.extra.katex_bundle | default(value="js/katexbundle.min.js") -%} {%- if katex_bundle %} - + {%- else %} {%- set katex_js=config.extra.katex_js | default(value="js/katex.min.js") -%} {%- if katex_js %}{%- if katex_js is matching("^http[s]?://") %} - + {%- else %} - + {%- endif %}{%- endif %} {%- 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]?://") %} {%- else %} - + {%- 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="js/katex-auto-render.min.js") -%} {%- if katex_autorender_js %} {%- if katex_autorender_js is matching("^http[s]?://") %} - + {%- else %} - + {%- endif %} {%- endif %} {%- set katex_options=config.extra.katex_options | default(value="js/katexoptions.js") -%} {%- if katex_options %} - + {%- endif %} {%- endif %} {%- endif %} diff --git a/templates/page.html b/templates/page.html index 36ff4f4..6ca83d4 100644 --- a/templates/page.html +++ b/templates/page.html @@ -69,7 +69,7 @@ {%- if toc %}