commit 5f17112de554c2d33f2ac9dfe6042853986bbf63 Author: Dominic DiTaranto Date: Tue Dec 30 15:59:38 2025 -0500 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..8e478e6 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# Summary + +Simple webring that does not require users to add javascript to their page + +# Getting started +Add this code to your page and email jigong@tilde.green to joing the webring! You need to modify the referrer in three places to point to your own webpage. +``` +
+ + + + + + +
+ -prev- + +
+ + random + +
+ -next- +
+
+ +``` + + +# Implement your own webring + +clone this repo and host the redirect.html and the static directory. You will also want to modify the code that users will put on their end page to suit your needs diff --git a/index.html b/index.html new file mode 100644 index 0000000..99eeed9 --- /dev/null +++ b/index.html @@ -0,0 +1,122 @@ + + + + + tilde.green webring + + + + +

tilde.green webring

+ +
+ + + + + + + +
+ < + +
+ + ? + +
+ > +
+
+ + REPO: + https://git.tilde.green/jigong/tilde-ring + +

How to Join:

+ If you would like to join the webring you must satisfy the following +
    +
  1. Be a member of tilde.green
  2. +
  3. Host a webpage on tilde.green that is not the default page
  4. +
  5. + Email jigong@tilde.green (or whoever takes over this... I am just using + me as an example) requesting to join +
  6. +
  7. + Add the following code snippet to your page, replacing the text + YOUR_USERNAME with your tilde username. include the tilde before your + username like ~jigong +
  8. +
+ + + <div id="webring" style="margin: 0 auto; font-size: small"> + <style> + #webring a { + color: #8ebf7c; + font-size: 20px; + font-weight: bolder; + text-decoration: none; + } + </style> + <table style="background-color: transparent; margin: 0 auto"> + <tr> + <td class="webring-prev" style="text-align: right"> + <a href="https://tilde.green/~jigong/tilde-ring/redirect.html?type=previous&referrer=YOUR_USER_NAME"><</a> + </td> + <td class="webring-info" style="text-align: center"> + <a href="https://tilde.green/~jigong/tilde-ring" + ><img src="https://tilde.green/~jigong/tilde-ring/static/tilde-webring.png" /></a + ><br /> + <span class="webring-links"> + <a href="https://tilde.green/~jigong/tilde-ring/redirect.html?referrer=YOUR_USER_NAME">?</a> + </span> + </td> + <td class="webring-next" style="text-align: left"> + <a href="https://tilde.green/~jigong/tilde-ring/redirect.html?type=next&referrer=YOUR_USER_NAME">></a> + </td> + </tr> + </table> + </div> + + + diff --git a/redirect.html b/redirect.html new file mode 100644 index 0000000..bca4cd0 --- /dev/null +++ b/redirect.html @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/static/redirect.js b/static/redirect.js new file mode 100644 index 0000000..1c841ae --- /dev/null +++ b/static/redirect.js @@ -0,0 +1,65 @@ +const sites = ["~jigong", "rafhei0"]; + +function getRandomSite(ignore) { + // get random index from sites + const index = Math.floor(Math.random() * sites.length); + // if random site is referrer, retry + return index === ignore ? getRandomSite(ignore) : sites[index]; +} + +const validRedirectTypes = ["next", "previous", "random"]; + +// parse url params +const params = new URLSearchParams(window.location.search); +let referrerUrl = params.get("referrer"); +let type = params.get("type") || "random"; // default to random if no type given + +if (!validRedirectTypes.includes(type)) { + // default to random is type not valid + type = "random"; +} + +if (!sites.includes(referrerUrl)) { + // referrer url is incorrect, select random referrer from sites list, + referrerUrl = sites[Math.floor(Math.random() * sites.length)]; + // select random site, and redirect to it + window.location.href = sites[Math.floor(Math.random() * sites.length)]; +} + +// get index of the referrer url +const referrerIndex = sites.indexOf(referrerUrl); +let redirect; +if (type === "random") { + redirect = getRandomSite(referrerIndex); +} else if (type === "next") { + // get index of next website in list + let nextIndex = referrerIndex + 1; + + // if index is greater than the length of list, loop back to 0 index + if (nextIndex > sites.length - 1) { + nextIndex = 0; + } + + redirect = sites[nextIndex]; +} else { + // redirect to previous + let previousIndex = referrerIndex - 1; + if (previousIndex < 0) { + // if previous index is less than 0, loop around to last index + previousIndex = sites.length - 1; + } + + redirect = sites[previousIndex]; +} + +if (redirect[0] !== "~") { + redirect = `~${redirect}`; +} + +if (redirect === "~rafhei0") { + redirect = `https://tilde.green/${redirect}/p/0.html`; + window.location.href = redirect; +} else { + redirect = `https://tilde.green/${redirect}/`; + window.location.href = redirect; +} diff --git a/static/tilde-webring.png b/static/tilde-webring.png new file mode 100644 index 0000000..bed8acc Binary files /dev/null and b/static/tilde-webring.png differ