This commit is contained in:
interlope committed 2026-07-12 15:40:39 +02:00
commit bacda9011c
8 files changed
+300 -13

No files matched your search

+17 -2
View File
@@ -261,5 +261,20 @@
?>
<link rel="stylesheet" type="text/css" href="<?php echo $styleHref; ?>">
<!-- Load Bludit Plugins: Site head -->
<?php Theme::plugins('siteHead'); ?>
<!-- Load Bludit Plugins: Site head.
The theme already emits a complete, coherent set of Open Graph / Twitter
Card / canonical tags above. Bludit's Open Graph & Twitter Cards plugins
emit their own (conflicting) set — e.g. a post image as og:image on the
homepage and multiple og:locale values — so their duplicates are stripped
here. Best fixed at the source by deactivating those plugins in the admin;
this filter just makes the markup correct either way. -->
<?php
ob_start();
Theme::plugins('siteHead');
$bdPluginHead = ob_get_clean();
// <meta property="og:…"> / <meta name="twitter:…"> / <meta property="article:…">
$bdPluginHead = preg_replace('/<meta\b[^>]*\b(?:property|name)=["\'](?:og:|twitter:|article:)[^"\']*["\'][^>]*>\s*/i', '', $bdPluginHead);
// duplicate <link rel="canonical">
$bdPluginHead = preg_replace('/<link\b[^>]*\brel=["\']canonical["\'][^>]*>\s*/i', '', $bdPluginHead);
echo $bdPluginHead;
?>
+37 -4
View File
@@ -52,11 +52,16 @@
<!-- Post list (titles only) -->
<div class="post-list">
<?php foreach ($content as $page) : ?>
<article class="post-list-item">
<?php $bdCover = $page->coverImage(); ?>
<article class="post-list-item<?php echo $bdCover ? ' has-thumb' : ''; ?>">
<!-- Load Bludit Plugins: Page Begin -->
<?php Theme::plugins('pageBegin'); ?>
<div class="post-list-row">
<div class="post-list-main">
<div class="post-list-head">
<a href="<?php echo $page->permalink(); ?>">
<h2 class="post-list-title"><?php echo blowfish_text($page->title()); ?></h2>
@@ -69,8 +74,18 @@
</div>
</div>
<!-- Tags and Category -->
<?php $tagsList = $page->tags(true); $categoryKey = $page->categoryKey(); ?>
<!-- Excerpt (the page description, set in the admin's SEO tab) -->
<?php $bdExcerpt = blowfish_plain($page->description()); ?>
<?php if ($bdExcerpt !== '') : ?>
<p class="post-list-excerpt"><?php echo htmlspecialchars($bdExcerpt, ENT_QUOTES, 'UTF-8'); ?></p>
<?php endif ?>
<!-- Tags and Category — capped so the list stays scannable -->
<?php
$tagsList = $page->tags(true);
$categoryKey = $page->categoryKey();
$bdMaxTags = 5; // tags shown per post on the list; the rest collapse into "+N"
?>
<?php if (!empty($tagsList) || $categoryKey) : ?>
<div class="post-taxonomy">
<?php if ($categoryKey) : ?>
@@ -78,12 +93,30 @@
<?php echo blowfish_icon('folder'); ?><?php echo blowfish_text($page->category()); ?>
</a>
<?php endif ?>
<?php $bdTagCount = 0; $bdTagOverflow = 0; ?>
<?php foreach ($tagsList as $tagKey => $tagName) : ?>
<a class="taxonomy-badge" href="<?php echo DOMAIN_TAGS . $tagKey; ?>"><?php echo blowfish_icon('tag'); ?><?php echo blowfish_text($tagName); ?></a>
<?php if ($bdTagCount < $bdMaxTags) : $bdTagCount++; ?>
<a class="taxonomy-badge" href="<?php echo DOMAIN_TAGS . $tagKey; ?>"><?php echo blowfish_icon('tag'); ?><?php echo blowfish_text($tagName); ?></a>
<?php else : $bdTagOverflow++; ?>
<?php endif ?>
<?php endforeach ?>
<?php if ($bdTagOverflow > 0) : ?>
<a class="taxonomy-badge taxonomy-badge-more" href="<?php echo $page->permalink(); ?>" title="<?php echo $L->get('All tags'); ?>">+<?php echo $bdTagOverflow; ?></a>
<?php endif ?>
</div>
<?php endif ?>
</div><!-- /.post-list-main -->
<!-- Cover thumbnail -->
<?php if ($bdCover) : ?>
<a class="post-list-thumb" href="<?php echo $page->permalink(); ?>" tabindex="-1" aria-hidden="true">
<img src="<?php echo htmlspecialchars($bdCover, ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy" decoding="async" />
</a>
<?php endif ?>
</div><!-- /.post-list-row -->
<!-- Load Bludit Plugins: Page End -->
<?php Theme::plugins('pageEnd'); ?>
+22
View File
@@ -55,6 +55,28 @@ if (!function_exists('blowfish_icon')) {
return DOMAIN_THEME . $rel . ($v ? '?v=' . $v : '');
}
// Inject width/height attributes into local-upload <img> tags that lack
// them, so the browser reserves the box before the image loads (no CLS).
// Only touches images served from this site's uploads folder; remote
// images and tags that already declare a width are left alone.
function blowfish_img_dimensions($html) {
if (!defined('DOMAIN_UPLOADS') || !defined('PATH_UPLOADS')) { return $html; }
return preg_replace_callback('/<img\b[^>]*>/i', function ($m) {
$tag = $m[0];
if (preg_match('/\b(?:width|height)\s*=/i', $tag)) { return $tag; }
if (!preg_match('/\bsrc=["\']([^"\']+)["\']/i', $tag, $src)) { return $tag; }
$url = html_entity_decode($src[1], ENT_QUOTES, 'UTF-8');
if (strpos($url, DOMAIN_UPLOADS) !== 0) { return $tag; }
$rel = rawurldecode(substr($url, strlen(DOMAIN_UPLOADS)));
if ($rel === '' || strpos($rel, '..') !== false) { return $tag; }
$file = PATH_UPLOADS . $rel;
if (!is_file($file)) { return $tag; }
$size = @getimagesize($file);
if (!$size || empty($size[0]) || empty($size[1])) { return $tag; }
return preg_replace('/<img\b/i', '<img width="' . (int) $size[0] . '" height="' . (int) $size[1] . '"', $tag, 1);
}, $html);
}
// Map a theme key to its toggle icon name.
function blowfish_theme_icon($theme) {
$map = array(
+47 -1
View File
@@ -102,11 +102,15 @@
// Lazy-load + async-decode in-content images that don't already
// set a loading attribute. Operates on the rendered HTML, so
// carousel/tabs fences (still raw text inside <pre>) are untouched.
echo preg_replace(
$bdContent = preg_replace(
'/<img(?![^>]*\bloading=)/i',
'<img loading="lazy" decoding="async"',
$page->content()
);
// Add width/height to local-upload images so the layout doesn't
// shift as they load (CLS). CSS `img { height: auto }` keeps the
// aspect ratio responsive.
echo blowfish_img_dimensions($bdContent);
?>
</div>
@@ -144,6 +148,48 @@
</article>
<?php
// ---- Previous / next post navigation ----
// Chronological neighbours (Bludit's list is newest-first). Guarded like
// the related-posts block so an API difference degrades to nothing.
if (!$page->isStatic() && !$url->notFound()) {
$bdOlder = null; $bdNewer = null;
try {
global $pages;
if (isset($pages) && method_exists($pages, 'getList')) {
$bdNavKeys = array();
foreach ($pages->getList(1, 10000, true) as $bdNk) {
$bdNp = new Page($bdNk);
if (!$bdNp->isStatic()) { $bdNavKeys[] = $bdNp; }
}
foreach ($bdNavKeys as $bdNi => $bdNp) {
if ($bdNp->key() === $page->key()) {
if ($bdNi > 0) { $bdNewer = $bdNavKeys[$bdNi - 1]; }
if ($bdNi < count($bdNavKeys) - 1) { $bdOlder = $bdNavKeys[$bdNi + 1]; }
break;
}
}
}
} catch (\Throwable $e) { $bdOlder = null; $bdNewer = null; }
?>
<?php if ($bdOlder || $bdNewer) : ?>
<nav class="post-nav" aria-label="<?php echo $L->get('Post navigation'); ?>">
<?php if ($bdOlder) : ?>
<a class="post-nav-item post-nav-older" href="<?php echo $bdOlder->permalink(); ?>" rel="prev">
<span class="post-nav-label"><?php echo blowfish_icon('chevron-left'); ?><?php echo $L->get('Older post'); ?></span>
<span class="post-nav-title"><?php echo blowfish_text($bdOlder->title()); ?></span>
</a>
<?php else : ?><span class="post-nav-item post-nav-empty" aria-hidden="true"></span><?php endif ?>
<?php if ($bdNewer) : ?>
<a class="post-nav-item post-nav-newer" href="<?php echo $bdNewer->permalink(); ?>" rel="next">
<span class="post-nav-label"><?php echo $L->get('Newer post'); ?><?php echo blowfish_icon('chevron-right'); ?></span>
<span class="post-nav-title"><?php echo blowfish_text($bdNewer->title()); ?></span>
</a>
<?php else : ?><span class="post-nav-item post-nav-empty" aria-hidden="true"></span><?php endif ?>
</nav>
<?php endif ?>
<?php } ?>
<?php
// ---- Related posts ----
// Best-effort via Bludit's Pages API; wrapped so any API difference degrades