From 3296eee590f795022dfae49567860270af5c6d51 Mon Sep 17 00:00:00 2001 From: Ahmed Date: Tue, 2 Jun 2026 01:14:00 +0300 Subject: init: moved to git.gumx.cc --- wr | 211 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100755 wr (limited to 'wr') diff --git a/wr b/wr new file mode 100755 index 0000000..1e4f07f --- /dev/null +++ b/wr @@ -0,0 +1,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 + + + + + + + + + webring + + + + + + + + + + + + + + + + + + + +
+

ω webring

+
+ +
+

This is an attempt to replicate Devine Lu Linvega's webring in a very minimal way, and with a lower technical bar.

+

To add your site to the webring, follow the instructions here. For issues, source code, documentation, visit the project page on sourcehut

+

This project is licensed under MIT license

+
+ +
+ + + +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: + +

+ ← previous +   + webring index +   + next → +

+ +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 -- cgit v1.2.3