1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-10 00:12:09 +00:00

Compare commits

...

4 commits

Author SHA1 Message Date
Rohan Kumar
7de728fdfe
Avoid data races with codeIndex on feeds 2023-11-29 00:38:15 -08:00
Rohan Kumar
a097b46950
Use local buku to get bookmarks if possible 2023-11-29 00:33:06 -08:00
Rohan Kumar
4581c83561
Make rsync output less noisy
Don't show .gz files: that's almost everything thanks to ect's
non-deterministic output
2023-11-28 19:46:15 -08:00
Rohan Kumar
41106cc9fd
Add comment-count to atom feed, better varnames 2023-11-28 19:45:12 -08:00
7 changed files with 70 additions and 12 deletions

View file

@ -22,8 +22,11 @@ ECT_LEVEL=6
csv/webrings.csv: csv/webrings.csv:
sh scripts/populate-webrings.sh sh scripts/populate-webrings.sh
data/bookmarks.json:
sh scripts/get-bookmarks.sh
.PHONY: hugo .PHONY: hugo
hugo: csv/webrings.csv $(SRCFILES) hugo: csv/webrings.csv data/bookmarks.json $(SRCFILES)
sh scripts/get-webmentions.sh sh scripts/get-webmentions.sh
hugo -b $(HUGO_BASEURL) $(HUGO_FLAGS) -d $(OUTPUT_DIR) hugo -b $(HUGO_BASEURL) $(HUGO_FLAGS) -d $(OUTPUT_DIR)
mv $(OUTPUT_DIR)/about/_index.gmi $(OUTPUT_DIR)/about/index.gmi mv $(OUTPUT_DIR)/about/_index.gmi $(OUTPUT_DIR)/about/index.gmi
@ -38,7 +41,7 @@ hugo: csv/webrings.csv $(SRCFILES)
.PHONY: clean .PHONY: clean
clean: clean:
rm -rf $(OUTPUT_DIR) .lighthouseci lighthouse-reports rm -rf $(OUTPUT_DIR) .lighthouseci lighthouse-reports data/webmentions.json csv/webrings.csv data/bookmarks.json
.PHONY: lint-css .PHONY: lint-css
lint-css: $(CSS_DIR)/*.css lint-css: $(CSS_DIR)/*.css
@ -123,16 +126,16 @@ compress: gzip brotli
.PHONY: gzip brotli compress .PHONY: gzip brotli compress
.PHONY: xhtmlize .PHONY: xhtmlize
xhtmlize: xhtmlize: hugo
sh scripts/xhtmlize.sh $(OUTPUT_DIR) sh scripts/xhtmlize.sh $(OUTPUT_DIR)
.PHONY: copy-to-xhtml .PHONY: copy-to-xhtml
copy-to-xhtml: copy-to-xhtml: xhtmlize
find $(OUTPUT_DIR) -type f -name "*.html" | grep -v 'resume/index.html' | xargs -n1 sh scripts/copy-file-to-xhtml.sh find $(OUTPUT_DIR) -type f -name "*.html" | grep -v 'resume/index.html' | xargs -n1 sh scripts/copy-file-to-xhtml.sh
.PHONY: deploy-html .PHONY: deploy-html
deploy-html: deploy-html:
rsync $(RSYNCFLAGS) $(RSYNCFLAGS_EXTRA) --exclude 'gemini' --exclude '*.gmi' --exclude-from .rsyncignore $(OUTPUT_DIR)/ $(WWW_RSYNC_DEST) --delete rsync $(RSYNCFLAGS) $(RSYNCFLAGS_EXTRA) --exclude 'gemini' --exclude '*.gmi' --exclude-from .rsyncignore $(OUTPUT_DIR)/ $(WWW_RSYNC_DEST) --delete | grep -v 'l\.gz$$'
.PHONY: deploy-gemini .PHONY: deploy-gemini
deploy-gemini: deploy-gemini:

View file

@ -9,9 +9,9 @@
{{- if eq .Section "notes" -}} {{- if eq .Section "notes" -}}
{{- $period = "hourly" -}} {{- $period = "hourly" -}}
{{- end -}} {{- end -}}
{{- $icon := resources.Get "/favicon.svg" | resources.Fingerprint "md5" -}} {{- $faviconSvg := resources.Get "/favicon.svg" | resources.Fingerprint "md5" -}}
{{- $image := resources.Get "/favicon192.png" | resources.Fingerprint "md5" -}} {{- $image := resources.Get "/favicon192.png" | resources.Fingerprint "md5" -}}
{{- $logo := resources.Get "/atom.svg" | resources.Fingerprint "md5" -}} {{- $atomLogo := resources.Get "/atom.svg" | resources.Fingerprint "md5" -}}
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed <feed
xmlns="http://www.w3.org/2005/Atom" xmlns="http://www.w3.org/2005/Atom"
@ -22,6 +22,7 @@
xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0"
xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:poco="http://portablecontacts.net/spec/1.0"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:thr="http://purl.org/syndication/thread/1.0"
xmlns:webfeeds="http://webfeeds.org/rss/1.0"> xmlns:webfeeds="http://webfeeds.org/rss/1.0">
@ -34,10 +35,10 @@
{{- end -}} {{- end -}}
</subtitle> </subtitle>
<link rel="self" type="application/atom+xml" href="{{ .Permalink }}atom.xml" /> <link rel="self" type="application/atom+xml" href="{{ .Permalink }}atom.xml" />
<icon>{{ $icon.Permalink }}</icon> <icon>{{ $faviconSvg.Permalink }}</icon>
<webfeeds:icon>{{ $icon.Permalink }}</webfeeds:icon> <webfeeds:icon>{{ $image.Permalink }}</webfeeds:icon>
<webfeeds:cover>{{ $logo.Permalink }}</webfeeds:cover> <webfeeds:cover>{{ $atomLogo.Permalink }}</webfeeds:cover>
<logo>{{ $logo.Permalink }}</logo> <logo>{{ $atomLogo.Permalink }}</logo>
<webfeeds:accentColor>191919</webfeeds:accentColor> <webfeeds:accentColor>191919</webfeeds:accentColor>
<sy:updatePeriod>{{ $period }}</sy:updatePeriod> <sy:updatePeriod>{{ $period }}</sy:updatePeriod>
<sy:updateFrequency>2</sy:updateFrequency> <sy:updateFrequency>2</sy:updateFrequency>
@ -57,7 +58,6 @@
{{ range $pages -}} {{ range $pages -}}
{{- if not .Params.Private -}} {{- if not .Params.Private -}}
<entry> <entry>
{{- .Page.Scratch.Set "codeIndex" 1 -}}
<title>{{ .Title }}</title> <title>{{ .Title }}</title>
<link rel="alternate" type="text/html" href="{{ .Permalink }}" /> <link rel="alternate" type="text/html" href="{{ .Permalink }}" />
<id>{{ .Permalink }}</id> <id>{{ .Permalink }}</id>
@ -90,6 +90,7 @@
{{ partial "processed-content.html" . | replaceRE `(?: )?(?:item(type|scope|prop|id|ref)="[^"]*"|class="language-figure")` "" | replaceRE `<meta content="true" ?/>` "" | safeHTML -}} {{ partial "processed-content.html" . | replaceRE `(?: )?(?:item(type|scope|prop|id|ref)="[^"]*"|class="language-figure")` "" | replaceRE `<meta content="true" ?/>` "" | safeHTML -}}
</div> </div>
</content> </content>
<slash:comments>{{ .Page.Scratch.Get "webmentionCount" }}</slash:comments>
</entry> </entry>
{{ end -}} {{ end -}}
{{- end }} {{- end }}

View file

@ -25,6 +25,7 @@
{{- end -}} {{- end -}}
{{- /* Render webmentions if they exist */ -}} {{- /* Render webmentions if they exist */ -}}
{{- $count := (len $webmentions) -}} {{- $count := (len $webmentions) -}}
{{- .Page.Scratch.Set "webmentionCount" $count -}}<!--For use in atom feed-->
{{- if gt $count 0 -}} {{- if gt $count 0 -}}
<details> <details>
<summary>Toggle {{ $count }} Webmentions</summary> <summary>Toggle {{ $count }} Webmentions</summary>

View file

@ -1,6 +1,8 @@
{{- define "main" -}} {{- define "main" -}}
{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }} {{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }}
{{- .Scratch.Set "codeIndex" 1 -}} {{- .Scratch.Set "codeIndex" 1 -}}
{{- .Scratch.Set "codeIndexAtom" 1 -}}
{{- .Scratch.Set "codeIndexRss" 1 -}}
<main <main
itemprop="mainEntity" itemscope="" itemtype="https://schema.org/BlogPosting{{ with .Params.articleType }} https://schema.org/{{ . }}{{ end }}" itemid="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}"> itemprop="mainEntity" itemscope="" itemtype="https://schema.org/BlogPosting{{ with .Params.articleType }} https://schema.org/{{ . }}{{ end }}" itemid="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}">
<link itemprop="isPartOf" href="{{ .Site.Params.CanonicalBaseURL }}/" /> <link itemprop="isPartOf" href="{{ .Site.Params.CanonicalBaseURL }}/" />

View file

@ -0,0 +1,17 @@
{{- $codeIndex := (.Page.Scratch.Get "codeIndexAtom") -}}
{{- $id := (printf `code-%d` $codeIndex) -}}
{{- with .Get "id" -}}
{{- $id = . -}}
{{- end -}}
{{ with .Parent }}
{{- with .Get "id" -}}
{{- $id = . -}}
{{- end -}}
{{- end -}}
<figcaption id="{{ $id }}-caption">
<span id="{{ $id }}" tabindex="-1">
<strong itemprop="name"> <span itemprop="codeSampleType">Code snippet</span> {{ $codeIndex }}</strong>{{with .Get "lang"}} (<span itemprop="programmingLanguage">{{ . }}</span>){{ end -}}
</span>:
{{ .Inner | .Page.RenderString | safeHTML }}
</figcaption>
{{- .Page.Scratch.Set "codeIndexAtom" (add 1 $codeIndex) -}}

View file

@ -0,0 +1,17 @@
{{- $codeIndex := (.Page.Scratch.Get "codeIndexRss") -}}
{{- $id := (printf `code-%d` $codeIndex) -}}
{{- with .Get "id" -}}
{{- $id = . -}}
{{- end -}}
{{ with .Parent }}
{{- with .Get "id" -}}
{{- $id = . -}}
{{- end -}}
{{- end -}}
<figcaption id="{{ $id }}-caption">
<span id="{{ $id }}" tabindex="-1">
<strong itemprop="name"> <span itemprop="codeSampleType">Code snippet</span> {{ $codeIndex }}</strong>{{with .Get "lang"}} (<span itemprop="programmingLanguage">{{ . }}</span>){{ end -}}
</span>:
{{ .Inner | .Page.RenderString | safeHTML }}
</figcaption>
{{- .Page.Scratch.Set "codeIndexRss" (add 1 $codeIndex) -}}

17
scripts/get-bookmarks.sh Normal file
View file

@ -0,0 +1,17 @@
#!/bin/sh
set -e -u
#shellcheck disable=SC3040 # This only sets pipefail if it's available and otherwise does nothing
set -o pipefail 2>/dev/null || true
dirname="$(dirname "$0")"
curl_wrapper="$dirname/curl-wrapper.sh"
bookmarks_file="$dirname/../data/bookmarks.json"
if command -v buku >/dev/null; then
buku -t public -j >"$bookmarks_file"
elif [ ! -f "$bookmarks_file" ]; then
"$curl_wrapper" 'https://seirdy.one/data/bookmarks.json' >"$bookmarks_file"
else
echo 'using cached bookmarks'
fi