webring

This commit is contained in:
dozens 2023-10-30 13:59:37 -06:00
parent d021ffed90
commit d7c5108c5b
7 changed files with 269 additions and 0 deletions

32
webring/README.md Normal file
View File

@ -0,0 +1,32 @@
# webring
the benevolent tildepals basement heroes 43beans commonheath of casakhstan webring
## joining
add your info to `db/members.rec`
## snippet
a code snippet to add to member site
all you have to do (after you've been added to the db) is add a few
anchor tags to your site. you can do something like the following,
replacing "yoursitename" with the value of "name" you provide in
members.rec
<div>
<p>this site is a member of a very powerful webring!</p>
<p>
&lt; <a href="https://friends.m455.casa/webring/index.html?name=yoursitename&dir=prev">previous</a> |
<a href="https://friends.m455.casa/webring/index.html">all</a> |
<a href="https://friends.m455.casa/webring/index.html?name=yoursitename&dir=next">next</a> &gt;
</p>
</div>
that would end up looking something like this:
this site is a member of a very powerful webring!
< previous | all | next >

20
webring/db/members.rec Normal file
View File

@ -0,0 +1,20 @@
%rec: member
%doc: a member of the webring
%key: id
%unique: id name url feed
%auto: id created
%type: id int
%type: created date
%type: title,url,feed line
%typedef: Name_t regexp /[a-z]{3,13}/
%type: name Name_t
%allowed: id created title name url feed
%mandatory: id title name url
%sort: id
id: 0
created: Mon, 30 Oct 2023 13:38:40 -0600
name: dozens
title: dozens
url: https://tilde.town/~dozens
feed:

73
webring/index.html Normal file
View File

@ -0,0 +1,73 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>webring</title>
<style type="text/css" media="screen">
body {
max-width: 70ch;
margin: 0 auto;
}
</style>
</head>
<body>
<header>
<h1>the benevolent tildepals basement heroes 43beans commonheath of casakhstan webring</h1>
</header>
<main>
<section>
<h2>members</h2>
<ul>
<li>
<a href="https://tilde.town/~dozens">dozens</a>
</li>
</ul>
</section>
<section id="about">
<h2>about</h2>
<p>
for more info about becoming a member
and adding the webring to your site
see <a href="https://tildegit.org/casa/pages/src/branch/main/webring">https://tildegit.org/casa/pages/src/branch/main/webring</a>
</p>
</section>
</main>
<footer>
<p>
<small>
this webring is built using <a href="https://git.tilde.town/dozens/webring">https://git.tilde.town/dozens/webring</a>
</small>
</p>
</footer>
</body>
</html>
<script>
const members = [
{
"id": false,
"name": "dozens",
"url": "https://tilde.town/~dozens",
},
]
const last = members.length - 1
const query = window.location.search
const params = new URLSearchParams(query)
const name = params.get('name')
const dir = params.get('dir')
if (name && dir) {
const step = (dir === 'next') ? 1 : (dir === 'prev') ? -1 : 0
const member = members.filter(member => member.name === name)[0]
if (!(typeof member === "undefined")) {
const next = (member.id + step > last)
? 0
: (member.id + step < 0)
? last
: member.id + step
const loc = members.filter(m => m.id === next)[0]
window.location.replace(loc.url)
}
}
</script>

38
webring/justfile Normal file
View File

@ -0,0 +1,38 @@
# list all recipes
default:
just --list --unsorted
# add a new webring member
new:
#!/usr/bin/env sh
read -p "name (lowercase, 3-13 characters): " name
read -p "title: " title
read -p "url: " url
read -p "feed: " feed
recins --verbose -t member \
-f "name" -v "$name" \
-f "title" -v "$title" \
-f "url" -v "$url" \
-f "feed" -v "$feed" \
db/members.rec
alias add := new
# build html
html:
recsel db/members.rec \
| rec2csv \
| csvjson \
| jq '. | {data: .}' \
| mustache - src/example.html index.html
# build opml
opml:
recsel db/members.rec \
| rec2csv \
| csvjson \
| jq '. | {data: .}' \
| jq '{ data: [ .data[] | select(.feed != null) ] }' \
| mustache - src/example.opml webring.opml
# compile html and opml
build: html opml

77
webring/src/example.html Normal file
View File

@ -0,0 +1,77 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>webring</title>
<style type="text/css" media="screen">
body {
max-width: 70ch;
margin: 0 auto;
}
</style>
</head>
<body>
<header>
<h1>the benevolent tildepals basement heroes 43beans commonheath of casakhstan webring</h1>
</header>
<main>
<section>
<h2>members</h2>
<ul>
{{#data}}
<li>
<a href="{{{url}}}">{{{title}}}</a>
</li>
{{/data}}
</ul>
</section>
<section id="about">
<h2>about</h2>
<p>
for more info about becoming a member
and adding the webring to your site
see <a href="https://tildegit.org/casa/pages/src/branch/main/webring">https://tildegit.org/casa/pages/src/branch/main/webring</a>
</p>
</section>
</main>
<footer>
<p>
<small>
this webring is built using <a href="https://git.tilde.town/dozens/webring">https://git.tilde.town/dozens/webring</a>
</small>
</p>
</footer>
</body>
</html>
<script>
const members = [
{{#data}}
{
"id": {{{id}}},
"name": "{{{name}}}",
"url": "{{{url}}}",
},
{{/data}}
]
const last = members.length - 1
const query = window.location.search
const params = new URLSearchParams(query)
const name = params.get('name')
const dir = params.get('dir')
if (name && dir) {
const step = (dir === 'next') ? 1 : (dir === 'prev') ? -1 : 0
const member = members.filter(member => member.name === name)[0]
if (!(typeof member === "undefined")) {
const next = (member.id + step > last)
? 0
: (member.id + step < 0)
? last
: member.id + step
const loc = members.filter(m => m.id === next)[0]
window.location.replace(loc.url)
}
}
</script>

16
webring/src/example.opml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<opml version="2.0">
<head>
<title>tildepals webring</title>
<text>tildepals webring</text>
<ownerName>dozens</ownerName>
<ownerEmail>dozens@tilde.team</ownerEmail>
</head>
<body>
<outline text="tildepals webring" title="tildepals webring">
{{#data}}
<outline text="{{{name}}}" title="{{{title}}}" type="rss" xmlUrl="{{{feed}}}" />
{{/data}}
</outline>
</body>
</opml>

13
webring/webring.opml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<opml version="2.0">
<head>
<title>webring</title>
<text>webring</text>
<ownerName>dozens</ownerName>
<ownerEmail>dozens@tilde.team</ownerEmail>
</head>
<body>
<outline text="webring" title="webring">
</outline>
</body>
</opml>