feat: clean URLs + fix addFileMeta silent failure

This commit is contained in:
Cedric Abonnel
2026-05-12 10:04:58 +02:00
parent 045e93cffd
commit 70fd55be6f
20 changed files with 314 additions and 206 deletions
+18 -6
View File
@@ -32,7 +32,7 @@ if ($files) {
$externalLinks = $article['external_links'] ?? [];
$hasLeftSidebar = !empty($categorySidebar ?? []);
?>
<div class="row g-4 align-items-start flex-nowrap-lg">
<div class="row g-4 align-items-start flex-lg-nowrap">
<?php if ($hasLeftSidebar): ?>
<div class="post-sidebar-col order-2 order-lg-1">
@@ -87,8 +87,8 @@ $hasSources = (!empty($externalLinks) || !empty($files))
<div class="article-hero-top">
<a href="/" class="hero-btn">← Retour</a>
<?php if (function_exists('isAdmin') && isAdmin()): ?>
<a href="/?action=edit&uuid=<?= rawurlencode($article['uuid']) ?>" class="hero-btn ms-auto">✎ Modifier</a>
<a href="/?action=delete&uuid=<?= rawurlencode($article['uuid']) ?>"
<a href="/edit/<?= rawurlencode($article['uuid']) ?>" class="hero-btn ms-auto">✎ Modifier</a>
<a href="/delete/<?= rawurlencode($article['uuid']) ?>"
class="hero-btn hero-btn--danger"
data-confirm="Supprimer cet article définitivement ?">🗑 Supprimer</a>
<?php endif; ?>
@@ -111,7 +111,7 @@ $hasSources = (!empty($externalLinks) || !empty($files))
</div>
<div class="article-hero-right">
<?php if ($hasSources): ?>
<a href="/?action=sources&uuid=<?= rawurlencode($article['uuid']) ?>" class="hero-btn"> Sources</a>
<a href="/sources/<?= rawurlencode($article['uuid']) ?>" class="hero-btn"> Sources</a>
<?php endif; ?>
<?php if (function_exists('isLoggedIn') && isLoggedIn()): ?>
<form method="post" action="/?action=rate" class="d-flex align-items-center gap-2">
@@ -162,10 +162,14 @@ $hasSources = (!empty($externalLinks) || !empty($files))
<aside class="related-sidebar">
<?php if (!empty($attachments)): ?>
<?php $filesMeta = $article['files_meta'] ?? []; ?>
<h6 class="related-sidebar-title">Pièces jointes</h6>
<div class="d-flex flex-column gap-2 mb-4">
<?php foreach ($attachments as $file):
$fileUrl = '/file?uuid=' . rawurlencode($article['uuid']) . '&name=' . rawurlencode($file['name']);
$fileUrl = '/file?uuid=' . rawurlencode($article['uuid']) . '&name=' . rawurlencode($file['name']);
$fmeta = $filesMeta[$file['name']] ?? [];
$fAuthor = trim($fmeta['author'] ?? '');
$fSource = trim($fmeta['source_url'] ?? '');
?>
<a href="<?= htmlspecialchars($fileUrl) ?>" target="_blank" rel="noopener" class="source-card">
<?php if ($file['is_image']): ?>
@@ -179,7 +183,15 @@ $hasSources = (!empty($externalLinks) || !empty($files))
<?php endif; ?>
<div class="source-card-body">
<div class="source-card-title"><?= htmlspecialchars($file['name']) ?></div>
<div class="source-card-meta"><?= htmlspecialchars(number_format($file['size'] / 1024, 1)) ?> Ko</div>
<div class="source-card-meta">
<?= htmlspecialchars(number_format($file['size'] / 1024, 1)) ?> Ko
<?php if ($fAuthor !== ''): ?>
· <?= htmlspecialchars($fAuthor) ?>
<?php endif; ?>
<?php if ($fSource !== ''): ?>
· <?= htmlspecialchars(parse_url($fSource, PHP_URL_HOST) ?: $fSource) ?>
<?php endif; ?>
</div>
</div>
</a>
<?php endforeach; ?>