diff options
| author | Jieiku | 2023-08-19 10:39:52 -0700 |
|---|---|---|
| committer | Jieiku | 2023-08-19 10:39:52 -0700 |
| commit | 211d08f9804c70943d7395175f25096483f006d0 (patch) | |
| tree | c2c98891259fc353826b9346ee424101bb4c2e05 /templates | |
| parent | 3e5d8a96e9eae21a799f327cd8a52adb891ebe66 (diff) | |
| download | abridge-211d08f9804c70943d7395175f25096483f006d0.tar.gz abridge-211d08f9804c70943d7395175f25096483f006d0.tar.bz2 abridge-211d08f9804c70943d7395175f25096483f006d0.zip | |
Version 2.0.0 Refactor, Add PWA Support2.0.0
Diffstat (limited to 'templates')
| -rw-r--r-- | templates/404.html | 2 | ||||
| -rw-r--r-- | templates/base.html | 27 | ||||
| -rw-r--r-- | templates/macros/head.html | 19 | ||||
| -rw-r--r-- | templates/macros/social.html | 2 | ||||
| -rw-r--r-- | templates/page.html | 4 |
5 files changed, 36 insertions, 18 deletions
diff --git a/templates/404.html b/templates/404.html index f3fbfe9..27e9148 100644 --- a/templates/404.html +++ b/templates/404.html @@ -19,7 +19,7 @@ <div> <h1>404 :(</h1> {#- Default English message #} - <p>Page not found, maybe moved{% if config.languages | length > 0 %} or not in this language{% endif %}. {% if config.build_search_index %}Try searching or{% endif %} <a href="{{ config.base_url | safe }}/{%- if config.extra.uglyurls %}index.html{%- endif %}">go to homepage</a>.</p> + <p>Page not found, maybe moved{% if config.languages | length > 1 %} or not in this language{% endif %}. {% if config.build_search_index %}Try searching or {% endif %}<a href="{{ config.base_url | safe }}/{%- if config.extra.uglyurls %}index.html{%- endif %}">go to homepage</a>.</p> {# Iterate through each language and display the localised 404 message #} {%- for lcode, language in config.languages -%} diff --git a/templates/base.html b/templates/base.html index 228b396..db58b72 100644 --- a/templates/base.html +++ b/templates/base.html @@ -27,9 +27,10 @@ <meta name="apple-mobile-web-app-status-bar-style" content="default" /> {{- macros_head::security(config=config) }} {{- macros_head::favicons(config=config) }} - <noscript><link rel="stylesheet" href="{{ get_url(path='nojs.css', trailing_slash=false) | safe }}" /></noscript> + {{- macros_head::pwa(config=config) }} {%- block comments_init %} {%- endblock comments_init %} + <noscript><link rel="stylesheet" href="{{ get_url(path='nojs.css', trailing_slash=false) | safe }}" /></noscript> </head> <body> {%- block header %} @@ -120,16 +121,22 @@ {{- social_macros::social_links(config=config) }} {#- Copyright START #} - {%- set copyright_start_string=config.extra.copyright_start_string | default(value="©") %} - {%- if copyright_start_string %}{%- set copyright_start_string=copyright_start_string ~ " " %}{%- endif %} - {%- set copyright_start_year=config.extra.copyright_start_year | default(value="") %} - {%- if copyright_start_year %}{%- set copyright_start_year=copyright_start_year ~ "-" %}{%- endif %} - {%- set copyright_end_year=config.extra.copyright_end_year | default(value=now() | date(format="%Y")) %} - {%- if config.extra.copyright_entity %}{%- set copyright_entity= " " ~ config.extra.copyright_entity %}{%- else %}{%- set copyright_entity= " " ~ config.title %}{%- endif %} - {%- set copyright_end_string=config.extra.copyright_end_string | default(value="") %} - {%- if copyright_end_string %}{%- set copyright_end_string= " " ~ copyright_end_string %}{%- endif %} - <p{%- if config.extra.footer_size %} class="{{ config.extra.footer_size }}"{% endif %}> {{ copyright_start_string ~ copyright_start_year ~ copyright_end_year ~ copyright_entity ~ copyright_end_string }}</p> + {%- if config.extra.copyright | default(value=true) -%} + {%- set current_year = now() | date(format="%Y") %} + + {%- if config.extra.copyright_override -%} + {%- if lang != config.default_language %} + {%- set copyright_string = trans(key="copyright_override", lang=lang) | replace(from="$CURRENT_YEAR", to=current_year) | replace(from="$SITE_TITLE", to=config.title) %} + {% else %} + {%- set copyright_string = config.extra.copyright_override | replace(from="$CURRENT_YEAR", to=current_year) | replace(from="$SITE_TITLE", to=config.title) %} + {% endif -%} + {%- else -%} + {%- set copyright_string = "© " ~ current_year ~ " " ~ config.title %} + {%- endif %} + <p{%- if config.extra.footer_size %} class="{{ config.extra.footer_size }}"{% endif %}> {{ copyright_string | safe }}</p> + {%- endif -%} {#- Copyright END #} + {%- if config.extra.menu_footer %} <nav> {%- for i in config.extra.menu_footer -%} diff --git a/templates/macros/head.html b/templates/macros/head.html index 35afa5b..2c85f16 100644 --- a/templates/macros/head.html +++ b/templates/macros/head.html @@ -7,12 +7,23 @@ {%- if config.extra.js_switcher_default %}{%- if config.extra.js_switcher_default == "light" %} {%- set js_theme="js/theme_light.min.js" -%} {%- endif %}{%- endif %} - <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 %} + <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 %} {%- 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 %} + <script defer src="{{ get_url(path=js_swload, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity | default(value=true) %} integrity="sha384-{{ get_hash(path=js_swload, sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- endif %} +{%- endmacro %} + {%- macro stylesheets(config) %} {%- set stylesheets=config.extra.stylesheets | default(value=[ "abridge.css" ]) -%} @@ -54,7 +65,7 @@ {%- macro feed(config) %} {%- if config.generate_feed %} - <link rel="alternate" type="{% if config.feed_filename is containing('atom') %}application/atom+xml{% else %}application/rss+xml{% endif %}" title="Atom/RSS Feed" href="{{ get_url(path=config.feed_filename, trailing_slash=false, lang=lang) | safe }}" /> + <link rel="alternate" type="{% if config.feed_filename is containing('atom') %}application/atom+xml{% else %}application/rss+xml{% endif %}" title="{{ config.title }} Atom/RSS Feed" href="{{ get_url(path=config.feed_filename, trailing_slash=false, lang=lang) | safe }}" /> {%- endif %} {%- endmacro %} @@ -219,8 +230,8 @@ <meta name="msapplication-TileColor" content="{{ config.extra.favicon_ms_color }}" /> {%- endif %} - {%- if config.extra.favicon_webmanifest %} - <link rel="manifest" href="{{ get_url(path=config.extra.favicon_webmanifest, trailing_slash=false) | safe }}" /> + {%- if config.extra.webmanifest %} + <link rel="manifest" href="{{ get_url(path=config.extra.webmanifest, trailing_slash=false) | safe }}" /> {%- endif %} {%- if config.extra.favicon_mask and config.extra.favicon_mask_color %} diff --git a/templates/macros/social.html b/templates/macros/social.html index 1221ce7..8661976 100644 --- a/templates/macros/social.html +++ b/templates/macros/social.html @@ -1,7 +1,7 @@ {%- macro social_links(config) %} <nav><div> {%- if config.generate_feed and config.extra.feed -%} - <a href="{{ get_url(path=config.feed_filename, trailing_slash=false, lang=lang) | safe }}" target="_blank" title="Atom/RSS Feed"><i type="Button" class="svg rss" title="Atom/RSS Feed"></i></a>{% endif -%} + <a type="{% if config.feed_filename is containing('atom') %}application/atom+xml{% else %}application/rss+xml{% endif %}" href="{{ get_url(path=config.feed_filename, trailing_slash=false, lang=lang) | safe }}" target="_blank" title="{{ config.title }} Atom/RSS Feed"><i type="Button" class="svg rss" title="{{ config.title }} Atom/RSS Feed"></i></a>{% endif -%} {%- if config.extra.mail -%} {%- if config.extra.mail_encode | default(value=true) -%} {%- set base64_email = config.extra.mail -%} diff --git a/templates/page.html b/templates/page.html index e002b31..36ff4f4 100644 --- a/templates/page.html +++ b/templates/page.html @@ -32,7 +32,7 @@ {%- block comments_init %} {%- if config.extra.comments.hyvor %} - <script async src="https://talk.hyvor.com/embed/embed.js" type="module"></script> + <script defer src="https://talk.hyvor.com/embed/embed.js" type="module"></script> {%- endif %} {%- endblock comments_init %} @@ -58,7 +58,7 @@ {%- block comments_body %} {%- if config.extra.comments.hyvor %} - <hyvor-talk-comments website-id={{ config.extra.comments.hyvor }} page-id={{ page.slug }} colors="os"></hyvor-talk-comments> + <hyvor-talk-comments website-id={{ config.extra.comments.hyvor }} page-id={{ page.slug }}{%- if config.extra.comments.hyvorcolor %} colors="{{ config.extra.comments.hyvorcolor }}"{%- endif %}></hyvor-talk-comments> {%- endif %} {%- endblock comments_body %} </article> |
