Add table-based legacy design

This commit is contained in:
Roscoe 2025-08-10 02:54:16 +01:00
commit 57bb0e03a3
Signed by: RoscoeDaWah
SSH key fingerprint: SHA256:Hqn452XQ1ETzUt/FthJu6+OFkS4NBxCv5VQSEvuk7CE
35 changed files with 886 additions and 526 deletions

View file

@ -0,0 +1,15 @@
<?php
if (!function_exists('isLegacy')) {
/**
* Checks if the current hostname should return the legacy site
* @return bool
*/
function isLegacy(): bool {
return (
request()->getHost() === "legacy.wah.moe" || // Accessed via legacy.wah.moe domain
str_starts_with(request()->getHost(), "192.168") || // Accessed via local IP address
!request()->hasHeader("Host") // Browser does not send Host header (e.g. NCSA MOSAIC)
);
}
}

View file

@ -8,7 +8,11 @@
class RoscoLekoController extends Controller {
public function getImages(): array {
$images = [];
foreach (File::glob(public_path('images/pandamonium').'/*') as $path) {
$path = 'images/pandamonium';
if (isLegacy()) {
$path = 'images/pandamonium-legacy';
}
foreach (File::glob(public_path($path).'/*') as $path) {
$image_data = [];
try {
$exif = exif_read_data($path);

View file

@ -24,7 +24,7 @@ public static function insertGuestbookEntry(Request $request) {
$newEntry->message = $request->get('message');
$newEntry->ip = $request->ip();
$newEntry->agent = $request->userAgent();
$newEntry->admin = auth()->check();
$newEntry->legacy_flagged = isLegacy();
$newEntry->save();
}

View file

@ -8,11 +8,18 @@
class LastFMCurrent extends Component {
public $track;
public $artUrl;
/**
* Create a new component instance.
*/
public function __construct($track) {
$this->track = $track;
if (isLegacy()) {
$path = parse_url($track["image"], PHP_URL_PATH);
$this->artUrl = "//".request()->getHttpHost()."/proxy/lastfm/".basename($path);
} else {
$this->artUrl = $track["image"];
}
}
/**

View file

@ -17,9 +17,15 @@ public function __construct() {}
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string {
return view('components.layout', [
'isChristmas' => $this->isItChristmas()
]);
if (isLegacy()) {
return view('components.layout-legacy', [
'isChristmas' => $this->isItChristmas()
]);
} else {
return view('components.layout', [
'isChristmas' => $this->isItChristmas()
]);
}
}
public function isItChristmas() : bool {

View file

@ -17,6 +17,17 @@ public function __construct() {}
public function getWah(): string {
if (isLegacy()) {
try {
$response = Http::get('https://api.tinyfox.dev/img.json?animal=wah');
$data = $response->json();
if ($data == null) return "";
$path = parse_url("https://api.tinyfox.dev" . $data["loc"], PHP_URL_PATH);
return "//".request()->getHttpHost()."/proxy/wah/".basename($path);
} catch (Exception $ex) {
return "";
}
}
try {
$response = Http::get('https://api.tinyfox.dev/img.json?animal=wah');
$data = $response->json();
@ -26,7 +37,6 @@ public function getWah(): string {
} catch (Exception $ex) {
return "";
}
}
/**