From 8113e9c39376d1e9fb1c239a678a7502272e8fda Mon Sep 17 00:00:00 2001 From: tdro Date: Mon, 21 Nov 2022 11:23:56 -0500 Subject: themes/default/layouts: Use hashing algorithm consistently Avoid using shuffle in short codes by appending .Ordinal value --- themes/default/layouts/shortcodes/abbr.html | 6 +++--- themes/default/layouts/shortcodes/spoiler.html | 8 ++++++-- themes/default/layouts/shortcodes/spoiler.rss.xml | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'themes/default/layouts/shortcodes') diff --git a/themes/default/layouts/shortcodes/abbr.html b/themes/default/layouts/shortcodes/abbr.html index 52e3ff9..bad8895 100644 --- a/themes/default/layouts/shortcodes/abbr.html +++ b/themes/default/layouts/shortcodes/abbr.html @@ -1,8 +1,8 @@ {{- $abbr := default "TL;DR:" (.Get "abbr" | default (.Get 0)) -}} {{- $title := default "Too long, didn't read" (.Get "title" | default (.Get 1)) -}} +{{- $hash := print (truncate 8 "" (sha256 $abbr)) .Ordinal -}} -{{- $id := delimit (shuffle (seq 0 20)) "" -}} - + {{- /* This comment removes trailing newlines and white spaces. */ -}} - + {{- /* This comment removes trailing newlines and white spaces. */ -}} diff --git a/themes/default/layouts/shortcodes/spoiler.html b/themes/default/layouts/shortcodes/spoiler.html index fd3c9d3..ebc3643 100644 --- a/themes/default/layouts/shortcodes/spoiler.html +++ b/themes/default/layouts/shortcodes/spoiler.html @@ -1,9 +1,13 @@ {{- $text := default "This is a spoiler." (.Get "text" | default (.Get 0)) -}} {{- $title := default "Click to show/hide text." (.Get "title" | default (.Get 1)) -}} +{{- $hash := print (truncate 8 "" (sha256 $text)) .Ordinal -}} {{- if gt (len .Inner) 1 -}} {{- $text = .Inner -}} {{- end -}} - - + + + + + diff --git a/themes/default/layouts/shortcodes/spoiler.rss.xml b/themes/default/layouts/shortcodes/spoiler.rss.xml index 73dde8a..adbce7b 100644 --- a/themes/default/layouts/shortcodes/spoiler.rss.xml +++ b/themes/default/layouts/shortcodes/spoiler.rss.xml @@ -5,4 +5,6 @@ {{ $text = .Inner }} {{ end }} - + + + -- cgit v1.2.3