This is an old revision of the document!
Table of Contents
Pure Blog
I've installed Pure Blog
After trying the Blog Plugin in dokuwiki and Chyrp-Lite PHP/SQLite blogging platform I switched to Pure Blog.
It's just what I need, and nothing extra to make it big and bloated.
Installation & Configuration
See https://g4slv.info/installing-pure-blog for some info.
Addons
Kev sent me 2 PHP scripts to provide a Tag-Cloud and a full site Archive page.
I tweaked them a bit, and here are my current versions.
- tag-cloud.php
<?php declare(strict_types=1); $pageTitle = 'Tag Cloud'; $metaDescription = 'All tags, sized by how often they appear.'; $tagIndex = load_tag_index(); $tagCounts = []; if ($tagIndex) { foreach ($tagIndex as $slug => $slugs) { $tagCounts[$slug] = count($slugs); } } // Collect original display names from posts (slugs alone lose capitalisation/spaces) $originalNames = []; foreach (get_all_posts(false) as $post) { foreach (($post['tags'] ?? []) as $tag) { $slug = normalize_tag($tag); if (!isset($originalNames[$slug])) { $originalNames[$slug] = $tag; } } } // Sort alphabetically by display name uksort($tagCounts, function (string $a, string $b) use ($originalNames): int { return strcasecmp($originalNames[$a] ?? $a, $originalNames[$b] ?? $b); }); $maxCount = $tagCounts ? max($tagCounts) : 1; $minCount = $tagCounts ? min($tagCounts) : 1; $range = $maxCount > $minCount ? $maxCount - $minCount : 1; require PUREBLOG_BASE_PATH . '/includes/header.php'; render_masthead_layout($config, ['page' => null]); ?> <main> <h1>Tag Cloud</h1> <?php if (empty($tagCounts)): ?> <p>No tags found.</p> <?php else: ?> <p class="tag-cloud"> <?php foreach ($tagCounts as $slug => $count): $name = $originalNames[$slug] ?? $slug; $ratio = ($count - $minCount) / $range; $fontSize = round(0.85 + $ratio * 1.4, 2); $postWord = $count === 1 ? 'post' : 'posts'; echo '<a href="/tag/' . e(rawurlencode($slug)) . '"' . ' style="font-size: ' . $fontSize . 'em"' . ' title="' . e((string) $count) . ' ' . $postWord . '">' . e($name) . '(' . e((string) $count) . ')' . '</a>' . '  '; endforeach; ?> </p> <?php endif; ?> </main> <?php render_footer_layout($config, ['page' => null]); ?> </body> </html>
- archive.php
<?php declare(strict_types=1); $allPosts = get_all_posts(false); $postsByYear = []; foreach ($allPosts as $entry) { $year = !empty($entry['date']) ? date('Y', strtotime((string) $entry['date'])) : 'Unknown'; $postsByYear[$year][] = $entry; } krsort($postsByYear, SORT_NATURAL); $pageTitle = 'Archive'; $metaDescription = 'Browse all published posts by year.'; ?> <?php require PUREBLOG_BASE_PATH . '/includes/header.php'; ?> <?php render_masthead_layout($config); ?> <main class=archive> <article> <h1>Archive</h1> <p><?= e((string) count($allPosts)) ?> published posts.</p> <?php if (!$allPosts): ?> <p>No published posts yet.</p> <?php else: ?> <?php foreach ($postsByYear as $year => $yearPosts): ?> <h3><?= e((string) $year) ?> (<?= e((string) count($yearPosts)) ?>)</h3> <ul> <?php foreach ($yearPosts as $postItem): ?> <li> <?php if (!empty($postItem['date'])): ?> <!-- <small> --> <time datetime="<?= e((string) $postItem['date']) ?>"> <?= e(date('D Y-m-d H:i', strtotime((string) $postItem['date']))) ?> </time> <!-- </small> -->   <?php endif; ?> <a href="/<?= e((string) ($postItem['slug'] ?? '')) ?>"> <?= e((string) ($postItem['title'] ?? 'Untitled')) ?> </a> </li> <?php endforeach; ?> </ul> <?php endforeach; ?> <?php endif; ?> </article> </main> <?php render_footer_layout($config); ?> </body> </html>
Further Information
Page created : 02/03/26 08:50 GMT
Page updated : 02/03/26 09:03 GMT