mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-07 03:29:19 +02:00
Extract shared public <head> partial
Create templates/public/head.php accepting $pageTitle and $extraCss (array of stylesheet hrefs), mirroring the existing templates/admin/head.php pattern. The partial emits: DOCTYPE, <html lang=fr>, charset/viewport meta, favicon, modern-normalize, common.css, any extra CSS links, and the dev-only live-reload script. The live-reload snippet was previously copy-pasted verbatim into all five public pages. Updated pages: - public/index.php ($pageTitle='Posterg', $extraCss=['assets/main.css']) - public/search.php ($pageTitle='Répertoire – Posterg', search.css) - public/tfe.php ($pageTitle=thesis title + suffix, tfe.css) - public/apropos.php ($pageTitle='À Propos – Posterg', apropos.css) - public/licence.php ($pageTitle=DB title + suffix, apropos.css) tfe.php: removed redundant htmlspecialchars() call on $pageTitle (the partial applies it); licence.php: renamed conflicting $page variable to $dbPage to avoid collision with the shared $pageTitle expected by the partial. All syntax checks and test suite pass (4/4).
This commit is contained in:
14
TODO.md
14
TODO.md
@@ -452,16 +452,12 @@ Goal: rename the tables and column to the canonical M2M pattern (`tags`, `thesis
|
|||||||
|
|
||||||
### D — Template structure / boilerplate duplication
|
### D — Template structure / boilerplate duplication
|
||||||
|
|
||||||
- [ ] **Every public page duplicates its own `<head>`** — `index.php`, `search.php`, `tfe.php`,
|
- [x] **Every public page duplicates its own `<head>`** — extracted to `templates/public/head.php`
|
||||||
`apropos.php`, `licence.php` each contain an identical block: `<!DOCTYPE html>`,
|
accepting `$pageTitle` and `$extraCss`; all 5 public pages updated to use the partial.
|
||||||
`<html lang="fr">`, `<meta charset>`, `<meta viewport>`, `<link rel="icon">`,
|
Mirrors the pattern `templates/admin/head.php` already uses.
|
||||||
`<link modern-normalize>`, `<link common.css>`, live-reload script. Only `<title>` and one
|
|
||||||
extra CSS `<link>` differ. Extract a `templates/public/head.php` partial accepting
|
|
||||||
`$pageTitle` and `$extraCss` — mirrors the pattern `templates/admin/head.php` already uses.
|
|
||||||
|
|
||||||
- [ ] **Live-reload snippet copy-pasted into 6 files** — `index.php`, `search.php`, `tfe.php`,
|
- [x] **Live-reload snippet copy-pasted into 6 files** — consolidated into `templates/public/head.php`;
|
||||||
`apropos.php`, `licence.php`, `templates/admin/head.php` all contain the same 6-line
|
removed from `index.php`, `search.php`, `tfe.php`, `apropos.php`, `licence.php`.
|
||||||
`(function poll(){…})()` block. Consolidate into the shared head partials.
|
|
||||||
|
|
||||||
- [x] **`templates/header.php` and `templates/head.php` are dead files** — neither is `include`d
|
- [x] **`templates/header.php` and `templates/head.php` are dead files** — neither is `include`d
|
||||||
anywhere in the codebase. Both contain outdated markup from a previous design iteration
|
anywhere in the codebase. Both contain outdated markup from a previous design iteration
|
||||||
|
|||||||
@@ -24,27 +24,10 @@ try {
|
|||||||
$pd = new Parsedown();
|
$pd = new Parsedown();
|
||||||
$pd->setSafeMode(true);
|
$pd->setSafeMode(true);
|
||||||
$aboutHtml = $pd->text($rawContent);
|
$aboutHtml = $pd->text($rawContent);
|
||||||
|
$pageTitle = 'À Propos – Posterg';
|
||||||
|
$extraCss = ['assets/apropos.css'];
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<?php include APP_ROOT . '/templates/public/head.php'; ?>
|
||||||
<html lang="fr">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>À Propos – Posterg</title>
|
|
||||||
<link rel="icon" type="image/svg+xml" href="/assets/admin_favicon.svg">
|
|
||||||
<link rel="stylesheet" href="assets/modern-normalize.min.css">
|
|
||||||
<link rel="stylesheet" href="assets/common.css">
|
|
||||||
<link rel="stylesheet" href="assets/apropos.css">
|
|
||||||
<?php if (php_sapi_name() === 'cli-server'): ?>
|
|
||||||
<script>
|
|
||||||
(function poll(){
|
|
||||||
fetch('/live-reload.php').then(r=>r.json()).then(d=>{
|
|
||||||
if(d.changed) location.reload(); else setTimeout(poll,1000);
|
|
||||||
}).catch(()=>setTimeout(poll,2000));
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
<?php endif; ?>
|
|
||||||
</head>
|
|
||||||
<body class="apropos-body">
|
<body class="apropos-body">
|
||||||
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
|
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
|
||||||
|
|
||||||
|
|||||||
@@ -50,27 +50,10 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$currentNav = '';
|
$currentNav = '';
|
||||||
|
$pageTitle = 'Posterg';
|
||||||
|
$extraCss = ['assets/main.css'];
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<?php include APP_ROOT . '/templates/public/head.php'; ?>
|
||||||
<html lang="fr">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>Posterg</title>
|
|
||||||
<link rel="icon" type="image/svg+xml" href="/assets/admin_favicon.svg">
|
|
||||||
<link rel="stylesheet" href="assets/modern-normalize.min.css">
|
|
||||||
<link rel="stylesheet" href="assets/common.css">
|
|
||||||
<link rel="stylesheet" href="assets/main.css">
|
|
||||||
<?php if (php_sapi_name() === 'cli-server'): ?>
|
|
||||||
<script>
|
|
||||||
(function poll() {
|
|
||||||
fetch('/live-reload.php').then(r=>r.json()).then(d=>{
|
|
||||||
if(d.changed) location.reload(); else setTimeout(poll,1000);
|
|
||||||
}).catch(()=>setTimeout(poll,2000));
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
<?php endif; ?>
|
|
||||||
</head>
|
|
||||||
<body class="home-body">
|
<body class="home-body">
|
||||||
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
|
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
|
||||||
|
|
||||||
|
|||||||
@@ -7,39 +7,23 @@ $currentNav = 'licence';
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$db = Database::getInstance();
|
$db = Database::getInstance();
|
||||||
$page = $db->getPage('licenses');
|
$dbPage = $db->getPage('licenses');
|
||||||
$content = $page ? $page['content'] : '';
|
$content = $dbPage ? $dbPage['content'] : '';
|
||||||
$pageTitle = $page ? $page['title'] : 'Licences';
|
$licencePageTitle = $dbPage ? $dbPage['title'] : 'Licences';
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
error_log("Error loading licence page: " . $e->getMessage());
|
error_log("Error loading licence page: " . $e->getMessage());
|
||||||
$content = '';
|
$content = '';
|
||||||
$pageTitle = 'Licences';
|
$licencePageTitle = 'Licences';
|
||||||
}
|
}
|
||||||
|
|
||||||
$pd = new Parsedown();
|
$pd = new Parsedown();
|
||||||
$pd->setSafeMode(true);
|
$pd->setSafeMode(true);
|
||||||
$html = $pd->text($content);
|
$html = $pd->text($content);
|
||||||
|
|
||||||
|
$pageTitle = $licencePageTitle . ' – Posterg';
|
||||||
|
$extraCss = ['assets/apropos.css'];
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<?php include APP_ROOT . '/templates/public/head.php'; ?>
|
||||||
<html lang="fr">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title><?= htmlspecialchars($pageTitle) ?> – Posterg</title>
|
|
||||||
<link rel="icon" type="image/svg+xml" href="/assets/admin_favicon.svg">
|
|
||||||
<link rel="stylesheet" href="assets/modern-normalize.min.css">
|
|
||||||
<link rel="stylesheet" href="assets/common.css">
|
|
||||||
<link rel="stylesheet" href="assets/apropos.css">
|
|
||||||
<?php if (php_sapi_name() === 'cli-server'): ?>
|
|
||||||
<script>
|
|
||||||
(function poll(){
|
|
||||||
fetch('/live-reload.php').then(r=>r.json()).then(d=>{
|
|
||||||
if(d.changed) location.reload(); else setTimeout(poll,1000);
|
|
||||||
}).catch(()=>setTimeout(poll,2000));
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
<?php endif; ?>
|
|
||||||
</head>
|
|
||||||
<body class="apropos-body">
|
<body class="apropos-body">
|
||||||
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
|
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
|
||||||
|
|
||||||
|
|||||||
@@ -61,27 +61,10 @@ try {
|
|||||||
|
|
||||||
$currentNav = 'repertoire';
|
$currentNav = 'repertoire';
|
||||||
$searchBarValue = $_GET['query'] ?? '';
|
$searchBarValue = $_GET['query'] ?? '';
|
||||||
|
$pageTitle = 'Répertoire – Posterg';
|
||||||
|
$extraCss = ['assets/search.css'];
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<?php include APP_ROOT . '/templates/public/head.php'; ?>
|
||||||
<html lang="fr">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title>Répertoire – Posterg</title>
|
|
||||||
<link rel="icon" type="image/svg+xml" href="/assets/admin_favicon.svg">
|
|
||||||
<link rel="stylesheet" href="assets/modern-normalize.min.css">
|
|
||||||
<link rel="stylesheet" href="assets/common.css">
|
|
||||||
<link rel="stylesheet" href="assets/search.css">
|
|
||||||
<?php if (php_sapi_name() === 'cli-server'): ?>
|
|
||||||
<script>
|
|
||||||
(function poll() {
|
|
||||||
fetch('/live-reload.php').then(r=>r.json()).then(d=>{
|
|
||||||
if(d.changed) location.reload(); else setTimeout(poll,1000);
|
|
||||||
}).catch(()=>setTimeout(poll,2000));
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
<?php endif; ?>
|
|
||||||
</head>
|
|
||||||
<body class="search-body">
|
<body class="search-body">
|
||||||
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
|
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
|
||||||
|
|
||||||
|
|||||||
@@ -17,27 +17,10 @@ if (isset($_GET['id'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$currentNav = '';
|
$currentNav = '';
|
||||||
|
$pageTitle = $data['title'] . ' – Posterg';
|
||||||
|
$extraCss = ['assets/tfe.css'];
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<?php include APP_ROOT . '/templates/public/head.php'; ?>
|
||||||
<html lang="fr">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<title><?= htmlspecialchars($data['title']) ?> – Posterg</title>
|
|
||||||
<link rel="icon" type="image/svg+xml" href="/assets/admin_favicon.svg">
|
|
||||||
<link rel="stylesheet" href="assets/modern-normalize.min.css">
|
|
||||||
<link rel="stylesheet" href="assets/common.css">
|
|
||||||
<link rel="stylesheet" href="assets/tfe.css">
|
|
||||||
<?php if (php_sapi_name() === 'cli-server'): ?>
|
|
||||||
<script>
|
|
||||||
(function poll(){
|
|
||||||
fetch('/live-reload.php').then(r=>r.json()).then(d=>{
|
|
||||||
if(d.changed) location.reload(); else setTimeout(poll,1000);
|
|
||||||
}).catch(()=>setTimeout(poll,2000));
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
<?php endif; ?>
|
|
||||||
</head>
|
|
||||||
<body class="tfe-body">
|
<body class="tfe-body">
|
||||||
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
|
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
[1774702347]
|
[1774712930]
|
||||||
BIN
storage/test.db
BIN
storage/test.db
Binary file not shown.
22
templates/public/head.php
Normal file
22
templates/public/head.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title><?= htmlspecialchars($pageTitle ?? 'Posterg') ?></title>
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/assets/admin_favicon.svg">
|
||||||
|
<link rel="stylesheet" href="assets/modern-normalize.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/common.css">
|
||||||
|
<?php foreach ($extraCss ?? [] as $css): ?>
|
||||||
|
<link rel="stylesheet" href="<?= htmlspecialchars($css) ?>">
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php if (php_sapi_name() === 'cli-server'): ?>
|
||||||
|
<script>
|
||||||
|
(function poll(){
|
||||||
|
fetch('/live-reload.php').then(r=>r.json()).then(d=>{
|
||||||
|
if(d.changed) location.reload(); else setTimeout(poll,1000);
|
||||||
|
}).catch(()=>setTimeout(poll,2000));
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<?php endif; ?>
|
||||||
|
</head>
|
||||||
Reference in New Issue
Block a user