Site Builder
Editing:
index.php
writable 0666
<?php /************************************************************************** * TAGS INDEX / VIEWER • single‑file drop‑in * ------------------------------------------------- * 1. Lists all tag files ( /tags/*.txt , *.md ) * 2. ?t=slug → shows that one tag * /tags/slug also works via .htaccess rewrite * 3. Text file format: * --- ← optional YAML front‑matter * tag: emf protection * updated: 2025‑07‑24T03:12:00Z * --- * Your blurb **markdown** here … * * Front‑matter is optional—if missing we still show body. **************************************************************************/ /* ---------- config --------------------------------------------------- */ $dir = __DIR__; // /business/<slug>/tags/ $title = 'Tags'; // page <title> /* ---------- helper: tiny YAML parser (if ext/yaml not enabled) ------- */ if (!function_exists('yaml_parse')) { function yaml_parse(string $txt) { // VERY basic: key: value only $out=[]; foreach (preg_split('/\r?\n/', $txt) as $ln) { if (strpos($ln, ':')!==false) { [$k,$v]=explode(':', $ln, 2); $out[trim($k)] = trim($v); } } return $out; } } /* ---------- find requested tag -------------------------------------- */ $tagParam = preg_replace('/[^a-z0-9_-]/i', '', $_GET['t'] ?? ''); if (!$tagParam && preg_match('#/tags/([^/]+)$#', $_SERVER['REQUEST_URI'], $m)) { $tagParam = preg_replace('/[^a-z0-9_-]/i', '', $m[1]); } $file = $tagParam ? "$dir/$tagParam.txt" : ''; $renderOne = is_file($file); /* ---------- HTML head ------------------------------------------------ */ ?> <!doctype html><html lang="en"><head> <meta charset="utf-8"> <title><?=htmlspecialchars($renderOne ? ucfirst($tagParam) : $title)?></title> <meta name="viewport" content="width=device-width,initial-scale=1"> <style> :root{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif; --violet:#5c3bff;--gold:#ffb63b} body{margin:0;background:#f5f8fb;color:#1b334a;line-height:1.5} main{max-width:780px;margin:2rem auto;padding:0 1rem} a{color:var(--violet);text-decoration:none} a:hover{text-decoration:underline} /* tag list grid ------------------------------------------------------ */ .tag-list{display:grid;gap:1.1rem;grid-template-columns:repeat(auto-fill,minmax(160px,1fr))} .tag{background:#fff;border:2.5px solid var(--gold);border-radius:18px; box-shadow:0 4px 16px #c2d4ff33;padding:1.1rem;text-align:center;font-weight:700} /* blurb card --------------------------------------------------------- */ .blurb{background:#fff;border:3.5px solid var(--gold);border-radius:27px; box-shadow:0 6px 26px #dde3fa50;padding:2rem 1.6rem} .blurb h1{margin-top:0;font-size:1.7rem;color:#2c61d7} .blurb p{margin:.8rem 0} </style> </head><body><main> <?php /* ---------- single tag view ----------------------------------------- */ if ($renderOne) { $raw = file_get_contents($file); // pull optional front‑matter if (preg_match('/^---\s*(.*?)\s*---\s*(.*)$/s', $raw, $m)) { $meta = yaml_parse($m[1]); $body = $m[2]; $tag = $meta['tag'] ?? $tagParam; $title = ucfirst($tag); } else { $meta = []; $body = $raw; $title = ucfirst(str_replace('-',' ',$tagParam)); } // very light Markdown: **bold** & line‑breaks $html = nl2br(preg_replace('/\*\*(.+?)\*\*/','<strong>$1</strong>', htmlspecialchars($body))); echo '<article class="blurb">'; echo '<h1>'.htmlspecialchars($title).'</h1>'; echo $html; echo '<p><a href="./">← Back to all tags</a></p>'; echo '</article>'; } else { /* ---------- list all tags --------------------------------------- */ $files = glob("$dir/*.txt"); natsort($files); if (!$files) { echo '<p>No tags yet.</p>'; exit; } echo '<h1 style="margin-top:0">All Tags</h1>'; echo '<div class="tag-list">'; foreach ($files as $f) { $slug = basename($f, '.txt'); $name = ucfirst(str_replace('-',' ', $slug)); echo '<a class="tag" href="?t='.urlencode($slug).'">'.$name.'</a>'; } echo '</div>'; } ?> </main></body></html>
Save changes
Create folder
writable 0777
Create
Cancel