From dc36597427bbf33534191f900a7c1a40e31f4a17 Mon Sep 17 00:00:00 2001 From: Served Smart <195884188+servedsmart@users.noreply.github.com> Date: Mon, 2 Jun 2025 12:40:58 +0200 Subject: [PATCH] :lock: Add config parameter fingerprintAlgorithm This parameter allows users to choose their algorithm for html integrity checks. This mainly affects Hugo's fingerprint --- config/_default/params.toml | 2 ++ exampleSite/config/_default/params.toml | 2 ++ .../content/docs/configuration/index.it.md | 1 + .../content/docs/configuration/index.ja.md | 1 + .../content/docs/configuration/index.md | 1 + .../content/docs/configuration/index.zh-cn.md | 1 + exampleSite/layouts/partials/home/custom.html | 2 +- layouts/_default/list.html | 2 +- layouts/_default/single.html | 2 +- layouts/_default/term.html | 2 +- layouts/_default/terms.html | 2 +- layouts/partials/footer.html | 2 +- layouts/partials/head.html | 8 ++++---- layouts/partials/meta/zen-mode.html | 2 +- layouts/partials/vendor.html | 18 +++++++++--------- 15 files changed, 28 insertions(+), 20 deletions(-) diff --git a/config/_default/params.toml b/config/_default/params.toml index 4ade93d2..c1642cd1 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -29,6 +29,8 @@ disableTextInHeader = false # smartTOC = true # smartTOCHideUnfocusedChildren = true +fingerprintAlgorithm = "sha512" # Valid values are "sha512" (default), "sha384", "sha256" + giteaDefaultServer = "https://git.fsfe.org" forgejoDefaultServer = "https://v8.next.forgejo.org" diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index c6790ad5..5df906be 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -30,6 +30,8 @@ highlightCurrentMenuArea = true smartTOC = true smartTOCHideUnfocusedChildren = false +fingerprintAlgorithm = "sha512" # Valid values are "sha512" (default), "sha384", "sha256" + [header] layout = "fixed" # valid options: basic, fixed, fixed-fill, fixed-gradient, fixed-fill-blur diff --git a/exampleSite/content/docs/configuration/index.it.md b/exampleSite/content/docs/configuration/index.it.md index 907442ff..e6b36978 100644 --- a/exampleSite/content/docs/configuration/index.it.md +++ b/exampleSite/content/docs/configuration/index.it.md @@ -186,6 +186,7 @@ Many of the article defaults here can be overridden on a per article basis by sp | `highlightCurrentMenuArea` | _Not set_ | Marks menu entries in the main menu when selected | | `smartTOC` | _Not set_ | Activate smart Table of Contents, items in view will be highlighted. | | `smartTOCHideUnfocusedChildren` | _Not set_ | When smart Table of Contents is turned on, this will hide deeper levels of the table when they are not in focus. | +| `fingerprintAlgorithm` | `"sha512"` | This configures the fingerprint or resources.Fingerprint used in .Data.Integrity for files provided by the theme. Valid values are `sha512` (default), `sha384`, `sha256` | ### Header diff --git a/exampleSite/content/docs/configuration/index.ja.md b/exampleSite/content/docs/configuration/index.ja.md index 41699b8e..0ef0a3a4 100644 --- a/exampleSite/content/docs/configuration/index.ja.md +++ b/exampleSite/content/docs/configuration/index.ja.md @@ -186,6 +186,7 @@ Blowfish は、テーマの機能を制御する多数の設定パラメータ | `highlightCurrentMenuArea` | _未設定_ | メインメニューのメニュー項目が選択されているときにマークを付けます。 | | `smartTOC` | _未設定_ | スマート目次をアクティブにします。表示されている項目が強調表示されます。 | | `smartTOCHideUnfocusedChildren` | _未設定_ | スマート目次がオンになっている場合、フォーカスされていないときに、テーブルのより深いレベルが非表示になります。 | +| `fingerprintAlgorithm` | `"sha512"` | This configures the fingerprint or resources.Fingerprint used in .Data.Integrity for files provided by the theme. Valid values are `sha512` (default), `sha384`, `sha256` | ### ヘッダー(Header) diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index 2e7a5973..1399e639 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -192,6 +192,7 @@ Many of the article defaults here can be overridden on a per article basis by sp | `highlightCurrentMenuArea` | _Not set_ | Marks menu entries in the main menu when selected | | `smartTOC` | _Not set_ | Activate smart Table of Contents, items in view will be highlighted. | | `smartTOCHideUnfocusedChildren` | _Not set_ | When smart Table of Contents is turned on, this will hide deeper levels of the table when they are not in focus. | +| `fingerprintAlgorithm` | `"sha512"` | This configures the fingerprint or resources.Fingerprint used in .Data.Integrity for files provided by the theme. Valid values are `sha512` (default), `sha384`, `sha256` | ### Header diff --git a/exampleSite/content/docs/configuration/index.zh-cn.md b/exampleSite/content/docs/configuration/index.zh-cn.md index 3e4b99b5..69d15240 100644 --- a/exampleSite/content/docs/configuration/index.zh-cn.md +++ b/exampleSite/content/docs/configuration/index.zh-cn.md @@ -190,6 +190,7 @@ Blowfish 提供了大量控制主题功能的配置参数,下面的表格中 | `highlightCurrentMenuArea` | 无 | 当菜单被选择时,标记主菜单中的菜单项。 | | `smartTOC` | 无 | 开启智能目录,视图中的项目将会被高亮显示。 | | `smartTOCHideUnfocusedChildren` | 无 | 当开启智能目录,如果目录级别不再被聚焦时,将会隐藏更深层次的目录。 | +| `fingerprintAlgorithm` | `"sha512"` | This configures the fingerprint or resources.Fingerprint used in .Data.Integrity for files provided by the theme. Valid values are `sha512` (default), `sha384`, `sha256` | ### 页头 diff --git a/exampleSite/layouts/partials/home/custom.html b/exampleSite/layouts/partials/home/custom.html index e78774e7..f4cf9003 100644 --- a/exampleSite/layouts/partials/home/custom.html +++ b/exampleSite/layouts/partials/home/custom.html @@ -1,4 +1,4 @@ -{{ $jsHome := resources.Get "js/home.js" | resources.Minify | resources.Fingerprint "sha512" }} +{{ $jsHome := resources.Get "js/home.js" | resources.Minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }}
{{ partial "home/background.html" . }}
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 0b7d9098..d236e9b0 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -31,7 +31,7 @@ var oid_likes = "likes_{{ $path }}" {{ $jsPage := resources.Get "js/page.js" }} - {{ $jsPage = $jsPage | resources.Minify | resources.Fingerprint "sha512" }} + {{ $jsPage = $jsPage | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index c0a66f78..6c49cb42 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -145,7 +145,7 @@ var oid_likes = "likes_{{ $path }}" {{ $jsPage := resources.Get "js/page.js" }} - {{ $jsPage = $jsPage | resources.Minify | resources.Fingerprint "sha512" }} + {{ $jsPage = $jsPage | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ end }} diff --git a/layouts/_default/term.html b/layouts/_default/term.html index 74b9b646..e8448aa1 100644 --- a/layouts/_default/term.html +++ b/layouts/_default/term.html @@ -31,7 +31,7 @@ var oid_likes = "likes_term_{{ .Data.Term }}" {{ $jsPage := resources.Get "js/page.js" }} - {{ $jsPage = $jsPage | resources.Minify | resources.Fingerprint "sha512" }} + {{ $jsPage = $jsPage | resources.Minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ end }} diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html index 43a850dc..510f24ed 100644 --- a/layouts/_default/terms.html +++ b/layouts/_default/terms.html @@ -33,7 +33,7 @@ var oid_likes = "likes_taxonomy_{{ .Data.Plural }}" {{ $jsPage := resources.Get "js/page.js" }} - {{ $jsPage = $jsPage | resources.Minify | resources.Fingerprint "sha512" }} + {{ $jsPage = $jsPage | resources.Minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ end }} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index cce8ae9d..faf3cc9c 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -59,7 +59,7 @@ {{ end }} {{ $jsProcess := resources.Get "js/process.js" }} - {{ $jsProcess = $jsProcess | resources.Minify | resources.Fingerprint "sha512" }} + {{ $jsProcess = $jsProcess | resources.Minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{/* Extend footer - eg. for extra scripts, etc. */}} {{ if templates.Exists "partials/extend-footer.html" }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 6f9a5f21..574deae5 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -46,11 +46,11 @@ {{ $assets.Add "css" (slice $cssCustom) }} {{ end }} {{ $bundleCSS := $assets.Get "css" | resources.Concat "css/main.bundle.css" | resources.Minify | resources.Fingerprint - "sha512" }} + (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ $jsAppearance := resources.Get "js/appearance.js" }} - {{ $jsAppearance = $jsAppearance | resources.ExecuteAsTemplate "js/appearance.js" . | resources.Minify | resources.Fingerprint "sha512" }} + {{ $jsAppearance = $jsAppearance | resources.ExecuteAsTemplate "js/appearance.js" . | resources.Minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ if .Site.Params.enableSearch | default false }} @@ -70,13 +70,13 @@ {{ $assets.Add "js" (slice $jsMobileMenu) }} {{ if $assets.Get "js" }} {{ $bundleJS := $assets.Get "js" | resources.Concat "js/main.bundle.js" | resources.Minify | resources.Fingerprint - "sha512" }} + (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ end }} {{ if not .Site.Params.disableImageZoom | default true }} - {{ $zoomJS := resources.Get "lib/zoom/zoom.min.js" | resources.Fingerprint "sha512" }} + {{ $zoomJS := resources.Get "lib/zoom/zoom.min.js" | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ end }} {{/* Icons */}} diff --git a/layouts/partials/meta/zen-mode.html b/layouts/partials/meta/zen-mode.html index 6339e26b..94e0fdf3 100644 --- a/layouts/partials/meta/zen-mode.html +++ b/layouts/partials/meta/zen-mode.html @@ -1,5 +1,5 @@ {{ $jsZenMode := resources.Get "js/zen-mode.js" }} -{{ $jsZenMode = $jsZenMode | resources.Minify | resources.Fingerprint "sha512" }} +{{ $jsZenMode = $jsZenMode | resources.Minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} diff --git a/layouts/partials/vendor.html b/layouts/partials/vendor.html index b273cf34..f7209fcb 100644 --- a/layouts/partials/vendor.html +++ b/layouts/partials/vendor.html @@ -1,5 +1,5 @@ {{/* jQuery */}} -{{ $jqueryLib := resources.Get "lib/jquery/jquery.slim.min.js" | resources.Fingerprint "sha512" }} +{{ $jqueryLib := resources.Get "lib/jquery/jquery.slim.min.js" | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{/* Mermaid */}} @@ -7,7 +7,7 @@ {{ $mermaidLib := resources.Get "lib/mermaid/mermaid.min.js" }} {{ $mermaidConfig := resources.Get "js/mermaid.js" }} {{ $mermaidConfig := $mermaidConfig | resources.Minify }} - {{ $mermaidJS := slice $mermaidLib $mermaidConfig | resources.Concat "js/mermaid.bundle.js" | resources.Fingerprint "sha512" }} + {{ $mermaidJS := slice $mermaidLib $mermaidConfig | resources.Concat "js/mermaid.bundle.js" | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ end }} @@ -29,13 +29,13 @@ {{/* Katex */}} {{ if .Page.HasShortcode "katex" }} {{ $katexCSS := resources.Get "lib/katex/katex.min.css" }} -{{ $katexCSS := $katexCSS | resources.Fingerprint "sha512" }} +{{ $katexCSS := $katexCSS | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ $katexJS := resources.Get "lib/katex/katex.min.js" }} -{{ $katexJS := $katexJS | resources.Fingerprint "sha512" }} +{{ $katexJS := $katexJS | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ $katexRenderJS := resources.Get "lib/katex/auto-render.min.js" }} -{{ $katexRenderJS := $katexRenderJS | resources.Fingerprint "sha512" }} +{{ $katexRenderJS := $katexRenderJS | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ $katexFonts := resources.Match "lib/katex/fonts/*" }} @@ -46,7 +46,7 @@ {{/* TypeIt */}} {{ if .Page.HasShortcode "typeit" }} -{{ $typeitLib := resources.Get "lib/typeit/typeit.umd.js" | resources.Fingerprint "sha512" }} +{{ $typeitLib := resources.Get "lib/typeit/typeit.umd.js" | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ end }} @@ -56,7 +56,7 @@ {{ $jsShortcodeGallery := resources.Get "js/shortcodes/gallery.js" }} - {{ $jsShortcodeGallery = $jsShortcodeGallery | resources.Minify | resources.Fingerprint "sha512" }} + {{ $jsShortcodeGallery = $jsShortcodeGallery | resources.Minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ end }} @@ -68,7 +68,7 @@ {{/* youtubeLite */}} {{ if .Page.HasShortcode "youtubeLite" }} -{{ $youtubeLiteJS := resources.Get "lib/lite-youtube-embed/lite-yt-embed.js" | resources.Fingerprint "sha512" }} +{{ $youtubeLiteJS := resources.Get "lib/lite-youtube-embed/lite-yt-embed.js" | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} {{ $youtubeLiteCSS := resources.Get "lib/lite-youtube-embed/lite-yt-embed.css" }}