1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
#!/bin/sh
# wr - Minimal webring utility
# Licensed under the MIT License.
# This script should not be sourced, make sure to change the string 'wr'
# in the following line to match this file's name
[ 'wr' = "$( basename ${0} )" ] || return 1
# Edit DOMAIN and AUTHOR for your instance
# Make sure that DOMAIN is ONLY the domain of your instance, and without trailing slash
DOMAIN="webring.gumx.cc"
AUTHOR="Ahmed (~gumxcc)"
# Script metadata
SCRIPT=$( basename "$0" )
VMAJOR=0
VMINOR=1
VPATCH=0
HOMEPAGE="https://webring.gumx.cc/"
print_help () {
cat << HELP_TEXT
${SCRIPT} v${VMAJOR}.${VMINOR}.${VPATCH}
Minimal webring utility
Usage:
${SCRIPT} add SITE_URL SITE_TITLE [AUTHOR_NAME]
Add a new entry to the webring
${SCRIPT} [build]
Build the webring
${SCRIPT} -h | --help | help
Display this help message and exit
${SCRIPT} -v | --version | version
Display the script version and exit
Project homepage: <${HOMEPAGE}>
HELP_TEXT
}
print_version () {
VERSION="${VMAJOR}.${VMINOR}.${VPATCH}"
printf '%s Version %s\n' "${SCRIPT}" "${VERSION}"
}
print_error () {
ERROR_MSG=${1:-Unknown error}
printf '%s: %s\n' "${SCRIPT}" "${ERROR_MSG}" >&2
}
build_webring() {
mkdir -p public
printf '' > public/index.html
cat << INDEX_PAGE_TOP > public/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<meta content="width=device-width,initial-scale=1" name="viewport">
<title>webring</title>
<meta content="webring" name="title">
<meta content="${AUTHOR}" name="author">
<meta content="Minimal webring" name="description">
<meta content="website" property="og:type">
<meta content="${DOMAIN}" property="og:url">
<meta content="webring" property="og:site_name">
<meta content="webring" property="og:title">
<meta content="Minimal webring" property="og:description">
<meta content="summary" property="twitter:card">
<meta content="${DOMAIN}" property="twitter:url">
<meta content="webring" property="twitter:title">
<meta content="Minimal webring" property="twitter:description">
<link href="${DOMAIN}" rel="canonical">
<link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAACYktHRAAAqo0jMgAAAAd0SU1FB+YMGRUdK60VU+wAAAEzSURBVEjH7ZO9SgNBFIU/fyImEkgExRQquEiaQCwsDT6AnYWdnWCRx0jlA1ha+Q4WCvYWFimTgKzBRgUTRDSB6Fh4dzI7mJm1sNvT3DOHe787w7KQKtW/qIFCoTg3skPJbpIA7qT5yMhWJVMEvvGybt38FVu3B6atc01qj04sjy6/6wOUpbatPDpv+QCBBxAwlwzQtfKu7i+5AWtS+8AeISEhJ0BPdyzHB2YtwILUAVBgHYAVYKg7cu4bZKR+AVnxWeBz0kobMDCG8uLzsb3vbkD01hywZLx6DHhxA0Kpi4y/yAZQFK+4dwOaUivMsCO+QJWK+JZ+5AQd6H+hpZ3igTdxp3g0z5MxqLiMnRTbPgDsM9Ltz5S4Nsa9+39U44I+r1xRBYqc8cgHtxwzlQyQ6o/6BrGHacYUEyMVAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIyLTEyLTI1VDIxOjI5OjQzKzAwOjAwsFlEUAAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMi0xMi0yNVQyMToyOTo0MyswMDowMMEE/OwAAAAodEVYdGRhdGU6dGltZXN0YW1wADIwMjItMTItMjVUMjE6Mjk6NDMrMDA6MDCWEd0zAAAACHRFWHRsYWJlbADPieuXgVsAAAAASUVORK5CYII=" rel="icon">
<script type="application/ld+json">
{
"description":"Minimal webring",
"url":"${DOMAIN}",
"@type":"WebSite",
"headline":"webring",
"name":"webring",
"author":{
"@type":"Person",
"name":"${AUTHOR}"
},
"@context":"https://schema.org"
}
</script>
<style>
html { height:100%; background:white; }
body { background:white; color:black; font-family:monospace; font-size:16px; line-height:1.4; margin:0; padding:4rem 0; min-height:100%; overflow-wrap:break-word; }
main { max-width:640px; margin:0 auto; padding:0 2rem; }
h1 { text-align:center }
ul { display: flow-root; }
li, nav a { width: 40%; float: left; margin: 0 5%; }
nav a { text-decoration: none; display: block; text-align: center; }
body[theme="dark"] { filter:invert(1); }
@media (prefers-color-scheme: dark) { body[theme="auto"] { filter:invert(1); } }
@media (max-width:640px) { li { width: 90%; } }
</style>
</head>
<body theme="auto">
<main>
<h1>ω webring</h1>
<hr />
<ul>
INDEX_PAGE_TOP
#TODO: refactor this
count=0
for entry in $( find ./entries -type f ); do
count=$(( count + 1 ))
. ${entry}
entry_name="$( basename ${entry} )"
[ ${count} -eq 1 ] && first_entry="${entry_name}" && prev_entry="${entry_name}"
mkdir -p "public/${entry_name}" \
"public/${entry_name}/next" \
"public/${entry_name}/previous"
printf "<html><meta http-equiv=\"Refresh\" content=\"0; url='%s'\" /></html>\n" "${url}" \
> "public/${entry_name}/index.html"
cp "public/${entry_name}/index.html" "public/${prev_entry}/next/index.html"
cp "public/${prev_entry}/index.html" "public/${entry_name}/previous/index.html"
prev_entry="${entry_name}"
[ -n "${author}" ] \
&& printf ' <li><a href="%s">%s</a> by %s</li>\n' \
"${url}" "${title}" "${author}" >> public/index.html \
|| printf ' <li><a href="%s">%s</a></li>\n' \
"${url}" "${title}" >> public/index.html
unset url title author
done
cp "public/${first_entry}/index.html" "public/${entry_name}/next/index.html"
cp "public/${entry_name}/index.html" "public/${first_entry}/previous/index.html"
cat << INDEX_PAGE_BOTTOM >> public/index.html
</ul>
<hr />
<p>This is an attempt to replicate <a href="https://wiki.xxiivv.com/site/devine_lu_linvega.html">Devine Lu Linvega</a>'s <a href="https://webring.xxiivv.com/">webring</a> in a very minimal way, and with a lower technical bar.</p>
<p>To add your site to the webring, follow the instructions <a href="https://git.sr.ht/~gumxcc/webring.gumx.cc#host-your-own">here</a>. For issues, source code, documentation, visit the <a href="https://sr.ht/~a2/webring/">project page on sourcehut</a></p>
<p>This project is licensed under <a href="https://git.sr.ht/~gumxcc/webring.gumx.cc/tree/main/item/LICENSE">MIT license</a></p>
<hr />
<nav>
<a href="/${DOMAIN}/previous">≺ previous</a>
<a href="/${DOMAIN}/next">next ≻</a>
</nav>
</main>
</body>
</html>
INDEX_PAGE_BOTTOM
}
add_entry() {
entry="$( basename ${1} )"
entry_file="entries/${entry}"
mkdir -p $( dirname ${entry_file} )
printf 'url="%s"\ntitle="%s"' "${1}" "${2}" > "${entry_file}"
[ -n "${3}" ] && printf '\nauthor="%s"' "${3}" >> "${entry_file}"
cat << ENTRY_LINKS
Add the following links in your website, preferrably in the footer:
<p>
<a href="https://${DOMAIN}/${entry}/previous">← previous</a>
 
<a href="https://${DOMAIN}/">webring index</a>
 
<a href="https://${DOMAIN}/${entry}/next">next →</a>
</p>
You can style them as you please of course
ENTRY_LINKS
}
if [ -z "${1}" ] || [ "${1}" = "build" ]; then
printf 'Building the webring..'
build_webring
printf ' done\n'
exit 0
fi
ENTRY_URL=''
ENTRY_TITLE=''
ENTRY_AUTHOR=''
case "${1}" in
-h|--help|help)
print_help
exit 0
;;
-v|--version|version)
print_version
exit 0
;;
add)
shift
add_entry "${1}" "${2}" "${3}"
exit 0
;;
*)
print_error "${1}: Invalid argument"
print_help >&2
exit 22
;;
esac
trap "print_error 'Interrupt signal detected, output may be incomplete'" INT
|