feature/webring #18

Closed
dozens wants to merge 6 commits from feature/webring into main
7 changed files with 277 additions and 0 deletions

32
webring/README.md Normal file
View File

@ -0,0 +1,32 @@
# webring
the benevolent tildepals basement heroes 43beans commonhealth of casakhstan webring
dozens marked this conversation as resolved Outdated
Outdated
Review

commonheath

commonhealth?

Edit: also webring/src/example.html#L16

>commonheath commonhealth? Edit: also [webring/src/example.html#L16](https://tildegit.org/casa/pages/src/commit/ffc1c77ad0851da7b1e4f9897ace260f00100d6f/webring/src/example.html#L16)

good catch mio!
fixed!

good catch mio! fixed!
## 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 >

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

@ -0,0 +1,30 @@
%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
# FIELDS AND VALUES
# id: an incrementing integer
# created: timestamp
# name: a short slug to be used in the query params.
# 3 - 13 letters, lowercase, no spaces
# title: the title of your site. can be different from
# name. can have spaces, capital letters, etc
# url: link to the page where the webring code will appear
# feed: optional. a link to a rss/atom feed for your site
id: 0
created: Mon, 30 Oct 2023 13:38:40 -0600
name: dozens
title: tilde.town/~dozens
url: https://tilde.town/~dozens

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 commonhealth of casakhstan webring</h1>
</header>
<main>
<section>
<h2>members</h2>
<ul>
<li>
<a href="https://tilde.town/~dozens">tilde.town/~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": 0,
dozens marked this conversation as resolved Outdated

Now that's an interesting take on IDs 😛

Now that's an interesting take on IDs 😛

that's going to be a problem actually,
i need to perform number math on that id value
(as opposed to the less reliable but arguably more popular feelings math)

that's going to be a problem actually, i need to perform number math on that id value (as opposed to the less reliable but arguably more popular feelings math)
"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>

37
webring/justfile Normal file
View File

@ -0,0 +1,37 @@
# 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 -e 'feed != ""' \
| rec2csv \
| csvjson \
| jq '. | {data: .}' \
| mustache - src/example.opml webring.opml
dozens marked this conversation as resolved
Review

Couldn't those two jq calls be merged into a { data: map(select(.feed != null)) }, or maybe the filtering can be done in recsel directly?

Couldn't those two `jq` calls be merged into a `{ data: map(select(.feed != null)) }`, or maybe the filtering can be done in `recsel` directly?
Review

yes
this is a relic from when i had the rec->json transformation abstracted out into its own 'json' recipe.
to make the separate html and opml recipes,
i just copypasta the json recipe into them.
i think i always meant to go back
and do the filtering in recsel directly here.

yes this is a relic from when i had the rec->json transformation abstracted out into its own 'json' recipe. to make the separate html and opml recipes, i just copypasta the json recipe into them. i think i always meant to go back and do the filtering in recsel directly here.
# 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 commonhealth 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>

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

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<opml version="2.0">
<head>
<text>tildepals webring</text>
<ownerName>dozens</ownerName>
<ownerEmail>dozens@tilde.team</ownerEmail>
</head>
<body>
<outline text="tildepals webring" title="tildepals webring">
{{#data}}
dozens marked this conversation as resolved
Review

title is only useful for type="rss" outlines, where it's supposed to be the <title> of the RSS feed, so this can be omitted from other outlines

`title` is only useful for `type="rss"` outlines, where it's supposed to be the `<title>` of the RSS feed, so this can be omitted from other outlines
<outline text="{{{name}}}" title="{{{title}}}" type="rss" xmlUrl="{{{feed}}}" htmlUrl="{{{url}}}" />
{{/data}}
dozens marked this conversation as resolved
Review

This could include the website's URL as well using htmlUrl

This could include the website's URL as well using `htmlUrl`
</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>tildepals webring</title>
<text>tildepals webring</text>
<ownerName>dozens</ownerName>
<ownerEmail>dozens@tilde.team</ownerEmail>
</head>
<body>
<outline text="tildepals webring" title="tildepals webring">
</outline>
</body>
</opml>