first commit

This commit is contained in:
Dominic DiTaranto 2025-12-30 15:59:38 -05:00
commit 5f17112de5
5 changed files with 227 additions and 0 deletions

32
README.md Normal file
View file

@ -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.
```
<div id="tilde-webring" style="margin: 0 auto; font-size: small;">
<table style="background-color: transparent; margin: 0 auto;">
<tr>
<td class='webring-prev' style="text-align: right;">
<a href='/redirect.html?type=previous&referrer=https://cocopie.neocities.org/'>-prev-</a>
</td>
<td class='webring-info' style="text-align: center;">
<a href="https://christian-webring.nekoweb.org/"><img src="https://i.imgur.com/rYx5Gur.png"/></a><br>
<span class='webring-links'>
<a href='/redirect.html?referrer=https://cocopie.neocities.org/'>random</a>
</span>
</td>
<td class='webring-next' style="text-align: left;">
<a href='/redirect.html?type=next&referrer=https://cocopie.neocities.org/'>-next-</a>
</td>
</tr>
</table>
</div>
```
# 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

122
index.html Normal file
View file

@ -0,0 +1,122 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>tilde.green webring</title>
</head>
<body>
<style>
body {
padding: 20px;
background-color: black;
font-family: monospace;
color: #8ec07c;
font-size: 20px;
}
h3 {
margin-bottom: -3px;
}
a {
color: #7c8ec0;
}
a:hover {
color: #c07c8e;
}
</style>
<h1>tilde.green webring</h1>
<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=~jigong"
><</a
>
</td>
<td class="webring-info" style="text-align: center">
<a href="https://tilde.green/~jigong/tilde-ring"
><img src="static/tilde-webring.png" /></a
><br />
<span class="webring-links">
<a
href="https://tilde.green/~jigong/tilde-ring/redirect.html?referrer=~jigong"
>?</a
>
</span>
</td>
<td class="webring-next" style="text-align: left">
<a
href="https://tilde.green/~jigong/tilde-ring/redirect.html?type=next&referrer=~jigong"
>></a
>
</td>
</tr>
</table>
</div>
REPO:
<a href="https://git.tilde.green/jigong/tilde-ring"
>https://git.tilde.green/jigong/tilde-ring</a
>
<h3>How to Join:</h3>
If you would like to join the webring you must satisfy the following
<ol>
<li>Be a member of tilde.green</li>
<li>Host a webpage on tilde.green that is not the default page</li>
<li>
Email jigong@tilde.green (or whoever takes over this... I am just using
me as an example) requesting to join
</li>
<li>
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
</li>
</ol>
<xmp>
<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>
</xmp>
</body>
</html>

8
redirect.html Normal file
View file

@ -0,0 +1,8 @@
<!doctype html>
<html lang="en">
<head>
<script type="text/javascript" src="static/redirect.js"></script>
</head>
<body></body>
</html>

65
static/redirect.js Normal file
View file

@ -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;
}

BIN
static/tilde-webring.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB