Go to file
2024-01-21 18:37:01 +00:00
dinit Add dinit updater 2024-01-21 18:37:01 +00:00
LICENSES Add licenses for REUSE compliance 2021-12-31 12:49:26 -05:00
.gitignore Build binary at repo root 2023-12-04 13:43:46 +00:00
.pre-commit-config.yaml Add licenses for REUSE compliance 2021-12-31 12:49:26 -05:00
funcs.go Check if website contains webring server hostname 2023-12-04 14:19:56 +00:00
go-webring.service Add systemd service 2022-09-03 01:12:17 +08:00
go.mod Add licenses for REUSE compliance 2021-12-31 12:49:26 -05:00
go.sum Add all of the flags 2021-12-25 08:14:54 -05:00
go.sum.license Add licenses for REUSE compliance 2021-12-31 12:49:26 -05:00
handlers.go fix off-by-one 2024-01-10 22:16:34 +00:00
index.html Update instructions 2023-12-04 14:03:43 +00:00
index.md correct heading level in example home page 2021-12-31 19:25:11 -05:00
list.txt Add example inputs 2021-12-31 11:13:22 -05:00
list.txt.license Add licenses for REUSE compliance 2021-12-31 12:49:26 -05:00
main.go Add id= urlpart= 2023-12-04 13:33:10 +00:00
Makefile Build binary at repo root 2023-12-04 13:43:46 +00:00
README.md update wakapi shield for cumulative time 2022-04-26 09:17:51 -04:00
start.fish update socket path 2024-01-21 18:37:01 +00:00
updater Add updater 2023-12-04 14:23:24 +00:00

go-webring

REUSE status Donate with fosspay Time spent on project

Simple webring implementation created for the Fediring

git clone https://git.sr.ht/~amolith/go-webring
cd go-webring
pandoc -s index.md -o index.html
go build
./go-webring
xdg-open http://127.0.0.1:2857

Usage

$ ./go-webring -h
Usage of ./go-webring
  -i, --index string     Path to home page template (default "index.html")
  -l, --listen string    Host and port go-webring will listen on (default "127.0.0.1:2857")
  -m, --members string   Path to list of webring members (default "list.txt")

This webring implementation handles four paths:

  • Root: returns the home page template replacing the string "{{ . }}" with an HTML table of ring members
  • Next: returns a 302 redirect pointing to the next site in the list
  • Previous: returns a 302 redirect pointing to the previous site in the list
  • Random: returns a 302 redirect pointing to a random site in the list

The next and previous paths require a ?host= parameter containing a URL-encoded URI of the site being visited. For example, if Sam is a member of a webring on example.com and her site is sometilde.com/~sam, she will need the following links on her page for directing visitors to the next/previous ring members.

  • https://example.com/next?host=sometilde.com%2F~sam
  • https://example.com/previous?host=sometilde.com%2F~sam

With provided examples

See the included list.txt and index.md for examples of a webring setup. To run go-webring with those examples, first install pandoc then generate index.html from index.md like so:

$ pandoc -s index.md -o index.html

Next, you'll need to install Go and build the project.

$ go build

After that, simply execute the binary then open localhost:2857 in your browser.

$ ./go-webring

With custom files

To run your own webring, you'll first need a template homepage. This should be any HTML file with the string "{{ . }}" placed wherever you want the table of members inserted. This table is plain HTML so you can style it with CSS in the template's <head> or in a separate .css file.

Pandoc produces very pleasing (in my opinion) standalone HTML pages; if you just want something simple, I would recommend modifying the included index.md and generating your homepage as in section above.

Next, you'll need a text file containing a list of members. On each line should be the member's unique identifer (such as their username) followed by a single space followed by their site's URI omitting the scheme. For example, if a user is bob and his site is https://bobssite.com, his line would look like the following.

bob bobssite.com

If the user was sam and her site was https://sometilde/~sam, her line would look like this:

sam sometilde/~sam

With those two members in the text file, the HTML inserted into the home page will be the following.

<tr>
  <td>bob</td>
  <td><a href="https://bobssite.com">bobssite.com</a><td>
</tr>
<tr>
  <td>sam</td>
  <td><a href="https://sometilde.com/~sam">sometilde.com/~sam</a><td>
</tr>

Assuming this webring is on example.com, Bob will need to have the following links on his page.

  • https://example.com/next?host=bobssite.com
  • https://example.com/previous?host=bobssite.com

Because Sam has a forward slash in her URI, she'll need to percent-encode it so browsers interpret the parameter correctly.

  • https://example.com/next?host=sometilde.com%2F~sam
  • https://example.com/previous?host=sometilde.com%2F~sam

Questions & Contributions

Questions, comments, and patches can always be sent to my public inbox, but I'm also in my IRC channel/XMPP room pretty much 24/7. However, I might not see messages right away because I'm working on something else (or sleeping) so please stick around!

If you're wanting to introduce a new feature and I don't feel like it fits with this project's goal, I encourage you to fork the repo and make whatever changes you like!

If you haven't used mailing lists before, please take a look at SourceHut's documentation, especially the etiquette section.