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 | |
| parent | 3e5d8a96e9eae21a799f327cd8a52adb891ebe66 (diff) | |
| download | abridge-2.0.0.tar.gz abridge-2.0.0.tar.bz2 abridge-2.0.0.zip | |
Version 2.0.0 Refactor, Add PWA Support2.0.0
| -rw-r--r-- | .github/workflows/actions.yml | 2 | ||||
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | .nojekyll | 1 | ||||
| -rw-r--r-- | COPY-TO-ROOT-SASS/abridge.scss | 2 | ||||
| -rw-r--r-- | README.md | 22 | ||||
| -rw-r--r-- | config.toml | 28 | ||||
| -rw-r--r-- | content/pages/offline.fr.md | 10 | ||||
| -rw-r--r-- | content/pages/offline.md | 10 | ||||
| -rw-r--r-- | netlify.toml | 6 | ||||
| -rw-r--r-- | package.json | 5 | ||||
| -rw-r--r-- | sass/abridge.scss | 15 | ||||
| -rw-r--r-- | sass/fonts/_Abridge.scss | 31 | ||||
| -rw-r--r-- | sass/fonts/_Arimo.scss | 17 | ||||
| -rw-r--r-- | sass/fonts/_FiraCode.scss | 5 | ||||
| -rw-r--r-- | sass/fonts/_Roboto-Mono.scss | 4 | ||||
| -rw-r--r-- | sass/fonts/_Roboto.scss | 6 | ||||
| -rw-r--r-- | screenshot.png | bin | 53621 -> 53618 bytes | |||
| -rw-r--r-- | static/font/Abridge.woff2 | bin | 768 -> 0 bytes | |||
| -rw-r--r-- | static/font/Arimo-Bold.woff2 | bin | 10008 -> 0 bytes | |||
| -rw-r--r-- | static/font/Arimo-Italic.woff2 | bin | 10972 -> 0 bytes | |||
| -rw-r--r-- | static/font/Arimo.woff2 | bin | 9988 -> 0 bytes | |||
| -rw-r--r-- | static/font/FiraCode.woff2 | bin | 21096 -> 0 bytes | |||
| -rw-r--r-- | static/fonts/Roboto-Bold.woff2 (renamed from static/font/Roboto-Bold.woff2) | bin | 15860 -> 15860 bytes | |||
| -rw-r--r-- | static/fonts/Roboto-Italic.woff2 (renamed from static/font/Roboto-Italic.woff2) | bin | 17368 -> 17368 bytes | |||
| -rw-r--r-- | static/fonts/Roboto-Mono-Italic.woff2 (renamed from static/font/Roboto-Mono-Italic.woff2) | bin | 13572 -> 13572 bytes | |||
| -rw-r--r-- | static/fonts/Roboto-Mono.woff2 (renamed from static/font/Roboto-Mono.woff2) | bin | 12312 -> 12312 bytes | |||
| -rw-r--r-- | static/fonts/Roboto.woff2 (renamed from static/font/Roboto.woff2) | bin | 15744 -> 15744 bytes | |||
| -rw-r--r-- | static/js/sw_load.js | 13 | ||||
| -rw-r--r-- | static/js/sw_load.min.js | 1 | ||||
| -rw-r--r-- | static/manifest.json (renamed from static/site.webmanifest) | 10 | ||||
| -rw-r--r-- | static/stork.st | bin | 312789 -> 0 bytes | |||
| -rw-r--r-- | static/stork.wasm | bin | 336673 -> 0 bytes | |||
| -rw-r--r-- | static/sw.js | 175 | ||||
| -rw-r--r-- | static/sw.min.js | 1 | ||||
| -rw-r--r-- | static/tinysearch_engine_bg.wasm | bin | 96681 -> 0 bytes | |||
| -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 | ||||
| -rw-r--r-- | theme.toml | 2 |
41 files changed, 310 insertions, 112 deletions
diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 24d267d..af5250c 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -23,4 +23,4 @@ jobs: uses: JamesIves/github-pages-deploy-action@v4 with: branch: master - folder: '.'
\ No newline at end of file + folder: '.' @@ -1,8 +1,8 @@ .env public themes -storage build +storage static/demo.html static/tinysearch_engine.js static/tinysearch_engine.d.ts @@ -1 +0,0 @@ - diff --git a/COPY-TO-ROOT-SASS/abridge.scss b/COPY-TO-ROOT-SASS/abridge.scss index 103d91e..855d919 100644 --- a/COPY-TO-ROOT-SASS/abridge.scss +++ b/COPY-TO-ROOT-SASS/abridge.scss @@ -3,7 +3,7 @@ /// The things your less likely to need to override have been commented out. /// Enable a centered viewport for <header>, <main>, <footer> inside <body> - /// Fluid layout until a defined size, then becomes centered viewport + /// Fluid layout until a defined size, then becomes centered viewport. //$enable-maxwidth: true, $mw: 75%,// max-width //$mb: 1200px,// value at which to switch from fluid layout to max-width @@ -121,7 +121,7 @@ $switcherDefault: "dark",// default nojs switcher mode: dark, light (make sure t js_switcher_default = "dark" # default nojs switcher mode: dark, light (make sure to also set $switcherDefault in abridge.scss) ``` -By default abrdige uses dark mode for the switcher, so unless you want to set the default mode to light for nojs visitors, then you do not need to worry about these settings. +By default abridge uses dark mode for the switcher, so unless you want to set the default mode to light for nojs visitors, then you do not need to worry about these settings. ### Number of Items per page for pagination @@ -240,6 +240,18 @@ You can see a demo on [this page](https://abridge.netlify.app/overview-math/). For better performance I recommend only enabling math on a [per page bases in your post.md files](https://github.com/Jieiku/abridge/blob/master/content/overview-math.md?plain=1#L11-L13), instead of in your main config.toml file. +### PWA (Progressive Web Application) + +Abridge theme has PWA support. You can install the entire site as an app and have it work offline. To try it out simply use google chrome or your phone and go here: https://abridge.netlify.app/ + +If using chrome on desktop then look at the end of the address bar for the install button. On android you should get a popup to install, you can also install from the 3 dot menu in the top right corner. Once you have the PWA installed, you can go completely offline and you will still be able to browse or search the site! + +To use it in your own instance you will need to edit `static/sw.js` for the list of files to cache. Technically you do not need to edit `sw.js`, but if even a single file in the cache list is missing then it wont pre cache the list, so it will only cache as you browse. + +There is an npm script to generate the file cache list and minification `npm run pwa`. My `netlify.toml` file automatically runs this npm script during site deployment, so everything is automatic. If Zola was able to template a js file then it might be possible to generate the list of cache files dynamically at build. + +The PWA feature is also easy to disable by simply setting `pwa = false` in `config.toml` + ## Javascript files These are the javascript files currently used by Abridge: @@ -252,6 +264,8 @@ These are the javascript files currently used by Abridge: - theme.js: tiny script to facilitate local storage for the theme switcher. (never bundle, always separate) - theme_button.js: tiny script for the theme switcher function when you click the theme switch button. - prestyle.js: Used to preload css files `<link rel="preload"` - this script changes these to `<link rel="stylesheet"` once the page has finished loading, this allows us to load stylesheets for external fonts, fontawesome, or katex in a non blocking fashion. +- sw.js: this is the Service Worker file for the PWA. +- sw_load.js: this file handles loading the Service Worker for the PWA. ### js_bundle option @@ -397,14 +411,12 @@ Nginx does not come by default with brotli support, but adding it was not diffic ## Contributing and Philosophy -We'd love your help! Especially with fixes to issues. +We'd love your help! Especially with fixes to issues, or improvements to existing features. -The overall idea behind abridge is to be lightweight, fast, and to work properly even if javascript is disabled. +The goal is for abridge to be lightweight, fast, and to work properly even if javascript is disabled or blocked. The only feature that may be considered a necessity that relies on javascript is the Search. -New features that rely on javascript will do so with it disabled by default unless lightweight and useful. - ## License **abridge** is distributed under the terms of the [MIT license](https://github.com/jieiku/abridge/blob/master/LICENSE). diff --git a/config.toml b/config.toml index 495a088..09c414d 100644 --- a/config.toml +++ b/config.toml @@ -58,13 +58,10 @@ Sitemap = "Plan du site" 404_try_search = "Essayez de rechercher ou" ### go to homepage 404_go_home = "allez à la page d'accueil" +copyright_override = '© $CURRENT_YEAR $SITE_TITLE • Le contenu du site Web est sous licence <a rel="noopener" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>.' #[languages.es.translations] #flag = "🇪🇸" -#about = "Acerca de" -#posts = "Publicaciones" -#categories = "Categorías" -#tags = "Etiquetas" [search] # Options specific to elasticlunr search. index_format = "elasticlunr_json" # elasticlunr_json, elasticlunr_javascript @@ -138,11 +135,11 @@ sitedesc = false # enables or disables the display of the site description below headhr = false # show or hide horizontal rule below header foothr = true # show or hide horizontal rule above footer -#copyright_start_string = "©" -#copyright_start_year = 2019 # optional -#copyright_end_year = "" # optional, recommend leaving unset, zola build will set this to current year by default, can use empty string to omit the year. -#copyright_entity = "MyName." # optional, if ommited then the config.title is used. -#copyright_end_string = 'Unless otherwise noted, the content in this website is available under the <a href="http://creativecommons.org/licenses/by-nd/3.0/">CC BY-ND 3.0</a> license.' +### $CURRENT_YEAR and $SITE_TITLE can be used anywhere within the copyright, you can change their position or you can also delete them and type whatever you want instead. +#copyright = false # set to false to disable the copyright. +#copyright_override = '© 2019-$CURRENT_YEAR $SITE_TITLE' +#copyright_override = '© $CURRENT_YEAR $SITE_TITLE • Website content is licensed <a rel="noopener" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>.' + ############################################################################### ### meta/seo/analytic tags @@ -194,6 +191,15 @@ researchgate = "your-profile-id" ############################################################################### +### Commenting System for visitors to leave comments on pages. +### hyvor talk +############################################################################### + +#comments.hyvor = "9366" # hyvor website id, comment out to disable. +#comments.hyvorcolor = "os" # set the color property for hyvor + + +############################################################################### ### Resource Files ### You can load extra css files if you need to, just separate by comma: ### stylesheets = [ "abridge.css", "extra.css" ] @@ -217,9 +223,12 @@ search_library = 'elasticlunr' #js_prestyle = "js/prestyle.js"# Bundleable - used to preload: FontAwesome, Katex, external Google Fonts #js_codecopy = "js/codecopy.js"# Bundleable - copy code block to clipboard button #js_email = "js/email.js"# Bundleable - obfuscates email address in footer +#js_swload = "js/sw_load.min.js" # loads the PWA service worker stylesheets = ["abridge.css"] +pwa = true # true to load the service worker +webmanifest = "manifest.json" # Required for PWAs ############################################################################### ### Favicons, comment out a line to disable loading some or all of these if needed. @@ -227,7 +236,6 @@ stylesheets = ["abridge.css"] favicon_theme_color = "#333333" favicon_ms_color = "#333333" -favicon_webmanifest = "site.webmanifest" # Used for android-chrome-512x512.png and android-chrome-192x192.png favicon_mask = "safari-pinned-tab.svg" # safari-pinned-tab.svg favicon_mask_color = "#ff9900" favicon_svg = "favicon.svg" # favicon.svg diff --git a/content/pages/offline.fr.md b/content/pages/offline.fr.md new file mode 100644 index 0000000..e97502a --- /dev/null +++ b/content/pages/offline.fr.md @@ -0,0 +1,10 @@ ++++ +title = "Mode hors-ligne" +path = "fr/offline" +template = "pages.html" +draft = false ++++ + +## Mode hors-ligne + +Désolé, aucun cache n'a été trouvé et il semble que vous soyez hors ligne, une connexion est requise. diff --git a/content/pages/offline.md b/content/pages/offline.md new file mode 100644 index 0000000..e92c32e --- /dev/null +++ b/content/pages/offline.md @@ -0,0 +1,10 @@ ++++ +title = "Offline Mode" +path = "offline" +template = "pages.html" +draft = false ++++ + +## Offline Mode + +Sorry, no cache found and it looks like you’re offline, a connection is required. diff --git a/netlify.toml b/netlify.toml index 3356614..ec75f60 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,12 +1,12 @@ [build] publish = "public" -command = "zola build && npm run abridge-demo && zola build" +command = "zola build && npm run pwa && zola build" [build.environment] ZOLA_VERSION = "0.17.2" [context.deploy-preview] -command = "zola build --base-url $DEPLOY_PRIME_URL && npm run abridge-demo && zola build --base-url $DEPLOY_PRIME_URL" +command = "zola build --base-url $DEPLOY_PRIME_URL && npm run pwa && zola build --base-url $DEPLOY_PRIME_URL" [[headers]] for = "/*" @@ -16,4 +16,4 @@ command = "zola build --base-url $DEPLOY_PRIME_URL && npm run abridge-demo && zo X-XSS-Protection = "1; mode=block" Referrer-Policy = "strict-origin-when-cross-origin" Strict-Transport-Security = "max-age=63072000; includeSubdomains" - Content-Security-Policy = "default-src 'none'; frame-ancestors 'none'; object-src 'none'; base-uri 'self'; manifest-src 'self'; connect-src 'self'; form-action 'self'; script-src 'self'; img-src 'self' data: cdn.cloudflare.com; frame-src 'self' www.youtube-nocookie.com player.vimeo.com; media-src 'self' data: cdn.cloudflare.com www.youtube-nocookie.com player.vimeo.com; font-src 'self' cdn.cloudflare.com cdn.jsdelivr.net fonts.gstatic.com; style-src 'self' cdn.cloudflare.com cdn.jsdelivr.net fonts.googleapis.com;" + Content-Security-Policy = "default-src 'none'; frame-ancestors 'none'; object-src 'none'; base-uri 'self'; manifest-src 'self'; worker-src 'self'; form-action 'self'; connect-src 'self' *.hyvor.com ws://*.hyvor.com; script-src 'self' talk.hyvor.com; img-src 'self' data: talk.hyvor.com cdn.cloudflare.com; frame-src 'self' www.youtube-nocookie.com player.vimeo.com streamable.com www.streamable.com; media-src 'self' data: cdn.cloudflare.com www.youtube-nocookie.com player.vimeo.com; font-src 'self' cdn.cloudflare.com cdn.jsdelivr.net fonts.gstatic.com; style-src 'self' talk.hyvor.com cdn.cloudflare.com cdn.jsdelivr.net fonts.googleapis.com;" diff --git a/package.json b/package.json index 9514ab9..0f234e1 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,11 @@ "license": "MIT", "homepage": "https://github.com/Jieiku/abridge", "scripts": { - "all": "npm run theme && npm run theme-light && npm run katex-bundle && npm run search-elasticlunr && npm run search-stork && npm run search-tinysearch && npm run abridge-bundle-elasticlunr", - "nonbundles": "npm run theme && npm run theme-light && npm run katex-bundle && npm run search-elasticlunr && npm run search-stork && npm run search-tinysearch", + "all": "npm run theme && npm run theme-light && npm run pwa && npm run katex-bundle && npm run search-elasticlunr && npm run search-stork && npm run search-tinysearch && npm run abridge-bundle-elasticlunr", + "nonbundles": "npm run theme && npm run theme-light && npm run pwa && npm run katex-bundle && npm run search-elasticlunr && npm run search-stork && npm run search-tinysearch", "theme": "uglifyjs static/js/theme.js -c -m -o static/js/theme.min.js", "theme-light": "uglifyjs static/js/theme_light.js -c -m -o static/js/theme_light.min.js", + "pwa": "CACHEFILES=$(find public -type f | sed 's/^public//' | sed 's/^\\/sw\\..*//' | sed 's/.*sw_load.*//' | sed 's/index.html//' | sed 's/.*stork.*//' | sed 's/.*tinysearch.*//' | sort | uniq | sed '/^$/d' | sed \"s/\\(.*\\)/'\\1'/\" | tr '\\n' ',' | uniq | sed 's/.$//' | sed \"s/\\(.*\\)/BASE_CACHE_FILES = \\[\\1\\];/\") && echo $CACHEFILES && sed -i \"s|BASE_CACHE_FILES =.*|$CACHEFILES|\" 'static/sw.js' && uglifyjs static/js/sw_load.js -c -m -o static/js/sw_load.min.js && uglifyjs static/sw.js -c -m -o static/sw.min.js", "katex-bundle": "uglifyjs static/js/katex.min.js static/js/mathtex-script-type.min.js static/js/katex-auto-render.min.js static/js/katexoptions.js -c -m -o static/js/katexbundle.min.js", "search-elasticlunr": "uglifyjs static/js/elasticlunr.min.js static/js/search.js -c -m -o static/js/search_elasticlunr.min.js", "search-stork": "uglifyjs static/js/stork.js static/js/stork_config.js -c -m -o static/js/search_stork.min.js", diff --git a/sass/abridge.scss b/sass/abridge.scss index 2cde0d3..889ce78 100644 --- a/sass/abridge.scss +++ b/sass/abridge.scss @@ -672,8 +672,14 @@ $syntax: true !default;//syntax highlighting for code blocks text-align: right; } } - footer nav > a { - margin: .2rem; + //footer nav > + footer nav { + a { + margin: .2rem; + } + i { + margin-bottom: .2rem; + } } header > nav > div:first-of-type {//Keep the logo from wrapping display: inline; @@ -736,11 +742,6 @@ $syntax: true !default;//syntax highlighting for code blocks .mode:hover, .cnav { color: var(--a1);//pagination color current page } - footer nav { - i { - margin: 0 .2rem .4rem; - } - } //dropdown menu used for lang, etc. .dropdown { display: inline-block; diff --git a/sass/fonts/_Abridge.scss b/sass/fonts/_Abridge.scss deleted file mode 100644 index 6626626..0000000 --- a/sass/fonts/_Abridge.scss +++ /dev/null @@ -1,31 +0,0 @@ -// This is for the Abridge icon font, the css for this is adapted from fontello. -// I experimented using this, it is still here for those that want it, but not used by default. -// It is a pretty lightweight solution, but still not as good as svg icons directly in the css. -// The loading of icon fonts is blocked by noscript type browser addons, but css icons are not. - -@font-face { - font-family: 'Abridge'; - src: url('font/Abridge.woff2') format('woff2'); -} - -[class^="i-"]:before, [class*=" i-"]:before { - font-family: "Abridge"; - font-style: normal; - font-weight: normal; - font-variant: normal;// reset parent styles that can break glyph codes - text-transform: none;// reset parent styles that can break glyph codes - line-height: 1em;// fix buttons height - width: 1em;// fix buttons width - vertical-align: 1em;// fix buttons alignment - text-align: center; - display: inline-block; - //text-decoration: inherit; -} - -.i-search:before { content: '\f002'; } // search box button -.i-adjust:before { content: '\f042'; } // theme switcher button -.i-first:before { content: '\f100'; } // pagination first page -.i-last:before { content: '\f101'; } // pagination last page -.i-prev:before { content: '\f104'; } // pagination previous page -.i-next:before { content: '\f105'; } // pagination next page -.i-up:before { content: '\f106'; } // back to top button diff --git a/sass/fonts/_Arimo.scss b/sass/fonts/_Arimo.scss deleted file mode 100644 index 8931d79..0000000 --- a/sass/fonts/_Arimo.scss +++ /dev/null @@ -1,17 +0,0 @@ -@font-face { - font-family: 'Arimo'; - src: local("Arimo"), url("font/Arimo.woff2");//latin regular - font-display: swap; -} -@font-face { - font-family: 'Arimo'; - src: local("Arimo-Italic"), url("font/Arimo-Italic.woff2");//latin italic - font-style: italic; - font-display: swap; -} -@font-face { - font-family: 'Arimo'; - src: local("Arimo-Bold"), url("font/Arimo-Bold.woff2");//latin bold - font-weight: bold; - font-display: swap; -} diff --git a/sass/fonts/_FiraCode.scss b/sass/fonts/_FiraCode.scss deleted file mode 100644 index a20f4d7..0000000 --- a/sass/fonts/_FiraCode.scss +++ /dev/null @@ -1,5 +0,0 @@ -@font-face { - font-family: 'Fira Code'; - src: local("Fira Code"), url("font/FiraCode.woff2");//latin regular - font-display: swap; -} diff --git a/sass/fonts/_Roboto-Mono.scss b/sass/fonts/_Roboto-Mono.scss index 0685c3d..88040d4 100644 --- a/sass/fonts/_Roboto-Mono.scss +++ b/sass/fonts/_Roboto-Mono.scss @@ -1,11 +1,11 @@ @font-face { font-family: 'Roboto Mono'; - src: local("Roboto Mono"), local("Roboto-Mono"), local("RobotoMono"), local("Roboto-Mono-Regular"), local("RobotoMono-Regular"), url("font/Roboto-Mono.woff2");//latin regular + src: local("Roboto Mono"), local("Roboto-Mono"), local("RobotoMono"), local("Roboto-Mono-Regular"), local("RobotoMono-Regular"), url("fonts/Roboto-Mono.woff2");//latin regular font-display: swap; } @font-face { font-family: 'Roboto Mono'; - src: local("Roboto Mono Italic"), local("Roboto-Mono-Italic"), local("RobotoMono-Italic"), url("font/Roboto-Mono-Italic.woff2");//latin italic + src: local("Roboto Mono Italic"), local("Roboto-Mono-Italic"), local("RobotoMono-Italic"), url("fonts/Roboto-Mono-Italic.woff2");//latin italic font-style: italic; font-display: swap; } diff --git a/sass/fonts/_Roboto.scss b/sass/fonts/_Roboto.scss index 6370fc2..78bed1f 100644 --- a/sass/fonts/_Roboto.scss +++ b/sass/fonts/_Roboto.scss @@ -1,17 +1,17 @@ @font-face { font-family: 'Roboto'; - src: local("Roboto"), url("font/Roboto.woff2");//latin regular + src: local("Roboto"), url("fonts/Roboto.woff2");//latin regular font-display: swap; } @font-face { font-family: 'Roboto'; - src: local("Roboto-Italic"), url("font/Roboto-Italic.woff2");//latin italic + src: local("Roboto-Italic"), url("fonts/Roboto-Italic.woff2");//latin italic font-style: italic; font-display: swap; } @font-face { font-family: 'Roboto'; - src: local("Roboto-Bold"), url("font/Roboto-Bold.woff2");//latin bold + src: local("Roboto-Bold"), url("fonts/Roboto-Bold.woff2");//latin bold font-weight: bold; font-display: swap; } diff --git a/screenshot.png b/screenshot.png Binary files differindex ec8d65f..6f1ce33 100644 --- a/screenshot.png +++ b/screenshot.png diff --git a/static/font/Abridge.woff2 b/static/font/Abridge.woff2 Binary files differdeleted file mode 100644 index 2ce0193..0000000 --- a/static/font/Abridge.woff2 +++ /dev/null diff --git a/static/font/Arimo-Bold.woff2 b/static/font/Arimo-Bold.woff2 Binary files differdeleted file mode 100644 index cff36d9..0000000 --- a/static/font/Arimo-Bold.woff2 +++ /dev/null diff --git a/static/font/Arimo-Italic.woff2 b/static/font/Arimo-Italic.woff2 Binary files differdeleted file mode 100644 index 2adf459..0000000 --- a/static/font/Arimo-Italic.woff2 +++ /dev/null diff --git a/static/font/Arimo.woff2 b/static/font/Arimo.woff2 Binary files differdeleted file mode 100644 index f10b6c5..0000000 --- a/static/font/Arimo.woff2 +++ /dev/null diff --git a/static/font/FiraCode.woff2 b/static/font/FiraCode.woff2 Binary files differdeleted file mode 100644 index 41a8ef1..0000000 --- a/static/font/FiraCode.woff2 +++ /dev/null diff --git a/static/font/Roboto-Bold.woff2 b/static/fonts/Roboto-Bold.woff2 Binary files differindex 771fbec..771fbec 100644 --- a/static/font/Roboto-Bold.woff2 +++ b/static/fonts/Roboto-Bold.woff2 diff --git a/static/font/Roboto-Italic.woff2 b/static/fonts/Roboto-Italic.woff2 Binary files differindex e1b7a79..e1b7a79 100644 --- a/static/font/Roboto-Italic.woff2 +++ b/static/fonts/Roboto-Italic.woff2 diff --git a/static/font/Roboto-Mono-Italic.woff2 b/static/fonts/Roboto-Mono-Italic.woff2 Binary files differindex ece53bd..ece53bd 100644 --- a/static/font/Roboto-Mono-Italic.woff2 +++ b/static/fonts/Roboto-Mono-Italic.woff2 diff --git a/static/font/Roboto-Mono.woff2 b/static/fonts/Roboto-Mono.woff2 Binary files differindex f8894ba..f8894ba 100644 --- a/static/font/Roboto-Mono.woff2 +++ b/static/fonts/Roboto-Mono.woff2 diff --git a/static/font/Roboto.woff2 b/static/fonts/Roboto.woff2 Binary files differindex 020729e..020729e 100644 --- a/static/font/Roboto.woff2 +++ b/static/fonts/Roboto.woff2 diff --git a/static/js/sw_load.js b/static/js/sw_load.js new file mode 100644 index 0000000..b38f118 --- /dev/null +++ b/static/js/sw_load.js @@ -0,0 +1,13 @@ +if ("serviceWorker" in navigator) { + navigator.serviceWorker + .register("/sw.min.js?v=3.7.6", { scope: "/" }) + .then(() => { + console.info("SW Loaded"); + }, err => console.error("SW error: ", err)); + + navigator.serviceWorker + .ready + .then(() => { + console.info("SW Ready"); + }); +} diff --git a/static/js/sw_load.min.js b/static/js/sw_load.min.js new file mode 100644 index 0000000..c6cd8a1 --- /dev/null +++ b/static/js/sw_load.min.js @@ -0,0 +1 @@ +"serviceWorker"in navigator&&(navigator.serviceWorker.register("/sw.min.js?v=3.7.6",{scope:"/"}).then(()=>{console.info("SW Loaded")},e=>console.error("SW error: ",e)),navigator.serviceWorker.ready.then(()=>{console.info("SW Ready")}));
\ No newline at end of file diff --git a/static/site.webmanifest b/static/manifest.json index 8634a6c..04ed38b 100644 --- a/static/site.webmanifest +++ b/static/manifest.json @@ -2,11 +2,13 @@ "name": "Abridge Zola Theme", "short_name": "Abridge", "description": "Fast & Lightweight Zola Theme", - "start_url": "/index.html", - "scope": "/", - "background_color": "#111111", - "theme_color": "#222222", + "background_color": "#111", + "theme_color": "#222", "display": "standalone", + "orientation": "any", + "start_url": "/", + "scope": "/", + "categories": ["developer", "development", "productivity"], "icons": [ { "src": "/android-chrome-192x192.png", diff --git a/static/stork.st b/static/stork.st Binary files differdeleted file mode 100644 index a6aafe2..0000000 --- a/static/stork.st +++ /dev/null diff --git a/static/stork.wasm b/static/stork.wasm Binary files differdeleted file mode 100644 index 82559be..0000000 --- a/static/stork.wasm +++ /dev/null diff --git a/static/sw.js b/static/sw.js new file mode 100644 index 0000000..4a2b0db --- /dev/null +++ b/static/sw.js @@ -0,0 +1,175 @@ +class Pwa {
+
+ constructor(self) {
+ this.scope = self;
+ const Version = new URL(location).searchParams.get("v");
+ this.CACHE_VERSION = Version;
+ //this.BASE_CACHE_FILES=['/js/theme.min.js','/js/theme_light.min.js','/abridge.css','/js/abridge.min.js','/','/404.html','/offline/','/manifest.json'];
+ this.BASE_CACHE_FILES = ['/js/theme.min.js','/js/theme_light.min.js','/abridge.css','/js/abridge.min.js','/','/404.html','/offline/','/manifest.json'];
+ this.host = `${self.location.protocol}//${self.location.host}`;
+ console.info(`Host: ${this.host}`);
+ this.OFFLINE_PAGE = '/offline/';
+ this.NOT_FOUND_PAGE = '/404.html';
+ this.CACHE_NAME = `content-v${this.CACHE_VERSION}`;
+ // 3600=1hour, 28800=8hours, 86400=1day, 604800=1week, 1209600=2weeks
+ this.NORM_TTL = 86400;// html, json, xml, anything else undefined
+ this.LONG_TTL = 604800;// js, css
+ // rarely change, may be a good idea to periodically refresh, incase I change these and forget to increment service worker version:
+ this.TTL_LONG = ["js", "css"];
+ // never change, cache forever unless service worker version is incremented:
+ this.TTL_EXEMPT = ["jpg", "jpeg", "png", "gif", "webp", "avif", "ico", "svg", "otf", "eot", "ttf", "woff", "woff2", "xml", "xsl", "txt", "mp4", "webm", "mp3", "ogg"];
+ // skip these extensions so they expire same time as html: st,wasm,json(search), xml(sitemap,atom,rss)
+ }
+
+ canCache(url) {
+ if (url.startsWith("http://localhost")) {
+ return false;
+ }
+ const result = url.toString().startsWith(this.host);
+ return result;
+ }
+
+ getFileExtension(url) {
+ const extension = url.split('.').reverse()[0].split('?')[0];
+ return (extension.endsWith('/')) ? '/' : extension;
+ }
+
+ getTTL(url) {
+ if (typeof url === 'string') {
+ const extension = this.getFileExtension(url);
+ if (this.TTL_LONG.indexOf(extension) > -1) {
+ //console.info(url + ' contains a TTL_LONG extension');
+ return this.LONG_TTL;
+ }
+ if (this.TTL_EXEMPT.indexOf(extension) > -1) {
+ //console.info(url + ' contains a TTL_EXEMPT extension');
+ return null;
+ }
+ return this.NORM_TTL;
+ }
+ return null;
+ }
+
+ async installServiceWorker() {
+ try {
+ await caches.open(this.CACHE_NAME).then((cache) => {
+ return cache.addAll(this.BASE_CACHE_FILES);
+ }, err => console.error(`Error with ${this.CACHE_NAME}`, err));
+ return this.scope.skipWaiting();
+ }
+ catch (err) {
+ return console.error("Error with installation: ", err);
+ }
+ }
+
+ cleanupLegacyCache() {
+
+ const currentCaches = [this.CACHE_NAME];
+
+ return new Promise(
+ (resolve, reject) => {
+ caches.keys()
+ .then((keys) => keys.filter((key) => !~currentCaches.indexOf(key)))
+ .then((legacy) => {
+ if (legacy.length) {
+ Promise.all(legacy.map((legacyKey) => caches.delete(legacyKey))
+ ).then(() => resolve()).catch((err) => {
+ console.error("Error in legacy cleanup: ", err);
+ reject(err);
+ });
+ } else {
+ resolve();
+ }
+ }).catch((err) => {
+ console.error("Error in legacy cleanup: ", err);
+ reject(err);
+ });
+ });
+ }
+
+ async preCacheUrl(url) {
+ const cache = await caches.open(this.CACHE_NAME);
+ const response = await cache.match(url);
+ if (!response) {
+ return fetch(url).then(resp => cache.put(url, resp.clone()));
+ }
+ return null;
+ }
+
+ register() {
+ this.scope.addEventListener('install', event => {
+ event.waitUntil(
+ Promise.all([
+ this.installServiceWorker(),
+ this.scope.skipWaiting(),
+ ]));
+ console.info('SW Installed');
+ });
+
+ this.scope.addEventListener('activate', event => {
+ event.waitUntil(Promise.all(
+ [this.cleanupLegacyCache(),
+ this.scope.clients.claim(),
+ this.scope.skipWaiting()]).catch((err) => {
+ console.error("Activation error: ", err);
+ event.skipWaiting();
+ }));
+ });
+
+ this.scope.addEventListener('fetch', event => {
+ event.respondWith(
+ caches.open(this.CACHE_NAME).then(async cache => {
+ // check if this is NOT a resource we allow cacheing (some other domain), if so fetch it instead of cache.
+ if (!this.canCache(event.request.url)) {
+ return fetch(event.request);
+ }
+ // check the cache for the requested resource
+ const response = await cache.match(event.request);
+ if (response) {
+ const headers = response.headers.entries();
+ let date = null;
+ for (let pair of headers) {
+ if (pair[0] === 'date') {
+ date = new Date(pair[1]);
+ break;
+ }
+ }
+ // date is not working, so ignore TTL and just serve the cached resource.
+ if (!date) {
+ return response;
+ }
+ const age = parseInt(((new Date().getTime() - date.getTime()) / 1000).toString());
+ const ttl = this.getTTL(event.request.url);
+ if (ttl === null || (ttl && age < ttl)) {
+ // return the resource if it is not beyond the TTL
+ return response;
+ }
+ }
+ // if we made it here then we either did not have the cache, or the TTL was expired.
+ return fetch(event.request.clone()).then(resp => {
+ if (resp.status < 400) {
+ if (this.canCache(event.request.url)) {
+ cache.put(event.request, resp.clone());
+ }
+ return resp;
+ }
+ else {
+ return cache.match(this.NOT_FOUND_PAGE);
+ }
+ }).catch(err => {
+ // if we made it here then we were unable to fetch the resource.
+ // maybe we were only fetching because of expired TTL, so use the cache regardless of TTL:
+ if (response) {
+ return response;
+ }
+ // if we made it here then we were unable to fetch the resource and do not have it cached.
+ console.error(`Error fetching ${event.request.url} resulted in offline`, err);
+ return cache.match(this.OFFLINE_PAGE);
+ })
+ }));
+ });
+ }
+}
+
+const pwa = new Pwa(self);
+pwa.register();
diff --git a/static/sw.min.js b/static/sw.min.js new file mode 100644 index 0000000..c05bb61 --- /dev/null +++ b/static/sw.min.js @@ -0,0 +1 @@ +class Pwa{constructor(e){this.scope=e;var s=new URL(location).searchParams.get("v");this.CACHE_VERSION=s,this.BASE_CACHE_FILES=["/","/404.html","/about/","/abridge.css","/android-chrome-192x192m.png","/android-chrome-192x192.png","/android-chrome-512x512.png","/apple-touch-icon.png","/archive/","/atom.xml","/banner.png","/blog/","/blog/blog-section/","/blog/page/1/","/browserconfig.xml","/categories/","/categories/features/","/categories/features/atom.xml","/contact/","/elasticlunr.min.js","/favicon-16x16.png","/favicon-32x32.png","/favicon.ico","/favicon.svg","/font/Abridge.woff2","/font/Arimo-Bold.woff2","/font/Arimo-Italic.woff2","/font/Arimo.woff2","/font/FiraCode.woff2","/font/Roboto-Bold.woff2","/font/Roboto-Italic.woff2","/font/Roboto-Mono-Italic.woff2","/font/Roboto-Mono.woff2","/font/Roboto.woff2","/fonts/KaTeX_AMS-Regular.woff2","/fonts/KaTeX_Caligraphic-Bold.woff2","/fonts/KaTeX_Caligraphic-Regular.woff2","/fonts/KaTeX_Fraktur-Bold.woff2","/fonts/KaTeX_Fraktur-Regular.woff2","/fonts/KaTeX_Main-BoldItalic.woff2","/fonts/KaTeX_Main-Bold.woff2","/fonts/KaTeX_Main-Italic.woff2","/fonts/KaTeX_Main-Regular.woff2","/fonts/KaTeX_Math-BoldItalic.woff2","/fonts/KaTeX_Math-Italic.woff2","/fonts/KaTeX_SansSerif-Bold.woff2","/fonts/KaTeX_SansSerif-Italic.woff2","/fonts/KaTeX_SansSerif-Regular.woff2","/fonts/KaTeX_Script-Regular.woff2","/fonts/KaTeX_Size1-Regular.woff2","/fonts/KaTeX_Size2-Regular.woff2","/fonts/KaTeX_Size3-Regular.woff2","/fonts/KaTeX_Size4-Regular.woff2","/fonts/KaTeX_Typewriter-Regular.woff2","/fr/","/fr/about/","/fr/archive/","/fr/atom.xml","/fr/blog/","/fr/blog/blog-section/","/fr/blog/page/1/","/fr/categories/","/fr/categories/features/","/fr/categories/features/atom.xml","/fr/contact/","/fr/offline/","/fr/overview-abridge/","/fr/overview-code-blocks/","/fr/overview-embed-streamable/","/fr/overview-embed-vimeo/","/fr/overview-embed-youtube/","/fr/overview-images/","/fr/overview-images/corro.svg","/fr/overview-images/ferris-gesture.png","/fr/overview-images/ferris-gesture.svg","/fr/overview-images/ferris-happy.svg","/fr/overview-images/ferris.svg","/fr/overview-images/img/ferris-gesture.svg","/fr/overview-images/img/ferris.svg","/fr/overview-markdown-and-style/","/fr/overview-math/","/fr/overview-rich-content/","/fr/overview-rich-content/ferris-gesture.svg","/fr/overview-rich-content/ferris.svg","/fr/overview-rich-content/over9000-400.avif","/fr/overview-rich-content/over9000-640.avif","/fr/overview-rich-content/over9000-640.webp","/fr/overview-rich-content/over9000-960.avif","/fr/overview-rich-content/over9000_av1.mp4","/fr/overview-rich-content/over9000.mp3","/fr/overview-rich-content/over9000.ogg","/fr/overview-rich-content/over9000_vp9.webm","/fr/page/1/","/fr/page/2/","/fr/page/3/","/fr/page/4/","/fr/posts/","/fr/posts/posts-section/","/fr/privacy/","/fr/tags/","/fr/tags/audio/","/fr/tags/audio/atom.xml","/fr/tags/config/","/fr/tags/config/atom.xml","/fr/tags/images/","/fr/tags/images/atom.xml","/fr/tags/markdown/","/fr/tags/markdown/atom.xml","/fr/tags/mathematics/","/fr/tags/mathematics/atom.xml","/fr/tags/shortcodes/","/fr/tags/shortcodes/atom.xml","/fr/tags/video/","/fr/tags/video/atom.xml","/js/abridge.min.js","/js/codecopy.js","/js/elasticlunr.min.js","/js/email.js","/js/katex-auto-render.min.js","/js/katexbundle.min.js","/js/katex.min.js","/js/katexoptions.js","/js/lunr.da.js","/js/lunr.da.min.js","/js/lunr.de.js","/js/lunr.de.min.js","/js/lunr.du.js","/js/lunr.du.min.js","/js/lunr.es.js","/js/lunr.es.min.js","/js/lunr.fi.js","/js/lunr.fi.min.js","/js/lunr.fr.js","/js/lunr.fr.min.js","/js/lunr.hu.js","/js/lunr.hu.min.js","/js/lunr.it.js","/js/lunr.it.min.js","/js/lunr.jp.js","/js/lunr.jp.min.js","/js/lunr.no.js","/js/lunr.no.min.js","/js/lunr.pt.js","/js/lunr.pt.min.js","/js/lunr.ro.js","/js/lunr.ro.min.js","/js/lunr.ru.js","/js/lunr.ru.min.js","/js/lunr.stemmer.support.js","/js/lunr.stemmer.support.min.js","/js/lunr.sv.js","/js/lunr.sv.min.js","/js/lunr.tr.js","/js/lunr.tr.min.js","/js/lunr.zh.js","/js/lunr.zh.min.js","/js/mathtex-script-type.min.js","/js/prestyle.js","/js/search_elasticlunr.min.js","/js/searchjava.js","/js/searchjavaugly.js","/js/search.js","/js/theme_button.js","/js/theme.js","/js/theme_light.js","/js/theme_light.min.js","/js/theme.min.js","/katex.min.css","/manifest.json","/mstile-150x150.png","/nojs.css","/offline/","/overview-abridge/","/overview-code-blocks/","/overview-embed-streamable/","/overview-embed-vimeo/","/overview-embed-youtube/","/overview-images/","/overview-images/corro.svg","/overview-images/ferris-gesture.png","/overview-images/ferris-gesture.svg","/overview-images/ferris-happy.svg","/overview-images/ferris.svg","/overview-images/img/ferris-gesture.svg","/overview-images/img/ferris.svg","/overview-markdown-and-style/","/overview-math/","/overview-rich-content/","/overview-rich-content/ferris-gesture.svg","/overview-rich-content/ferris.svg","/overview-rich-content/over9000-400.avif","/overview-rich-content/over9000-640.avif","/overview-rich-content/over9000-640.webp","/overview-rich-content/over9000-960.avif","/overview-rich-content/over9000_av1.mp4","/overview-rich-content/over9000.mp3","/overview-rich-content/over9000.ogg","/overview-rich-content/over9000_vp9.webm","/page/1/","/page/2/","/page/3/","/page/4/","/posts/","/posts/posts-section/","/privacy/","/robots.txt","/safari-pinned-tab.svg","/search_index.en.json","/search_index.fr.json","/sitemap.xml","/tags/","/tags/audio/","/tags/audio/atom.xml","/tags/config/","/tags/config/atom.xml","/tags/images/","/tags/images/atom.xml","/tags/markdown/","/tags/markdown/atom.xml","/tags/mathematics/","/tags/mathematics/atom.xml","/tags/shortcodes/","/tags/shortcodes/atom.xml","/tags/video/","/tags/video/atom.xml"],this.host=e.location.protocol+"//"+e.location.host,console.info("Host: "+this.host),this.OFFLINE_PAGE="/offline/",this.NOT_FOUND_PAGE="/404.html",this.CACHE_NAME="content-v"+this.CACHE_VERSION,this.NORM_TTL=86400,this.LONG_TTL=1209600,this.TTL_LONG=["js","css"],this.TTL_EXEMPT=["jpg","jpeg","png","gif","webp","avif","ico","svg","otf","eot","ttf","woff","woff2","xml","xsl","txt","mp4","webm","mp3","ogg"]}canCache(e){return!e.startsWith("http://localhost")&&e.toString().startsWith(this.host)}getFileExtension(e){e=e.split(".").reverse()[0].split("?")[0];return e.endsWith("/")?"/":e}getTTL(e){var s;return"string"!=typeof e||(s=this.getFileExtension(e),-1<this.TTL_LONG.indexOf(s)&&console.info(e+" contains a TTL_LONG extension"),-1<this.TTL_EXEMPT.indexOf(s)&&console.info(e+" contains a TTL_EXEMPT extension"),~this.TTL_EXEMPT.indexOf(s))?null:this.NORM_TTL}async installServiceWorker(){try{return await caches.open(this.CACHE_NAME).then(e=>e.addAll(this.BASE_CACHE_FILES),e=>console.error("Error with "+this.CACHE_NAME,e)),this.scope.skipWaiting()}catch(e){return console.error("Error with installation: ",e)}}cleanupLegacyCache(){const t=[this.CACHE_NAME];return new Promise((s,r)=>{caches.keys().then(e=>e.filter(e=>!~t.indexOf(e))).then(e=>{e.length?Promise.all(e.map(e=>caches.delete(e))).then(()=>s()).catch(e=>{console.error("Error in legacy cleanup: ",e),r(e)}):s()}).catch(e=>{console.error("Error in legacy cleanup: ",e),r(e)})})}async preCacheUrl(s){const r=await caches.open(this.CACHE_NAME);return await r.match(s)?null:fetch(s).then(e=>r.put(s,e.clone()))}register(){this.scope.addEventListener("install",e=>{e.waitUntil(Promise.all([this.installServiceWorker(),this.scope.skipWaiting()])),console.info("SW Installed")}),this.scope.addEventListener("activate",s=>{s.waitUntil(Promise.all([this.cleanupLegacyCache(),this.scope.clients.claim(),this.scope.skipWaiting()]).catch(e=>{console.error("Activation error: ",e),s.skipWaiting()}))}),this.scope.addEventListener("fetch",a=>{a.respondWith(caches.open(this.CACHE_NAME).then(async s=>{if(!this.canCache(a.request.url))return fetch(a.request);const r=await s.match(a.request);if(r){var t;let e=null;for(t of r.headers.entries())if("date"===t[0]){e=new Date(t[1]);break}if(!e)return r;var o=parseInt((((new Date).getTime()-e.getTime())/1e3).toString()),i=this.getTTL(a.request.url);if(null===i||i&&o<i)return r}return fetch(a.request.clone()).then(e=>e.status<400?(this.canCache(a.request.url)&&s.put(a.request,e.clone()),e):s.match(this.NOT_FOUND_PAGE)).catch(e=>r||(console.error(`Error fetching ${a.request.url} resulted in offline`,e),s.match(this.OFFLINE_PAGE)))}))})}}const pwa=new Pwa(self);pwa.register();
\ No newline at end of file diff --git a/static/tinysearch_engine_bg.wasm b/static/tinysearch_engine_bg.wasm Binary files differdeleted file mode 100644 index c3559af..0000000 --- a/static/tinysearch_engine_bg.wasm +++ /dev/null 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> @@ -2,7 +2,7 @@ name = "abridge" description = "A fast and lightweight Zola theme using semantic html, a class-light abridge.css, and No mandatory JS." license = "MIT" homepage = "https://github.com/jieiku/abridge" -min_version = "0.17.3" +min_version = "0.17.2" demo = "https://abridge.netlify.app/" [extra] |
