refactor: extract templates from public/

- Created /templates for main site (header.php, footer.php)
- Created /templates/admin for admin section (head.php, footer.php)
- Removed /public/includes and /public/admin/inc
- Updated all references in code and docs
- Tests passing 

Cleaner separation: /public only contains web-accessible files (PHP entry points + assets)
This commit is contained in:
Théophile Gervreau-Mercier
2026-02-12 12:15:41 +01:00
parent 7fca85d1c1
commit 87971f9c23
15 changed files with 21 additions and 21 deletions

View File

@@ -25,7 +25,7 @@ if (php_sapi_name() === 'cli-server') {
// Simple helper function for including templates // Simple helper function for including templates
function include_template($name) { function include_template($name) {
$path = APP_ROOT . '/public/includes/' . $name; $path = APP_ROOT . '/templates/' . $name;
if (file_exists($path)) { if (file_exists($path)) {
include $path; include $path;
} }

View File

@@ -254,7 +254,7 @@ ini_set('error_log', '/var/log/posterg/error.log');
### 10. External CDN Stylesheet Without Subresource Integrity (SRI) ### 10. External CDN Stylesheet Without Subresource Integrity (SRI)
**File:** `public/admin/inc/head.php` **File:** `templates/admin/head.php`
```html ```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">

View File

@@ -57,7 +57,7 @@ function wasSelected($key, $value)
return $formData[$key] == $value; return $formData[$key] == $value;
} }
?> ?>
<?php require_once __DIR__ . "/inc/head.php"; ?> <?php require_once APP_ROOT . '/templates/admin/head.php'; ?>
<main> <main>
<?php if ($error): ?> <?php if ($error): ?>
<div class="error-message"> <div class="error-message">
@@ -260,4 +260,4 @@ function wasSelected($key, $value)
</form> </form>
</main> </main>
<?php require_once __DIR__ . "/inc/footer.php"; ?> <?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>

View File

@@ -173,7 +173,7 @@ try {
die("Erreur lors du chargement: " . $e->getMessage()); die("Erreur lors du chargement: " . $e->getMessage());
} }
?> ?>
<?php require_once __DIR__ . '/inc/head.php'; ?> <?php require_once APP_ROOT . '/templates/admin/head.php'; ?>
<main> <main>
<?php if ($error): ?> <?php if ($error): ?>
@@ -318,4 +318,4 @@ try {
</form> </form>
</main> </main>
<?php require_once __DIR__ . '/inc/footer.php'; ?> <?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>

View File

@@ -277,7 +277,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32)); $_SESSION['csrf_token'] = bin2hex(random_bytes(32));
} }
?> ?>
<?php require_once __DIR__ . '/inc/head.php'; ?> <?php require_once APP_ROOT . '/templates/admin/head.php'; ?>
<main> <main>
<h2>Importer des TFE depuis un fichier CSV</h2> <h2>Importer des TFE depuis un fichier CSV</h2>
@@ -347,4 +347,4 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
<p>Voir: <code>../db/Database_TFE_test.csv</code></p> <p>Voir: <code>../db/Database_TFE_test.csv</code></p>
</main> </main>
<?php require_once __DIR__ . "/inc/footer.php"; ?> <?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>

View File

@@ -77,7 +77,7 @@ try {
} }
?> ?>
<?php require_once __DIR__ . "/inc/head.php"; ?> <?php require_once APP_ROOT . '/templates/admin/head.php'; ?>
<script> <script>
function toggleAll(source) { function toggleAll(source) {
const checkboxes = document.querySelectorAll('input[name="selected_theses[]"]'); const checkboxes = document.querySelectorAll('input[name="selected_theses[]"]');
@@ -285,4 +285,4 @@ try {
<?php endif; ?> <?php endif; ?>
</main> </main>
<?php require_once __DIR__ . "/inc/footer.php"; ?> <?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>

View File

@@ -71,7 +71,7 @@ function formatFileSize($bytes) {
// Set page title for header // Set page title for header
$pageTitle = "Merci"; $pageTitle = "Merci";
?> ?>
<?php require_once __DIR__ . '/inc/head.php'; ?> <?php require_once APP_ROOT . '/templates/admin/head.php'; ?>
<main> <main>
<?php if ($error): ?> <?php if ($error): ?>
@@ -198,4 +198,4 @@ $pageTitle = "Merci";
<?php endif; ?> <?php endif; ?>
</main> </main>
<?php require_once __DIR__ . '/inc/footer.php'; ?> <?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>

View File

@@ -19,7 +19,7 @@ try {
$totalPages = 0; $totalPages = 0;
} }
include APP_ROOT . '/public/includes/header.php'; include APP_ROOT . '/templates/header.php';
?> ?>
<main> <main>
@@ -54,4 +54,4 @@ include APP_ROOT . '/public/includes/header.php';
</nav> </nav>
<?php endif; ?> <?php endif; ?>
<?php include APP_ROOT . '/public/includes/footer.php'; ?> <?php include APP_ROOT . '/templates/footer.php'; ?>

View File

@@ -29,7 +29,7 @@ if (isset($_GET['id'])) {
} }
// Include the header template // Include the header template
include APP_ROOT . '/public/includes/header.php'; ?> include APP_ROOT . '/templates/header.php'; ?>
<main> <main>
<div class="item"> <div class="item">
<div class="card-content"> <div class="card-content">
@@ -151,4 +151,4 @@ include APP_ROOT . '/public/includes/header.php'; ?>
</main> </main>
<!-- Include the footer template --> <!-- Include the footer template -->
<?php include APP_ROOT . '/public/includes/footer.php'; ?> <?php include APP_ROOT . '/templates/footer.php'; ?>

View File

@@ -16,7 +16,7 @@ if (!$rateLimit->check()) {
$rateLimit->sendHeaders(); $rateLimit->sendHeaders();
// Display error page // Display error page
include APP_ROOT . '/public/includes/header.php'; include APP_ROOT . '/templates/header.php';
echo '<section class="section">'; echo '<section class="section">';
echo ' <div class="container">'; echo ' <div class="container">';
echo ' <div class="notification is-danger">'; echo ' <div class="notification is-danger">';
@@ -26,7 +26,7 @@ if (!$rateLimit->check()) {
echo ' </div>'; echo ' </div>';
echo ' </div>'; echo ' </div>';
echo '</section>'; echo '</section>';
include APP_ROOT . '/public/includes/footer.php'; include APP_ROOT . '/templates/footer.php';
exit; exit;
} }
@@ -122,7 +122,7 @@ try {
$languages = []; $languages = [];
} }
include APP_ROOT . '/public/includes/header.php'; ?> include APP_ROOT . '/templates/header.php'; ?>
<section class="section"> <section class="section">
<div class="container"> <div class="container">
@@ -415,4 +415,4 @@ include APP_ROOT . '/public/includes/header.php'; ?>
</div> </div>
</section> </section>
<?php include APP_ROOT . '/public/includes/footer.php'; ?> <?php include APP_ROOT . '/templates/footer.php'; ?>

View File

@@ -1 +1 @@
[1770894771] [1770894924]