From f77c9ccffaca7c10d0b56346f5baa8756fbcbab9 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 1 Dec 2022 22:45:08 +0000 Subject: add link redirection thing, and documentation --- doc.txt | 10 ++++++++++ link.cgi | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100755 link.cgi diff --git a/doc.txt b/doc.txt index 32f9ad9..6a196d0 100644 --- a/doc.txt +++ b/doc.txt @@ -29,6 +29,16 @@ the pulsating animation on the word "GEORGE" is disabled if the CSS prefers-redu --- +GET https://george.gh0.pw/link.cgi?from=membername&dir=next|prev +redirects to the page of the GEORGE member in the selected direction from the given member. +this can be used if you want to construct your own GEORGE widget, for whatever reason. +for example, if your member name is 'example', you could do something like +NEXT +PREV +and these links will always go to the right place relative to your current position in the webring. + +--- + GET https://coral.shoes/george-status/george-status-json returns current status information about the GEORGE webring, including which members currently haven't correctly embedded the GEORGE widget onto their page. diff --git a/link.cgi b/link.cgi new file mode 100755 index 0000000..c0b40a5 --- /dev/null +++ b/link.cgi @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +from georgedata import george +order = list(george.keys()) + +from os import getenv +from urllib.parse import parse_qs +qs = getenv("QUERY_STRING") +query = parse_qs(qs) +try: + member = query["from"][0] + dir = query["dir"][0] + ind = order.index(member) + offs = {"next":1,"prev":-1}[dir] +except (ValueError,KeyError): + print("Status: 400") + print("Content-Type: text/html") + print() + print("

bad request

") +else: + l=len(order) + m = george[order[(ind+offs)%l]] + print("Location: "+m) -- cgit v1.2.3