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

Automatically pull webring links during build

This commit is contained in:
Rohan Kumar 2022-06-07 09:39:32 -07:00
parent c87a67c5de
commit c9291830d0
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
6 changed files with 91 additions and 2 deletions

View file

@ -4,6 +4,7 @@
# hugo, brotli, ect (like gzip/zopfli), sd, and xmlfmt.
image: alpine/edge
packages:
- curl # for webring update script
- rsync
- git # for Hugo's gitInfo
- bmake

1
.gitignore vendored
View file

@ -10,3 +10,4 @@ old/
public/
public_*/
.hugo_build.lock
csv/webrings.csv

View file

@ -19,8 +19,11 @@ ECT_LEVEL=9
VNU ?= vnu
csv/webrings.csv:
sh scripts/populate-webrings.sh
.PHONY: hugo
hugo: $(SRCFILES)
hugo: csv/webrings.csv $(SRCFILES)
hugo -b $(HUGO_BASEURL) $(HUGO_FLAGS) -d $(OUTPUT_DIR)
# .hintrc-local for linting local files

View file

@ -6,7 +6,6 @@ no js webring,https://nojs.sugarfi.dev/prev.php?url=https://seirdy.one,https://n
Fediring,https://fediring.net/previous?host=seirdy.one,https://fediring.net/,https://fediring.net/next?host=seirdy.one
Loop (JS),https://graycot.com/webring/loop-redirect.html?action=prev,https://graycot.com/webring/,https://graycot.com/webring/loop-redirect.html?action=next
YesterWeb,https://webring.yesterweb.org/noJS/index.php?d=prev&url=https://seirdy.one/,https://yesterweb.org/webring/,https://webring.yesterweb.org/noJS/index.php?d=next&url=https://seirdy.one/
GEORGE,https://aroace.space,https://george.gh0.pw,http://truttle1.xyz/truttlecities/~Itzzy/MainStreet/index.html
Retronaut,https://webring.dinhe.net/prev/https://seirdy.one,https://webring.dinhe.net/,https://webring.dinhe.net/next/https://seirdy.one
Hotline,https://hotlinewebring.club/seirdy/previous,https://hotlinewebring.club,https://hotlinewebring.club/seirdy/next
Bucket (JS),https://webring.bucketfish.me/redirect.html?to=prev&name=seirdy,https://webring.bucketfish.me/,https://webring.bucketfish.me/redirect.html?to=next&name=seirdy
1 name prev home next
6 Fediring https://fediring.net/previous?host=seirdy.one https://fediring.net/ https://fediring.net/next?host=seirdy.one
7 Loop (JS) https://graycot.com/webring/loop-redirect.html?action=prev https://graycot.com/webring/ https://graycot.com/webring/loop-redirect.html?action=next
8 YesterWeb https://webring.yesterweb.org/noJS/index.php?d=prev&url=https://seirdy.one/ https://yesterweb.org/webring/ https://webring.yesterweb.org/noJS/index.php?d=next&url=https://seirdy.one/
GEORGE https://aroace.space https://george.gh0.pw http://truttle1.xyz/truttlecities/~Itzzy/MainStreet/index.html
9 Retronaut https://webring.dinhe.net/prev/https://seirdy.one https://webring.dinhe.net/ https://webring.dinhe.net/next/https://seirdy.one
10 Hotline https://hotlinewebring.club/seirdy/previous https://hotlinewebring.club https://hotlinewebring.club/seirdy/next
11 Bucket (JS) https://webring.bucketfish.me/redirect.html?to=prev&name=seirdy https://webring.bucketfish.me/ https://webring.bucketfish.me/redirect.html?to=next&name=seirdy

84
scripts/populate-webrings.sh Executable file
View file

@ -0,0 +1,84 @@
#!/bin/sh
# Get webring links to append to the CSV before building
# Some webrings require an iframe or scripts, but I want a plain static
# first-party HTML+CSS page. This script fetches webring links by
# parsing the iframes and appends appropriate values to my webrings.csv file.
set -e -u
# the name of this program
progname="$(basename "$0")"
dirname="$(dirname "$0")"
webrings_src="$dirname/../csv/webrings.base.csv"
webrings_dest="$dirname/../csv/webrings.csv"
help_text="Usage: $progname [OPTION...]
Update webrings.csv with new prev/next links, to avoid iframes/scripts
Options:
-h Print this help and exit
-d Dry run; just print results, don't update webrings.csv
"
usage() {
printf '%s' "$help_text"
}
# when the user passess bad args, send a msg to stderr and exit
# usage: bad_option <option> <reason>
bad_option() {
echo "$progname: option $1: $2" >&2
usage >&2
exit 1
}
dry_run='0'
while getopts "hd" flags; do
case $flags in
h)
usage
exit 0
;;
d)
dry_run='1'
shift
;;
*)
bad_option "$flags" 'invalid option'
exit 1
;;
esac
done
# values for the GEORGE webring
george() {
echo GEORGE
curl -s 'https://george.gh0.pw/embed.cgi?seirdy' | htmlq -a href 'main p a'
}
values_to_csv() {
tr '\n' ',' && echo
}
print_csv_values() {
printf %s "$(george)" | values_to_csv
}
if [ -f "$webrings_dest" ]; then
echo "webrings file already generated"
exit 0
fi
if [ "$dry_run" = '1' ]; then
print_csv_values
else
print_csv_values | cat "$webrings_src" - >"$webrings_dest"
fi
# vi:ft=sh

View file

@ -29,6 +29,7 @@ sed 7d "$html_file" | xmllint --format --encode UTF-8 --noent - | sd '^\t' '' >"
{
head -n7 "$tmp_file"
cat tmp.css
# shellcheck disable=SC2016 # these are regex statements, not shell expressions
tail -n +8 "$tmp_file" \
| sd '<pre(?: tabindex="0")?>\n\t*<code ' '<pre tabindex="0"><code ' \
| sd '(?:\n)?</code>\n(?:[\t\s]*)?</pre>' '</code></pre>' \