From a27fd0ea3fdd4da1b895d1243cd7c1599646095e Mon Sep 17 00:00:00 2001 From: stradichenko Date: Sun, 26 Apr 2026 15:04:29 +0200 Subject: [PATCH] =?UTF-8?q?Unit=2012:=20widget=20partials=20=E2=80=94=20ex?= =?UTF-8?q?tract=20inline=20JS,=20add=20SRI,=20i18n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For each of: zipfs-law, lda-analysis, knowledge-graph, filters, gallery-slider, contribution-calendar: - Move inline +{{ else }} + {{ errorf "Required file 'contribution-calendar.js' not found in assets/js/ directory" }} +{{ end }} diff --git a/layouts/partials/filters.html b/layouts/partials/filters.html index e965070..dd46b38 100644 --- a/layouts/partials/filters.html +++ b/layouts/partials/filters.html @@ -3,8 +3,8 @@
- +
-

Select a category or tag to view matching posts

+

{{ i18n "filters_initial_message" | default "Select a category or tag to view matching posts" }}

- +{{ with resources.Get "js/filters.js" }} + {{ $filtersJS := . | resources.Minify | fingerprint }} + +{{ else }} + {{ errorf "Required file 'filters.js' not found in assets/js/ directory" }} +{{ end }} diff --git a/layouts/partials/gallery-slider.html b/layouts/partials/gallery-slider.html index b9e5e58..909314e 100644 --- a/layouts/partials/gallery-slider.html +++ b/layouts/partials/gallery-slider.html @@ -10,12 +10,12 @@
-
- +
- +
- +
-
- - - + + +
- -
- +
- +
- +
-
- - - + + +
- - - +
@@ -182,7 +182,7 @@ -{{ $graphScript := resources.Get "js/knowledge-graph.js" }} -{{ if $graphScript }} - {{ $graphScript = $graphScript | resources.ExecuteAsTemplate "js/knowledge-graph.js" . | resources.Minify | fingerprint }} - - +{{/* D3 with SRI: prefer build-time fetch via resources.GetRemote so we get a verified hash. */}} +{{ $d3URL := "https://cdn.jsdelivr.net/npm/d3@7.9.0/dist/d3.min.js" }} +{{ $d3Integrity := "" }} +{{ $d3Resource := resources.GetRemote $d3URL }} +{{ if $d3Resource }} + {{ if $d3Resource.Err }} + {{ warnf "knowledge-graph: failed to fetch D3 for SRI: %s" $d3Resource.Err }} + {{ else }} + {{ $d3Integrity = $d3Resource.Data.Integrity }} + {{ end }} +{{ end }} + +{{ with resources.Get "js/knowledge-graph.js" }} + {{ $graphScript := . | resources.ExecuteAsTemplate "js/knowledge-graph.js" $ | resources.Minify | fingerprint }} + {{ if $d3Integrity }} + + {{ else }} + + {{ end }} + {{ else }} {{ errorf "Required file 'knowledge-graph.js' not found in assets/js/ directory" }} {{ end }} diff --git a/layouts/partials/lda-analysis.html b/layouts/partials/lda-analysis.html index c934b92..571e039 100644 --- a/layouts/partials/lda-analysis.html +++ b/layouts/partials/lda-analysis.html @@ -1,11 +1,11 @@
-

Topic Analysis (LDA)

- +

{{ i18n "lda_title" | default "Topic Analysis (LDA)" }}

+
-

Topic Distribution

+

{{ i18n "lda_topic_distribution" | default "Topic Distribution" }}

@@ -14,13 +14,13 @@

Topic Distribution

- +
-

Topic Details

+

{{ i18n "lda_topic_details" | default "Topic Details" }}

-

Analyzing content using GPU-accelerated LDA...

+

{{ i18n "lda_loading" | default "Analyzing content using GPU-accelerated LDA..." }}

@@ -40,8 +40,10 @@

-
@@ -54,20 +56,18 @@

@@ -76,114 +76,26 @@

{{ end }} - - +{{/* TensorFlow.js with SRI via resources.GetRemote */}} +{{ $tfURL := "https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@4.22.0/dist/tf.min.js" }} +{{ $tfIntegrity := "" }} +{{ $tfResource := resources.GetRemote $tfURL }} +{{ if $tfResource }} + {{ if $tfResource.Err }} + {{ warnf "lda-analysis: failed to fetch tfjs for SRI: %s" $tfResource.Err }} + {{ else }} + {{ $tfIntegrity = $tfResource.Data.Integrity }} + {{ end }} +{{ end }} +{{ if $tfIntegrity }} + +{{ else }} + +{{ end }} - - {{ with resources.Get "js/lda-analysis.js" }} - {{ $ldaJS := . | js.Build | minify | fingerprint }} - + {{ $ldaJS := . | js.Build (dict "minify" true) | fingerprint }} + +{{ else }} + {{ errorf "Required file 'lda-analysis.js' not found in assets/js/ directory" }} {{ end }} diff --git a/layouts/partials/zipfs-law.html b/layouts/partials/zipfs-law.html index 5858934..075117b 100644 --- a/layouts/partials/zipfs-law.html +++ b/layouts/partials/zipfs-law.html @@ -1,10 +1,10 @@
-

Content Analysis (Zipf's Law)

- +

{{ i18n "zipf_title" | default "Content Analysis (Zipf's Law)" }}

+
-

Word Frequency Distribution

+

{{ i18n "zipf_word_freq_distribution" | default "Word Frequency Distribution" }}

@@ -29,9 +29,9 @@

Word Frequency Distribution

- - - + + +
@@ -77,16 +77,16 @@

About the Cleaned Corpus

-

Word Frequency Analysis

+

{{ i18n "zipf_word_freq_analysis" | default "Word Frequency Analysis" }}

- - - - - + + + + + @@ -119,9 +119,9 @@

Word Frequency Analysis

- - - + + +
@@ -136,43 +136,28 @@

Word Frequency Analysis

- -{{ $zipfJS := resources.Get "js/zipfs-law.js" }} - + +{{- $mainSections := site.Params.taxonomies.mainSections | default site.Params.mainSections | default (slice "posts" "docs" "blog") -}} +{{- $words := slice -}} +{{- range where site.RegularPages "Type" "in" $mainSections -}} + {{- with .Title -}} + {{- $words = $words | append (split (lower .) " ") -}} + {{- end -}} + {{- with .Description -}} + {{- $words = $words | append (split (lower .) " ") -}} + {{- end -}} + {{- range .Params.tags -}} + {{- $words = $words | append (lower .) -}} + {{- end -}} + {{- range .Params.categories -}} + {{- $words = $words | append (lower .) -}} + {{- end -}} +{{- end }} + - +{{ with resources.Get "js/zipfs-law.js" }} + {{ $zipfJS := . | resources.Minify | fingerprint }} + +{{ else }} + {{ errorf "Required file 'zipfs-law.js' not found in assets/js/ directory" }} +{{ end }}
RankWordFreq (n/total)Pr(%)Ideal{{ i18n "zipf_rank" | default "Rank" }}{{ i18n "zipf_word" | default "Word" }}{{ i18n "zipf_freq" | default "Freq (n/total)" }}{{ i18n "zipf_pr" | default "Pr(%)" }}{{ i18n "zipf_ideal" | default "Ideal" }}