From 898b52edcb47bcb3e9d6106e74ca73e74ea01e70 Mon Sep 17 00:00:00 2001 From: sillylaird Date: Thu, 3 Sep 2026 00:33:59 +0000 Subject: import live www.sillylaird.ca webroot --- partials/admin_vibe.php | 201 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 partials/admin_vibe.php (limited to 'partials/admin_vibe.php') diff --git a/partials/admin_vibe.php b/partials/admin_vibe.php new file mode 100644 index 0000000..74227c3 --- /dev/null +++ b/partials/admin_vibe.php @@ -0,0 +1,201 @@ + '', 'url' => '', 'updated' => '']; + +$errors = []; +$success = false; + +// Handle POST save +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $desc = trim($_POST['description'] ?? ''); + $url = trim($_POST['url'] ?? ''); + $updated = date('Y-m-d'); + + // Basic URL validation (allow empty) + if ($url !== '' && !filter_var($url, FILTER_VALIDATE_URL)) { + $errors[] = 'URL does not appear to be valid.'; + } + + if (empty($errors)) { + $export = var_export([ + 'description' => $desc, + 'url' => $url, + 'updated' => $updated, + ], true); + + $content = " $desc, 'url' => $url, 'updated' => $updated]; + } else { + $errors[] = 'Could not write vibe.php — check file permissions.'; + } + } +} + +// Detect embed type for preview +function admin_vibe_detect_type(string $url): string { + if (empty($url)) return 'none'; + $path = strtolower(parse_url($url, PHP_URL_PATH) ?? ''); + $ext = pathinfo($path, PATHINFO_EXTENSION); + $images = ['jpg','jpeg','png','gif','webp','bmp','svg','avif']; + $videos = ['mp4','webm','ogv','mov']; + $audio = ['mp3','flac','wav','ogg','aac','opus','m4a']; + if (in_array($ext, $images)) return 'image'; + if (in_array($ext, $videos)) return 'video'; + if (in_array($ext, $audio)) return 'audio'; + if (preg_match('/(?:youtube\.com\/watch\?.*v=|youtu\.be\/)([A-Za-z0-9_-]{11})/', $url, $m)) return 'youtube:' . $m[1]; + if (preg_match('/vimeo\.com\/(\d+)/', $url, $m)) return 'vimeo:' . $m[1]; + return 'link'; +} + +$preview_type = admin_vibe_detect_type($vibe['url'] ?? ''); +$safe_url = htmlspecialchars($vibe['url'] ?? '', ENT_QUOTES, 'UTF-8'); + +// Human-readable label for detected type +function type_label(string $type): string { + if ($type === 'none') return '—'; + if ($type === 'image') return 'Image'; + if ($type === 'video') return 'Video'; + if ($type === 'audio') return 'Audio'; + if ($type === 'link') return 'Plain link'; + if (str_starts_with($type, 'youtube:')) return 'YouTube embed'; + if (str_starts_with($type, 'vimeo:')) return 'Vimeo embed'; + return 'Unknown'; +} +?> + + + + + + Edit Current Vibe — SillyLaird + + + + + +
+ ← Back to admin +

Edit: My Current Vibe

+ + +

✓ Saved successfully.

+ + + +
+ +

+ +
+ + +
+
+ + +
+ +
+ + + + Detected type: + +
+ + +

Last saved:

+ + + +
+ + +
+

Current Preview

+ + +

+ Vibe preview + + +

+ + + +

+ + + + +

+
+ +
+ + + +

+
+ +
+ + +

+ +
+ + +
+ + -- cgit v1.2.3