- Implemented configurable public URL rewriting.
What changed: Added pretty URL helpers/default setting in [includes/db.php](/Users/tyemeclifford/Documents/GH/mediaplayer/includes/db.php). Added root rewrite rules in [.htaccess](/Users/tyemeclifford/Documents/GH/mediaplayer/.htaccess):/v/<slug> /all /search/<query> Added Admin → Settings “Public URL Style” toggle in [admin/settings.php](/Users/tyemeclifford/Documents/GH/mediaplayer/admin/settings.php), defaulting to pretty URLs. Updated public/player/catalogue/embed/admin preview links to use the configured URL style. Added redirects from legacy ?v= and ?q= URLs to pretty routes when rewriting is enabled. Documented deployment and fallback behavior in [README.md](/Users/tyemeclifford/Documents/GH/mediaplayer/README.md).
This commit is contained in:
+13
-1
@@ -12,10 +12,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$per_page = max(1, min(50, (int)($_POST['catalogue_per_page'] ?? 10)));
|
||||
$site_title = trim($_POST['site_title'] ?? 'Ty Clifford');
|
||||
$site_sub = trim($_POST['site_sub'] ?? 'tyclifford.com / media');
|
||||
$url_mode = $_POST['url_rewrite_mode'] ?? 'pretty';
|
||||
if (!in_array($url_mode, ['pretty', 'query'], true)) $url_mode = 'pretty';
|
||||
|
||||
set_setting('catalogue_per_page', (string)$per_page);
|
||||
set_setting('site_title', $site_title);
|
||||
set_setting('site_sub', $site_sub);
|
||||
set_setting('url_rewrite_mode', $url_mode);
|
||||
$msg = 'Settings saved.';
|
||||
}
|
||||
|
||||
@@ -40,6 +43,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$per_page = setting('catalogue_per_page', '10');
|
||||
$site_title = setting('site_title', 'Ty Clifford');
|
||||
$site_sub = setting('site_sub', 'tyclifford.com / media');
|
||||
$url_rewrite_mode = url_rewrite_mode();
|
||||
|
||||
// DB stats
|
||||
$db = get_db();
|
||||
@@ -83,7 +87,7 @@ render_head('Settings — Admin', '
|
||||
</div>
|
||||
</div>
|
||||
<nav class="topbar-social">
|
||||
<a class="social-pill" href="../index.php" target="_blank">
|
||||
<a class="social-pill" href="<?= h(public_absolute_url(public_home_url())) ?>" target="_blank">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15,3 21,3 21,9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>
|
||||
View Site
|
||||
</a>
|
||||
@@ -164,6 +168,14 @@ render_head('Settings — Admin', '
|
||||
name="catalogue_per_page" value="<?= h($per_page) ?>" min="1" max="50">
|
||||
<span class="hint">How many thumbnails to show per page (1–50).</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="url_rewrite_mode">Public URL Style</label>
|
||||
<select class="form-select" id="url_rewrite_mode" name="url_rewrite_mode">
|
||||
<option value="pretty" <?= $url_rewrite_mode === 'pretty' ? 'selected' : '' ?>>Pretty rewrite URLs (/v/sample)</option>
|
||||
<option value="query" <?= $url_rewrite_mode === 'query' ? 'selected' : '' ?>>PHP query URLs (index.php?v=sample)</option>
|
||||
</select>
|
||||
<span class="hint">Default routes are /v/<slug>, /all, and /search/<query>. Pretty URLs require Apache mod_rewrite and the included .htaccess.</span>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-primary btn-sm" type="submit">
|
||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M19 21H5a2 2 0 01-2-2V5a2 2 0 012-2h11l5 5v11a2 2 0 01-2 2z"/><polyline points="17,21 17,13 7,13 7,21"/><polyline points="7,3 7,8 15,8"/></svg>
|
||||
|
||||
Reference in New Issue
Block a user