summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2026-02-28 01:03:17 -0500
committerFreya Murphy <freya@freyacat.org>2026-02-28 01:03:17 -0500
commit0dfa656c70d70581ab4cd2ddf393cb432cd16517 (patch)
treee3f0396a65c854fa1da91c69bab08631b6cf8710
parentfix even more css (for ie4) (diff)
downloadwebsite-0dfa656c70d70581ab4cd2ddf393cb432cd16517.tar.gz
website-0dfa656c70d70581ab4cd2ddf393cb432cd16517.tar.bz2
website-0dfa656c70d70581ab4cd2ddf393cb432cd16517.zip
bucket webring: pull links from local json file
-rw-r--r--src/web/_controller/bucket.php4
-rw-r--r--src/web/_model/bucket.php48
-rw-r--r--src/web/_views/bucket/main.php5
-rw-r--r--src/web/_views/head.php2
4 files changed, 55 insertions, 4 deletions
diff --git a/src/web/_controller/bucket.php b/src/web/_controller/bucket.php
index 460f862..1723f72 100644
--- a/src/web/_controller/bucket.php
+++ b/src/web/_controller/bucket.php
@@ -17,6 +17,10 @@ class Bucket_controller extends Controller {
$this->error(400);
return;
}
+
+ $data['before'] = $this->bucket_model->get_before($data['name']);
+ $data['after'] = $this->bucket_model->get_after($data['name']);
+
$this->view('bucket/main', $data);
}
}
diff --git a/src/web/_model/bucket.php b/src/web/_model/bucket.php
index 7c426b7..3075ac3 100644
--- a/src/web/_model/bucket.php
+++ b/src/web/_model/bucket.php
@@ -1,6 +1,54 @@
<?php /* Copyright (c) 2024 Freya Murphy */
class Bucket_model extends Model {
+ private $bucket_json;
+ private $bucket_map;
+
+ function __construct()
+ {
+ $this->bucket_json = array();
+ if (file_exists('/var/run/crimson/bucket.json')) {
+ $this->bucket_json = file_get_contents('/var/run/crimson/bucket.json');
+ $this->bucket_json = json_decode($this->bucket_json) ?? array();
+ }
+
+ $this->bucket_map = array();
+ foreach ($this->bucket_json as $idx => $entry) {
+ $this->bucket_map[$entry->name ?? ''] = $idx;
+ }
+ }
+
+ public function get_before(string $name): string
+ {
+ $default = "https://webring.bucketfish.me/redirect.html?to=prev&name={$name}";
+
+ $idx = $this->bucket_map[$name ?? ''] ?? null;
+ if (!$idx)
+ return $default;
+
+ if ($idx)
+ $idx--;
+ else
+ $idx = count($this->bucket_json) - 1;
+
+ return $this->bucket_json[$idx]->url ?? $default;
+ }
+
+ public function get_after(string $name): string
+ {
+ $default = "https://webring.bucketfish.me/redirect.html?to=next&name={$name}";
+
+ $idx = $this->bucket_map[$name ?? ''] ?? null;
+ if (!$idx)
+ return $default;
+
+ $idx++;
+ if ($idx == count($this->bucket_json))
+ $idx = 0;
+
+ return $this->bucket_json[$idx]->url ?? $default;
+ }
+
public function get_data(): ?array
{
$data = parent::get_data();
diff --git a/src/web/_views/bucket/main.php b/src/web/_views/bucket/main.php
index b85c773..2842afc 100644
--- a/src/web/_views/bucket/main.php
+++ b/src/web/_views/bucket/main.php
@@ -1,6 +1,5 @@
<?php /* Copyright (c) 2024 Freya Murphy */ ?>
<?php
- $root='https://webring.bucketfish.me/redirect.html?to=%s&name=' . $name;
$this->view('head', $data);
if ($lightmode === 'true') {
echo embed_css_ext('css/bucket_light.css');
@@ -34,8 +33,8 @@
🏳️‍🌈
</span>
</center>
- <span class="left">⥼ <a href="<?=sprintf($root, 'prev')?>" class="prev">prev</a></span>
- <span class="right"><a href="<?=sprintf($root, 'next')?>" class="next">next</a> ⥽</span>
+ <span class="left">⥼ <a href="<?=$before?>" class="prev">prev</a></span>
+ <span class="right"><a href="<?=$after?>" class="next">next</a> ⥽</span>
</div>
</body>
</html>
diff --git a/src/web/_views/head.php b/src/web/_views/head.php
index 4d16a1b..281ebc5 100644
--- a/src/web/_views/head.php
+++ b/src/web/_views/head.php
@@ -7,7 +7,7 @@
if (ENVIRONMENT == 'production' && !in_array($current_app, $non_cached_apps)) {
$cache_seconds = 300;
if ($current_app == 'bucket') {
- $cache_seconds = 3600;
+ $cache_seconds = 86400;
}
header("Cache-Control: public, max-age=$cache_seconds");
header("Expires: " . gmdate('D, d M Y H:i:s', time() + $cache_seconds) . " UTC");