add explore list to webring
This commit is contained in:
parent
9e7007e7f4
commit
f003e0ae62
|
@ -1,33 +1,37 @@
|
|||
<?php
|
||||
$action = $_GET["action"] ?? "index";
|
||||
$users = [];
|
||||
foreach (glob("/home/*/.ring") as $path)
|
||||
$users[] = basename(dirname($path));
|
||||
|
||||
if ($action !== "index") {
|
||||
$users = [];
|
||||
foreach (glob("/home/*/.ring") as $path)
|
||||
$users[] = basename(dirname($path));
|
||||
// handle webring redirects
|
||||
|
||||
$me = $_GET["me"] ?? "";
|
||||
$i = array_search($me, $users) ?? 0;
|
||||
|
||||
switch ($action) {
|
||||
case "random":
|
||||
$notme = array_diff($users, [$me]);
|
||||
$user = $notme[array_rand($notme)];
|
||||
break;
|
||||
case "next":
|
||||
$user = $users[$i + 1] ?? $users[0];
|
||||
break;
|
||||
case "prev":
|
||||
$user = $users[$i - 1] ?? $users[count($users) - 1];
|
||||
break;
|
||||
default:
|
||||
die("invalid action");
|
||||
case "random":
|
||||
$notme = array_diff($users, [$me]);
|
||||
$user = $notme[array_rand($notme)];
|
||||
break;
|
||||
case "next":
|
||||
$user = $users[$i + 1] ?? reset($users);
|
||||
break;
|
||||
case "prev":
|
||||
$user = $users[$i - 1] ?? end($users);
|
||||
break;
|
||||
default:
|
||||
die("invalid action");
|
||||
}
|
||||
|
||||
header("Location: https://tilde.team/~$user/");
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
// keep this as a string so we can escape it easily with htmlspecialchars()
|
||||
$snippet = '<!-- Begin Tilde.Team Ring Fragment-->
|
||||
<div id="newring">
|
||||
<center>
|
||||
|
@ -43,26 +47,32 @@ else {
|
|||
<html>
|
||||
<head>
|
||||
<title>webring - how to join</title>
|
||||
<link rel="stylesheet" href="https://tilde.team/~ben/gruvbox/gruvbox.min.css">
|
||||
<style><?php include "../gruvbox/gruvbox.min.css"; ?></style>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
</head>
|
||||
<body id="top">
|
||||
<main>
|
||||
<h1>how to join the webring</h1>
|
||||
|
||||
<p>This webring can be joined by any user on tilde.team.</p>
|
||||
<p>First, add the following code to your page, replacing USERNAME by your username (no ~):</p>
|
||||
|
||||
<pre><?=htmlspecialchars($snippet)?></pre>
|
||||
<p>this webring can be joined by any user on tilde.team.</p>
|
||||
<p>first, add the following links to your page, replacing USERNAME by your username (no ~):</p>
|
||||
|
||||
<p>You may edit the code however you want. It should work as long as the URLs are kept in place and have your user in them.</p>
|
||||
<pre><?=htmlspecialchars($snippet)?></pre>
|
||||
|
||||
<p>Then create a .ring file in your ~ to be added in the webring:</p>
|
||||
<p>you may edit the code however you want. it should work as long as the URLs are kept in place and have your user in them.</p>
|
||||
|
||||
<p>then create a .ring file in your ~ to be added in the webring:</p>
|
||||
<pre>$ touch ~/.ring</pre>
|
||||
|
||||
<h3>explore webring</h3>
|
||||
<ul>
|
||||
<?php foreach ($users as $user): ?>
|
||||
<li><a href="https://tilde.team/~<?=$user?>/">~<?=$user?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<p>see webring source <a href="index.php.txt">here</a></p>
|
||||
<p>it will probably work if you copy it to your <code>~/public_html</code></p>
|
||||
<p>it will probably work if you copy it to your own <code>~/public_html</code></p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue