From c00dc361b7d3924df8abca4a32427d0a1232dc0b Mon Sep 17 00:00:00 2001 From: tdro Date: Wed, 26 Oct 2022 21:53:13 -0400 Subject: config: Overwrite and build expired Remove xkcd from content security policy, no longer needed. --- config.json | 2 +- config.toml | 3 ++- config.yaml | 3 ++- content/canory/messages/selfdestructed.md | 10 ++++++++++ content/canory/messages/unlisted.md | 4 ++-- themes/default/layouts/_default/index.json | 2 +- themes/default/layouts/_default/rss.xml | 2 +- themes/default/layouts/_default/single.plain.txt | 2 +- themes/default/layouts/_default/summary.html | 6 ++++-- themes/default/layouts/partials/function-content.html | 13 ++++++++++--- themes/default/layouts/partials/function-strings.html | 6 ------ themes/default/layouts/partials/meta-expiry-date.html | 8 +++++++- themes/default/layouts/shortcodes/version.html | 2 +- 13 files changed, 42 insertions(+), 21 deletions(-) create mode 100644 content/canory/messages/selfdestructed.md delete mode 100644 themes/default/layouts/partials/function-strings.html diff --git a/config.json b/config.json index b2d2ae3..fc57fbe 100644 --- a/config.json +++ b/config.json @@ -6,6 +6,7 @@ "summaryLength": 1, "enableEmoji": true, "buildDrafts": true, + "buildExpired": true, "languageCode": "en-us", "enableRobotsTXT": true, "author": { @@ -139,7 +140,6 @@ "img-src": [ "'self'", "http://preview.test", - "imgs.xkcd.com", "www.gutenberg.org" ], "manifest-src": [ diff --git a/config.toml b/config.toml index 6da97ed..386076b 100644 --- a/config.toml +++ b/config.toml @@ -4,6 +4,7 @@ paginate = 10 summaryLength = 1 enableEmoji = true buildDrafts = true +buildExpired = true languageCode = "en-us" enableRobotsTXT = true @@ -108,7 +109,7 @@ enableRobotsTXT = true font-src = ["'self'"] form-action = ["'self'", "lite.duckduckgo.com"] frame-src = ["'self'", "imgur.com", "www.youtube-nocookie.com", "platform.twitter.com", "en.m.wikipedia.org", "odysee.com", "www.gutenberg.org"] - img-src = ["'self'", "http://preview.test", "imgs.xkcd.com", "www.gutenberg.org"] + img-src = ["'self'", "http://preview.test", "www.gutenberg.org"] manifest-src = ["'self'"] media-src = ["'self'", "raw.githubusercontent.com", "i.imgur.com"] object-src = ["'self'", "www.gutenberg.org"] diff --git a/config.yaml b/config.yaml index 96beeeb..bb55ea4 100644 --- a/config.yaml +++ b/config.yaml @@ -7,6 +7,7 @@ paginate: 10 summaryLength: 1 enableEmoji: true buildDrafts: true +buildExpired: true languageCode: en-us enableRobotsTXT: true @@ -97,7 +98,7 @@ params: form-action: ["'self'", lite.duckduckgo.com] frame-src: ["'self'", imgur.com, www.youtube-nocookie.com, platform.twitter.com, en.m.wikipedia.org, odysee.com, www.gutenberg.org] - img-src: ["'self'", http://preview.test, imgs.xkcd.com, www.gutenberg.org] + img-src: ["'self'", http://preview.test, www.gutenberg.org] manifest-src: ["'self'"] media-src: ["'self'", raw.githubusercontent.com, i.imgur.com] object-src: ["'self'", www.gutenberg.org] diff --git a/content/canory/messages/selfdestructed.md b/content/canory/messages/selfdestructed.md new file mode 100644 index 0000000..79d580a --- /dev/null +++ b/content/canory/messages/selfdestructed.md @@ -0,0 +1,10 @@ ++++ +date = "2022-03-08T02:18:49+00:00" +lastmod = "2022-03-08T02:18:49+00:00" +expirydate = "2022-03-08T02:19:51+00:00" +tags = [ "docs", "selfdestructed" ] +author = "canory" +slug = "cf1a1feb2" ++++ + +This is a special message. diff --git a/content/canory/messages/unlisted.md b/content/canory/messages/unlisted.md index 53d9f2f..f746c77 100644 --- a/content/canory/messages/unlisted.md +++ b/content/canory/messages/unlisted.md @@ -1,6 +1,6 @@ +++ -date = "2022-03-08T02:20:51+00:00" -lastmod = "2022-03-08T02:20:51+00:00" +date = "2022-03-08T02:19:51+00:00" +lastmod = "2022-03-08T02:19:51+00:00" tags = [ "docs", "unlisted" ] unlisted = true author = "canory" diff --git a/themes/default/layouts/_default/index.json b/themes/default/layouts/_default/index.json index 1e672fd..86be455 100644 --- a/themes/default/layouts/_default/index.json +++ b/themes/default/layouts/_default/index.json @@ -32,7 +32,7 @@ {{- end -}} ], "content_text": {{ $data.Plain | jsonify }}, - "content_html": {{ partial "function-content.html" $data.Content | jsonify }} + "content_html": {{ partial "function-content.html" $data | jsonify }} } {{- end -}} {{ end }} diff --git a/themes/default/layouts/_default/rss.xml b/themes/default/layouts/_default/rss.xml index beda119..3eee035 100644 --- a/themes/default/layouts/_default/rss.xml +++ b/themes/default/layouts/_default/rss.xml @@ -75,7 +75,7 @@ {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} {{ .Permalink }} - {{- partial "function-content.html" .Content | html -}} + {{- partial "function-content.html" . | html -}} {{- print "
" | html -}} {{- partial "rss-tags.html" . | html -}}
diff --git a/themes/default/layouts/_default/single.plain.txt b/themes/default/layouts/_default/single.plain.txt index d110b5e..6b97968 100644 --- a/themes/default/layouts/_default/single.plain.txt +++ b/themes/default/layouts/_default/single.plain.txt @@ -1 +1 @@ -{{- .Content | plainify | htmlUnescape -}} +{{- partial "function-content.html" . | plainify | htmlUnescape -}} diff --git a/themes/default/layouts/_default/summary.html b/themes/default/layouts/_default/summary.html index e1e6f73..356d0d9 100644 --- a/themes/default/layouts/_default/summary.html +++ b/themes/default/layouts/_default/summary.html @@ -1,5 +1,7 @@ -{{- $limit := gt .WordCount 75 -}} -{{- $content := partial "function-content.html" .Content | safeHTML -}} +{{- $wordLimit := gt .WordCount 75 -}} +{{- $content := partial "function-content.html" . | safeHTML -}} +{{- $expired := and .ExpiryDate (ge now.Unix .ExpiryDate.Unix) -}} +{{- $limit := and $wordLimit (not $expired) -}} {{- if $limit -}} diff --git a/themes/default/layouts/partials/function-content.html b/themes/default/layouts/partials/function-content.html index be33ba0..de68946 100644 --- a/themes/default/layouts/partials/function-content.html +++ b/themes/default/layouts/partials/function-content.html @@ -1,4 +1,7 @@ -{{- $content := . -}} +{{- $context := . -}} +{{- $content := $context.Content -}} +{{- $expired := and .ExpiryDate (ge now.Unix .ExpiryDate.Unix) -}} +{{- $empty := eq (len $content) 0 -}} {{- $content = $content | @@ -7,8 +10,12 @@ replaceRE "

" "" | -}} -{{- if eq (len $content) 0 -}} - {{- $content = partial "function-strings.html" "messageNoContent" -}} +{{- if $empty -}} + {{- $content = "This message contains no content." -}} +{{- end -}} + +{{- if $expired -}} + {{- $content = "This message has expired." -}} {{- end -}} {{- return $content -}} diff --git a/themes/default/layouts/partials/function-strings.html b/themes/default/layouts/partials/function-strings.html deleted file mode 100644 index 37de01a..0000000 --- a/themes/default/layouts/partials/function-strings.html +++ /dev/null @@ -1,6 +0,0 @@ -{{- $string := . -}} - -{{- if eq $string "messageExpired" -}} {{- $string = "This message has expired." -}} {{- end -}} -{{- if eq $string "messageNoContent" -}} {{- $string = "This message contains no content." -}} {{- end -}} - -{{- return $string -}} diff --git a/themes/default/layouts/partials/meta-expiry-date.html b/themes/default/layouts/partials/meta-expiry-date.html index e2c4838..62f01da 100644 --- a/themes/default/layouts/partials/meta-expiry-date.html +++ b/themes/default/layouts/partials/meta-expiry-date.html @@ -1,9 +1,15 @@ {{- if .ExpiryDate -}} + {{- $expired := and .ExpiryDate (ge now.Unix .ExpiryDate.Unix) -}} {{- $diff := now.Sub .ExpiryDate -}} {{- $duration := lang.FormatNumberCustom 0 (math.Round (mul (div $diff.Hours 24) -1)) -}} + {{- $date := .ExpiryDate | time.Format "Monday, January 2 2006 at 15:04:05 MST" -}} + {{- $title := print "Self destructs within" " " $duration " " "days" " " "(" $date ")" -}} + {{- if $expired -}} + {{- $title = print "Self destructed" " " $date -}} + {{- end -}} + title="{{ $title }}"> {{- safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/trash-2.svg")) -}}