From a67ca468ef1cefd6d685e60456ef2ba137290609 Mon Sep 17 00:00:00 2001 From: Oscar Admin Contributors Date: Thu, 3 Dec 2026 18:49:13 -0500 Subject: [PATCH] Add SEO metadata and git repo link to admin pages Makes login page indexable with description/OG/canonical options, keeps authenticated dashboard noindex, and adds a footer link to the source repository. --- lib.php | 26 +++++++++++++++++++++++--- login.php | 7 +++++-- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/lib.php b/lib.php index eefea1a..8c6eede 100644 --- a/lib.php +++ b/lib.php @@ -326,20 +326,24 @@ function admin_redirect(string $url): never exit; } -function admin_page(string $title, string $active, callable $body): void +function admin_page(string $title, string $active, callable $body, array $opts = []): void { $user = admin_current_user(); $flashes = admin_flashes(); $site = (string) admin_cfg('site_name', 'Oscar Admin'); $shared = (string) admin_cfg('shared_style_path', 'assets/style.css'); $sharedHref = file_exists(__DIR__ . '/' . ltrim($shared, '/')) ? $shared : $shared; + $indexable = !empty($opts['indexable']); + $desc = trim((string) ($opts['description'] ?? ($indexable ? 'Oscar Admin is a standalone web admin dashboard for Open OSCAR Server. Manage users, sessions, rooms, BART, buddy lists, and more.' : ''))); + $canonical = trim((string) ($opts['canonical'] ?? '')); + $repoUrl = trim((string) ($opts['repo_url'] ?? 'https://git.claytonia.net/Clarth/oscar-admin')); if (!headers_sent()) { header('X-Frame-Options: DENY'); header('X-Content-Type-Options: nosniff'); header('Referrer-Policy: no-referrer'); header('Permissions-Policy: camera=(), microphone=(), geolocation=()'); - header('X-Robots-Tag: noindex, nofollow'); + header('X-Robots-Tag: ' . ($indexable ? 'index, follow' : 'noindex, nofollow')); header("Content-Security-Policy: default-src 'self'; base-uri 'self'; object-src 'none'; frame-ancestors 'none'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; connect-src 'self'; form-action 'self'"); } ?> @@ -348,7 +352,18 @@ function admin_page(string $title, string $active, callable $body): void - + + + + + + + + + + + + <?= h($title) ?> - <?= h($site) ?> @@ -399,6 +414,11 @@ function admin_page(string $title, string $active, callable $body): void + diff --git a/login.php b/login.php index 615daa6..f1cd250 100644 --- a/login.php +++ b/login.php @@ -32,7 +32,6 @@ if (!headers_sent()) { header('X-Content-Type-Options: nosniff'); header('Referrer-Policy: no-referrer'); header('Permissions-Policy: camera=(), microphone=(), geolocation=()'); - header('X-Robots-Tag: noindex, nofollow'); header("Content-Security-Policy: default-src 'self'; base-uri 'self'; object-src 'none'; frame-ancestors 'none'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; connect-src 'self'; form-action 'self'"); } @@ -298,4 +297,8 @@ admin_page('Login', 'login', function () use ($error, $notice, $pending, $stage, true, + 'description' => 'Oscar Admin is a standalone open-source web dashboard for managing Open OSCAR Server: users, sessions, chat rooms, BART assets, buddy lists, and more.', + 'repo_url' => 'https://git.claytonia.net/Clarth/oscar-admin', +]);