Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 331e9c9ecd | |||
| 0280ef3ca1 | |||
| eddde2165a | |||
| 07d004b3f0 | |||
| 5cb0e854fd | |||
| 5452fb4927 | |||
| de8785d088 | |||
| 4b5943c0a4 | |||
| a552f105cd | |||
| 16afec3039 |
@@ -6,6 +6,7 @@
|
|||||||
APP_URL=https://example.com
|
APP_URL=https://example.com
|
||||||
APP_ENV=prod
|
APP_ENV=prod
|
||||||
APP_DEBUG=0
|
APP_DEBUG=0
|
||||||
|
APP_TIMEZONE=Europe/Paris
|
||||||
|
|
||||||
# Authentification admin (email de l'administrateur principal)
|
# Authentification admin (email de l'administrateur principal)
|
||||||
ADMIN_EMAIL=
|
ADMIN_EMAIL=
|
||||||
@@ -40,6 +41,12 @@ SMTP_FROM_NAME=
|
|||||||
CONTACT_EMAIL=
|
CONTACT_EMAIL=
|
||||||
CONTACT_FROM_EMAIL=
|
CONTACT_FROM_EMAIL=
|
||||||
|
|
||||||
|
# Dépôt Folio pour le vérificateur de mises à jour (UpdateChecker)
|
||||||
|
# URL de base du dépôt Gitea (sans slash final)
|
||||||
|
FOLIO_REPO_URL=https://git.abonnel.fr/cedricAbonnel/folio
|
||||||
|
# Branche suivie pour les mises à jour (défaut : main)
|
||||||
|
# FOLIO_UPDATE_BRANCH=main
|
||||||
|
|
||||||
# Chemin absolu vers le répertoire des articles (data/)
|
# Chemin absolu vers le répertoire des articles (data/)
|
||||||
# Par défaut : BASE_PATH/data (dans le répertoire de l'application)
|
# Par défaut : BASE_PATH/data (dans le répertoire de l'application)
|
||||||
# Recommandé en production : chemin hors du répertoire web, ex. /srv/data/folio
|
# Recommandé en production : chemin hors du répertoire web, ex. /srv/data/folio
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ if (!defined('BASE_PATH')) {
|
|||||||
define('BASE_PATH', __DIR__);
|
define('BASE_PATH', __DIR__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$__tz = $_ENV['APP_TIMEZONE'] ?? getenv('APP_TIMEZONE') ?: 'Europe/Paris';
|
||||||
|
date_default_timezone_set($__tz);
|
||||||
|
unset($__tz);
|
||||||
|
|
||||||
if (!defined('DATA_PATH')) {
|
if (!defined('DATA_PATH')) {
|
||||||
$__dataPath = $_ENV['DATA_PATH'] ?? getenv('DATA_PATH') ?: '';
|
$__dataPath = $_ENV['DATA_PATH'] ?? getenv('DATA_PATH') ?: '';
|
||||||
define('DATA_PATH', $__dataPath !== '' ? rtrim($__dataPath, '/') : BASE_PATH . '/data');
|
define('DATA_PATH', $__dataPath !== '' ? rtrim($__dataPath, '/') : BASE_PATH . '/data');
|
||||||
|
|||||||
+15
-1
@@ -45,7 +45,7 @@ $action = $_GET['action'] ?? 'list';
|
|||||||
$uuid = $_GET['uuid'] ?? '';
|
$uuid = $_GET['uuid'] ?? '';
|
||||||
$slug = $_GET['slug'] ?? '';
|
$slug = $_GET['slug'] ?? '';
|
||||||
|
|
||||||
$_noindexActions = ['create', 'edit', 'admin', 'categories', 'diff', 'add_files', 'import_image', 'import_image_step2', 'sources', 'profile', 'delete_file', 'delete_external_link', 'rename_category', 'delete_category', 'toggle_private_category', 'admin_save_site', 'not_found', 'add_feed', 'delete_feed', 'add_link', 'delete_link', 'reorder_links', 'react', 'comment', 'verify_comment', 'comment_moderate', 'comment_delete', 'comment_resend', 'create_tag_type', 'delete_tag_type', 'edit_tags', 'book_save', 'book_delete', 'admin_save_as_groups', 'run_engine_update'];
|
$_noindexActions = ['create', 'edit', 'admin', 'categories', 'diff', 'add_files', 'import_image', 'import_image_step2', 'sources', 'profile', 'delete_file', 'delete_external_link', 'rename_category', 'delete_category', 'toggle_private_category', 'admin_save_site', 'not_found', 'add_feed', 'delete_feed', 'add_link', 'delete_link', 'reorder_links', 'react', 'comment', 'verify_comment', 'comment_moderate', 'comment_delete', 'comment_resend', 'create_tag_type', 'delete_tag_type', 'edit_tags', 'book_save', 'book_delete', 'admin_save_as_groups', 'admin_save_folio_config', 'run_engine_update'];
|
||||||
$metaRobots = in_array($action, $_noindexActions, true) ? 'noindex, nofollow' : null;
|
$metaRobots = in_array($action, $_noindexActions, true) ? 'noindex, nofollow' : null;
|
||||||
unset($_noindexActions);
|
unset($_noindexActions);
|
||||||
|
|
||||||
@@ -2903,6 +2903,20 @@ switch ($action) {
|
|||||||
header('Location: /admin?tab=dashboard');
|
header('Location: /admin?tab=dashboard');
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
case 'admin_save_folio_config':
|
||||||
|
requireAuth();
|
||||||
|
if (!isAdmin() || $_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
|
http_response_code(403);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$ok = saveSiteSettings([
|
||||||
|
'folio_repo_url' => $_POST['folio_repo_url'] ?? '',
|
||||||
|
'folio_update_branch' => $_POST['folio_update_branch'] ?? '',
|
||||||
|
]);
|
||||||
|
$_updateChecker->clearCache();
|
||||||
|
header('Location: /admin/site?notice=' . ($ok ? 'folio_saved' : 'folio_error'));
|
||||||
|
exit;
|
||||||
|
|
||||||
case 'admin_save_site':
|
case 'admin_save_site':
|
||||||
requireAuth();
|
requireAuth();
|
||||||
if (!isAdmin() || $_SERVER['REQUEST_METHOD'] !== 'POST') {
|
if (!isAdmin() || $_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
|
|||||||
+19
-1
@@ -68,6 +68,24 @@ function apacheAccessLog(): string
|
|||||||
return (string)($_ENV['APACHE_ACCESS_LOG'] ?? getenv('APACHE_ACCESS_LOG') ?: '*-access.log');
|
return (string)($_ENV['APACHE_ACCESS_LOG'] ?? getenv('APACHE_ACCESS_LOG') ?: '*-access.log');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function folioRepoUrl(): string
|
||||||
|
{
|
||||||
|
$fromSettings = siteSettings()['folio_repo_url'] ?? '';
|
||||||
|
if ($fromSettings !== '') {
|
||||||
|
return rtrim($fromSettings, '/');
|
||||||
|
}
|
||||||
|
return rtrim((string)($_ENV['FOLIO_REPO_URL'] ?? getenv('FOLIO_REPO_URL') ?: ''), '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
function folioUpdateBranch(): string
|
||||||
|
{
|
||||||
|
$fromSettings = siteSettings()['folio_update_branch'] ?? '';
|
||||||
|
if ($fromSettings !== '') {
|
||||||
|
return $fromSettings;
|
||||||
|
}
|
||||||
|
return (string)($_ENV['FOLIO_UPDATE_BRANCH'] ?? getenv('FOLIO_UPDATE_BRANCH') ?: 'main');
|
||||||
|
}
|
||||||
|
|
||||||
/** @return list<array{label:string,patterns:list<string>}> */
|
/** @return list<array{label:string,patterns:list<string>}> */
|
||||||
function asGroups(): array
|
function asGroups(): array
|
||||||
{
|
{
|
||||||
@@ -78,7 +96,7 @@ function asGroups(): array
|
|||||||
function saveSiteSettings(array $data): bool
|
function saveSiteSettings(array $data): bool
|
||||||
{
|
{
|
||||||
$current = siteSettings();
|
$current = siteSettings();
|
||||||
$stringKeys = ['site_title', 'site_claim', 'site_lang', 'site_license_label', 'site_license_url', 'apache_access_log'];
|
$stringKeys = ['site_title', 'site_claim', 'site_lang', 'site_license_label', 'site_license_url', 'apache_access_log', 'folio_repo_url', 'folio_update_branch'];
|
||||||
foreach ($stringKeys as $key) {
|
foreach ($stringKeys as $key) {
|
||||||
if (array_key_exists($key, $data)) {
|
if (array_key_exists($key, $data)) {
|
||||||
$val = trim((string)$data[$key]);
|
$val = trim((string)$data[$key]);
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class UpdateChecker
|
|||||||
*/
|
*/
|
||||||
private function checkRemoteVersion(): ?string
|
private function checkRemoteVersion(): ?string
|
||||||
{
|
{
|
||||||
$repoUrl = rtrim((string) ($_ENV['FOLIO_REPO_URL'] ?? getenv('FOLIO_REPO_URL') ?: ''), '/');
|
$repoUrl = folioRepoUrl();
|
||||||
if ($repoUrl === '') {
|
if ($repoUrl === '') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ class UpdateChecker
|
|||||||
|
|
||||||
public function getBranch(): string
|
public function getBranch(): string
|
||||||
{
|
{
|
||||||
return (string) ($_ENV['FOLIO_UPDATE_BRANCH'] ?? getenv('FOLIO_UPDATE_BRANCH') ?: 'main');
|
return folioUpdateBranch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastChecked(): ?int
|
public function getLastChecked(): ?int
|
||||||
|
|||||||
+31
-1
@@ -106,6 +106,7 @@ function adminStatusBadge(array $a, int $now): string
|
|||||||
$_notices = isset($_updateChecker) ? $_updateChecker->adminNotices() : [];
|
$_notices = isset($_updateChecker) ? $_updateChecker->adminNotices() : [];
|
||||||
$_branch = isset($_updateChecker) ? $_updateChecker->getBranch() : 'main';
|
$_branch = isset($_updateChecker) ? $_updateChecker->getBranch() : 'main';
|
||||||
$_lastChecked = isset($_updateChecker) ? $_updateChecker->getLastChecked() : null;
|
$_lastChecked = isset($_updateChecker) ? $_updateChecker->getLastChecked() : null;
|
||||||
|
$_repoConfigured = folioRepoUrl() !== '';
|
||||||
$_remoteLabel = '—';
|
$_remoteLabel = '—';
|
||||||
foreach ($_notices as $_n) {
|
foreach ($_notices as $_n) {
|
||||||
if ($_n['type'] === 'info' && preg_match('/v([\d]+\.[\d]+\.[\d]+)/', $_n['message'], $_m)) {
|
if ($_n['type'] === 'info' && preg_match('/v([\d]+\.[\d]+\.[\d]+)/', $_n['message'], $_m)) {
|
||||||
@@ -130,10 +131,12 @@ function adminStatusBadge(array $a, int $now): string
|
|||||||
<form method="POST" action="/?action=run_engine_update" class="d-inline">
|
<form method="POST" action="/?action=run_engine_update" class="d-inline">
|
||||||
<button type="submit" class="btn btn-primary btn-sm">Mettre à jour vers v<?= htmlspecialchars($_remoteLabel) ?></button>
|
<button type="submit" class="btn btn-primary btn-sm">Mettre à jour vers v<?= htmlspecialchars($_remoteLabel) ?></button>
|
||||||
</form>
|
</form>
|
||||||
<?php else: ?>
|
<?php elseif ($_repoConfigured): ?>
|
||||||
<form method="POST" action="/?action=force_update_check" class="d-inline">
|
<form method="POST" action="/?action=force_update_check" class="d-inline">
|
||||||
<button type="submit" class="btn btn-outline-secondary btn-sm py-0">Vérifier</button>
|
<button type="submit" class="btn btn-outline-secondary btn-sm py-0">Vérifier</button>
|
||||||
</form>
|
</form>
|
||||||
|
<?php else: ?>
|
||||||
|
<span class="text-muted small">(<code>FOLIO_REPO_URL</code> non configuré)</span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -544,6 +547,33 @@ function adminStatusBadge(array $a, int $now): string
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php if (($_GET['notice'] ?? '') === 'folio_saved'): ?>
|
||||||
|
<div class="alert alert-success py-2 mt-3 small">Configuration Folio enregistrée.</div>
|
||||||
|
<?php elseif (($_GET['notice'] ?? '') === 'folio_error'): ?>
|
||||||
|
<div class="alert alert-danger py-2 mt-3 small">Impossible d'enregistrer.</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<div class="card mt-4" style="max-width:540px">
|
||||||
|
<div class="card-header bg-transparent py-2 small fw-semibold">Mises à jour du moteur</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<form method="POST" action="/?action=admin_save_folio_config">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label small fw-semibold mb-1">URL du dépôt Folio</label>
|
||||||
|
<input type="url" name="folio_repo_url" class="form-control form-control-sm font-monospace"
|
||||||
|
placeholder="https://git.abonnel.fr/cedricAbonnel/folio"
|
||||||
|
value="<?= htmlspecialchars(folioRepoUrl()) ?>">
|
||||||
|
<div class="form-text">Sans slash final. Laissez vide pour utiliser <code>FOLIO_REPO_URL</code> du .env.</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label small fw-semibold mb-1">Branche suivie</label>
|
||||||
|
<input type="text" name="folio_update_branch" class="form-control form-control-sm font-monospace"
|
||||||
|
placeholder="main"
|
||||||
|
value="<?= htmlspecialchars(folioUpdateBranch()) ?>">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary btn-sm">Enregistrer</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<!-- ─────────────────────────── CATÉGORIES & TAGS ─────────────────── -->
|
<!-- ─────────────────────────── CATÉGORIES & TAGS ─────────────────── -->
|
||||||
|
|||||||
Reference in New Issue
Block a user