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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
#!/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="https://${DOMAIN}" rel="canonical">
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<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>
@font-face { font-family: "Kawkab Mono"; src: url(/fonts/KawkabMono-Regular.woff2); font-weight: normal; }
@font-face { font-family: "Kawkab Mono"; src: url(/fonts/KawkabMono-Bold.woff2); font-weight: bold; }
* { unicode-bidi: plaintext; box-sizing: border-box; }
html { color: black; background-color: white; }
body { font-family: "Kawkab Mono", monospace; font-size: 16px; line-height: 1.4; margin: 0; padding: 4rem 0; min-height: 100%; overflow-wrap: break-word; }
main, header, footer { max-width: 800px; margin-inline: auto; padding: 0 2rem; }
h1, footer { text-align: center; }
p, h2, h3 { margin: 1em 0 0 0; }
header { margin-bottom: 1em; }
footer { margin-top: 3em; }
hr { border: none; border-top: thin solid; margin: 1.25rem 0; }
main { text-align: justify; }
ul { padding: 0; margin: 1em 0; column-count: 2; column-gap: 2rem; }
li { padding: 0.25rem 0; break-inside: avoid; }
ol { margin: 0.5em 0 0 1.5em; padding: 0; }
ol li { padding: 0.2rem 0; }
@media (max-width: 600px) { body { font-size: 0.9em; } h1 { font-size: 1.8em; } }
@media (max-width: 400px) { body { font-size: 0.8em; } h1 { font-size: 1.6em; } }
@media (prefers-color-scheme: dark) { html { filter: invert(1); } img { filter: invert(1); } }
</style>
</head>
<body>
<header>
<nav><strong><a href="https://gumx.cc">gumx</a></strong> / webring</nav>
</header>
<main>
<h1>webring</h1>
<p>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>
<h2>members</h2>
<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>
<h2>join</h2>
<ol>
<li>Clone the <a href="https://git.gumx.cc/webring">repository</a></li>
<li>Add your site: <code>./wr add example.com "my site" "Your Name"</code></li>
<li>Submit a patch via <a href="https://github.com/gumxcc/webring">GitHub</a> pull request, <a href="https://gitlab.com/gumxcc/webring">GitLab</a> merge request, or <a href="https://git-send-email.io/">git send-email</a></li>
<li>Add prev/next links to your site footer: <code><a href="https://${DOMAIN}/example.com/previous">&larr; previous</a></code> / <code><a href="https://${DOMAIN}/example.com/next">next &rarr;</a></code></li>
</ol>
<h2>host your own</h2>
<ol>
<li>Clone the <a href="https://git.gumx.cc/webring">repository</a></li>
<li>Clear existing entries: <code>rm -fr entries/* public</code></li>
<li>Add your webring as an entry: <code>./wr add yourdomain.com "my webring" "Your Name"</code></li>
<li>Add member entries and run <code>./wr</code> to build</li>
<li>Deploy the <code>public/</code> directory to any static host</li>
</ol>
</main>
<footer>
<hr>
<a href="https://twt.gumx.cc">twt</a> /
<a href="https://git.gumx.cc">git</a> /
<a href="https://mail.gumx.cc">mail</a> /
<a href="https://lists.gumx.cc">list</a> /
<a href="https://irc.gumx.cc">irc</a> /
<a href="https://files.gumx.cc">files</a> /
<a href="https://vpn.gumx.cc">vpn</a> /
<a href="https://pgp.gumx.cc">pgp</a> /
<a href="https://demo.gumx.cc">demo</a> /
<a href="https://wk.fo">wk.fo</a>
<br>
<a href="/${DOMAIN}/previous">← previous site</a> /
<a href="/${DOMAIN}/next">next site →</a>
<br>
<a href="https://git.gumx.cc/webring">source</a> /
<a href="https://gumx.cc/license">license</a>
</footer>
</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}/${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
|