View Source

Preview the code here, or download the complete usable site as one ZIP. It contains the same unminified, untranspiled PHP, CSS, images, and configuration that run the site.

↓ Download complete site source
index.php 143 lines
<?php
$pageTitle   = 'dispelled.ca';
$currentPage = 'home';
require_once __DIR__ . '/includes/config.php';
require_once __DIR__ . '/includes/rss.php';
$filter = $_GET['source'] ?? 'all';
$q      = trim($_GET['q'] ?? '');
$availableSources = ['all', 'slashdot', 'ars', 'hn', 'register', 'phoronix', 'debian', 'kernel', 'freebsd', 'openbsd', 'eff', 'krebs'];
if (!in_array($filter, $availableSources, true)) $filter = 'all';
$feedItems = getAllFeedItems();
if ($q !== '') {
    $filter = 'all';
    $feedItems = array_values(array_filter($feedItems, function($i) use ($q) {
        return stripos($i['title'], $q) !== false
            || stripos($i['description'] ?? '', $q) !== false;
    }));
} elseif ($filter !== 'all') {
    $feedItems = array_values(array_filter($feedItems, fn($i) => $i['source'] === $filter));
}
require_once __DIR__ . '/includes/header.php';
?>
<section class="home-quick-links" aria-label="Featured Articles">
  <div class="hql-header">
    <div>
      <h2>Featured Articles</h2>
    </div>
    <a href="<?= BASE_PATH ?>/categories.php" class="hql-all">[ Browse All ]</a>
  </div>
  <ul class="hql-list">
    <li class="hql-item">
      <span class="hql-cat">Code</span>
      <a href="<?= BASE_PATH ?>/categories.php?cat=<?= urlencode('Code') ?>&amp;article=<?= urlencode('Creating a Simple Client-Server Application in C') ?>" class="hql-link">Network Sockets in C</a>
      <span class="hql-desc">Building TCP clients and servers from scratch in C.</span>
    </li>
    <li class="hql-item">
      <span class="hql-cat">Unix</span>
      <a href="<?= BASE_PATH ?>/categories.php?cat=<?= urlencode('Unix') ?>&amp;article=<?= urlencode('The Birth of Unix at Bell Labs') ?>" class="hql-link">The Origins of Unix</a>
      <span class="hql-desc">How Thompson, Ritchie, and McIlroy built the system that shaped computing.</span>
    </li>
    <li class="hql-item">
      <span class="hql-cat">Homelab</span>
      <a href="<?= BASE_PATH ?>/categories.php?cat=<?= urlencode('Homelab') ?>&amp;article=<?= urlencode('Building a Compact 10-inch Homelab Rack') ?>" class="hql-link">10-inch Homelab Racks</a>
      <span class="hql-desc">Planning, parts, and 3D prints for dense, quiet home infrastructure.</span>
    </li>
    <li class="hql-item">
      <span class="hql-cat">Wireless Networking</span>
      <a href="<?= BASE_PATH ?>/categories.php?cat=<?= urlencode('Wireless Networking') ?>&amp;article=<?= urlencode('Linux Wireless Interfaces with iw and nmcli') ?>" class="hql-link">Linux Wireless Tools</a>
      <span class="hql-desc">Managing 802.11 interfaces directly from the command line.</span>
    </li>
    <li class="hql-item">
      <span class="hql-cat">Python</span>
      <a href="<?= BASE_PATH ?>/categories.php?cat=<?= urlencode('Python') ?>&amp;article=<?= urlencode("Beginner's Guide to Python Programming") ?>" class="hql-link">Beginner's Python</a>
      <span class="hql-desc">Start here to learn programming, from variables to command line tools.</span>
    </li>
    <li class="hql-item">
      <span class="hql-cat">Retro Hardware</span>
      <a href="<?= BASE_PATH ?>/categories.php?cat=<?= urlencode('Retro Hardware') ?>&amp;article=<?= urlencode('DEC PDP-11 Architecture Models Peripherals and Unix Context') ?>" class="hql-link">DEC PDP-11 Architecture</a>
      <span class="hql-desc">The minicomputer that defined C and hosted the first editions of Unix.</span>
    </li>
  </ul>
</section>
<div class="feed-header">
  <div class="feed-header-row">
    <div class="terminal-title">
      <div class="terminal-title-line">
        <h1>Terminal</h1>
        <span class="terminal-live"><span aria-hidden="true"></span>Live RSS</span>
      </div>
      <p class="home-section-note">External headlines from independent technology and security sources.</p>
    </div>
    <form method="GET" action="" class="search-form">
      <input
        type="search"
        name="q"
        class="search-input"
        placeholder="Search…"
        value="<?= htmlspecialchars($q) ?>"
      >
    </form>
  </div>
  <?php if (!$q): ?>
  <div class="filter-bar">
    <a href="?source=all"       class="filter-btn <?= $filter === 'all'       ? 'active' : '' ?>">All</a>
    <a href="?source=slashdot"  class="filter-btn <?= $filter === 'slashdot'  ? 'active' : '' ?>">Slashdot</a>
    <a href="?source=ars"       class="filter-btn <?= $filter === 'ars'       ? 'active' : '' ?>">Ars Technica</a>
    <a href="?source=hn"        class="filter-btn <?= $filter === 'hn'        ? 'active' : '' ?>">Hacker News</a>
    <a href="?source=register"  class="filter-btn <?= $filter === 'register'  ? 'active' : '' ?>">The Register</a>
    <a href="?source=phoronix"  class="filter-btn <?= $filter === 'phoronix'  ? 'active' : '' ?>">Phoronix</a>
    <a href="?source=debian"    class="filter-btn <?= $filter === 'debian'    ? 'active' : '' ?>">Debian News</a>
    <a href="?source=kernel"    class="filter-btn <?= $filter === 'kernel'    ? 'active' : '' ?>">kernel.org</a>
    <a href="?source=freebsd"   class="filter-btn <?= $filter === 'freebsd'   ? 'active' : '' ?>">FreeBSD News</a>
    <a href="?source=openbsd"   class="filter-btn <?= $filter === 'openbsd'   ? 'active' : '' ?>">OpenBSD Journal</a>
    <a href="?source=eff"       class="filter-btn <?= $filter === 'eff'       ? 'active' : '' ?>">EFF</a>
    <a href="?source=krebs"     class="filter-btn <?= $filter === 'krebs'     ? 'active' : '' ?>">Krebs</a>
  </div>
  <?php endif ?>
</div>
<?php if ($q && empty($feedItems)): ?>
  <p class="empty-msg">No results for &ldquo;<?= htmlspecialchars($q) ?>&rdquo;.</p>
<?php elseif (empty($feedItems)): ?>
  <p style="color:var(--text-muted);font-family:'Roboto Mono',monospace;font-size:.85rem;">
    Loading feeds&hellip; refresh in a moment.
  </p>
<?php else: ?>
<ul class="feed-list feed-timeline">
<?php foreach ($feedItems as $item): ?>
  <li class="feed-item">
    <div class="feed-dot source-<?= htmlspecialchars($item['source']) ?>"></div>
    <h2>
      <a href="<?= htmlspecialchars($item['url']) ?>" target="_blank" rel="noreferrer noopener">
        <?= htmlspecialchars($item['title']) ?><span class="external-mark" aria-hidden="true"> ↗</span><span class="sr-only"> (opens external article)</span>
      </a>
    </h2>
    <div class="feed-meta">
      <span class="source-badge <?= htmlspecialchars($item['source']) ?>">
        <?= htmlspecialchars($item['sourceLabel']) ?>
      </span>
      <time class="feed-time"><?= timeAgo($item['publishedAt']) ?></time>
    </div>
    <?php if ($item['description']): ?>
      <p class="feed-desc"><?= htmlspecialchars($item['description']) ?>&hellip;</p>
    <?php endif; ?>
  </li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php require_once __DIR__ . '/includes/footer.php'; ?>