Diff
diff --git a/lib/db.php b/lib/db.php
index cd7371d..18fae5d 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -83,9 +83,50 @@ class Db {
self::ensure_column('threads', 'pinned', "INTEGER NOT NULL DEFAULT 0");
self::ensure_column('threads', 'locked', "INTEGER NOT NULL DEFAULT 0");
+ self::seed_boards();
self::build_search();
}
+ /**
+ * this function plants the default board layout the first time the app runs
+ * against an empty boards table, so a fresh (e.g. production) database comes
+ * up with the same categories and boards as development. it is a one-time
+ * seed: once any boards exist, admin-panel edits and deletions are left
+ * untouched. board names carry a leading nerd font glyph (iosevka nerd font
+ * is shipped + @font-face'd in the css, so these render for every visitor)
+ *
+ * @return void
+ */
+ public static function seed_boards() : void {
+ $dbh = self::handle();
+ if ((int) $dbh->query("SELECT COUNT(*) FROM boards")->fetchColumn() > 0) {
+ return;
+ }
+
+ // [category, slug, glyph + name, description, position]
+ $boards = [
+ ['administrative', 'announcements', "\u{f0a1} announcements", 'official news & site updates', 0],
+ ['administrative', 'rules', "\u{f0e3} rules", 'read before posting', 1],
+ ['administrative', 'tutorial-requests', "\u{f02d} tutorial requests", 'request or post guides & howtos', 2],
+ ['the distro wars', 'arch', "\u{f303} arch", 'arch & arch-based discussion', 10],
+ ['the distro wars', 'nixos', "\u{f313} nixos", 'nixos & flakes discussion', 11],
+ ['the distro wars', 'gentoo', "\u{f30d} gentoo", 'gentoo & source-based discussion', 12],
+ ['the distro wars', 'gnu-guix', "\u{f325} gnu guix", 'gnu guix discussion', 13],
+ ['the lounge', 'general', "\u{f086} general", 'general linux & tech chat', 20],
+ ['the lounge', 'the-code-review', "\u{f121} the code review", 'share code, get reviews & talk programming', 21],
+ ['other', 'post-your-rice', "\u{f108} post your rice", 'show off your desktop, dotfiles & themes', 30],
+ ['other', 'tech-support', "\u{f1cd} tech support", 'broke something? get help here', 31],
+ ['other', 'off-topic', "\u{f0f4} off-topic", "everything that isn't linux", 32],
+ ];
+
+ $sth = $dbh->prepare(
+ "INSERT INTO boards (slug, name, description, category, position) VALUES (?, ?, ?, ?, ?)"
+ );
+ foreach ($boards as [$category, $slug, $name, $description, $position]) {
+ $sth->execute([$slug, $name, $description, $category, $position]);
+ }
+ }
+
/**
* this function adds a column to a table only if its not there yet, so an
* older database picks up new columns in place without a full rebuild
diff --git a/public/css/style.css b/public/css/style.css
index dd60c24..0f47bdc 100644
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -1,22 +1,28 @@
@font-face {
font-family: 'IosevkaNerdFontMono';
- src: url('/fonts/IosevkaNerdFontMono-Regular.ttf') format('truetype');
+ src: url('/fonts/IosevkaNerdFontMono-Regular.woff2') format('woff2'),
+ url('/fonts/IosevkaNerdFontMono-Regular.ttf') format('truetype');
font-weight: 400;
font-style: normal;
+ font-display: swap;
}
@font-face {
font-family: 'IosevkaNerdFontMono';
- src: url('/fonts/IosevkaNerdFontMono-Bold.ttf') format('truetype');
+ src: url('/fonts/IosevkaNerdFontMono-Bold.woff2') format('woff2'),
+ url('/fonts/IosevkaNerdFontMono-Bold.ttf') format('truetype');
font-weight: 700;
font-style: normal;
+ font-display: swap;
}
@font-face {
font-family: 'IosevkaNerdFontMono';
- src: url('/fonts/IosevkaNerdFontMono-Italic.ttf') format('truetype');
+ src: url('/fonts/IosevkaNerdFontMono-Italic.woff2') format('woff2'),
+ url('/fonts/IosevkaNerdFontMono-Italic.ttf') format('truetype');
font-weight: 400;
font-style: italic;
+ font-display: swap;
}
:root {
diff --git a/public/fonts/IosevkaNerdFontMono-Bold.woff2 b/public/fonts/IosevkaNerdFontMono-Bold.woff2
new file mode 100644
index 0000000..413ca3c
Binary files /dev/null and b/public/fonts/IosevkaNerdFontMono-Bold.woff2 differ
diff --git a/public/fonts/IosevkaNerdFontMono-Italic.woff2 b/public/fonts/IosevkaNerdFontMono-Italic.woff2
new file mode 100644
index 0000000..e797f48
Binary files /dev/null and b/public/fonts/IosevkaNerdFontMono-Italic.woff2 differ
diff --git a/public/fonts/IosevkaNerdFontMono-Regular.woff2 b/public/fonts/IosevkaNerdFontMono-Regular.woff2
new file mode 100644
index 0000000..75da3ed
Binary files /dev/null and b/public/fonts/IosevkaNerdFontMono-Regular.woff2 differ