From d705edda91dd1743fd56f4cb0087ee6fed5a6b8a Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Tue, 11 Aug 2020 06:01:00 -0700 Subject: [PATCH] Add catalog page Resolves #107. --- css/global.css | 11 ++++++++++ inc/defines.php | 3 +++ inc/functions.php | 4 ++-- inc/html.php | 52 ++++++++++++++++++++++++++++++++++++++++++-- settings.default.php | 1 + 5 files changed, 67 insertions(+), 4 deletions(-) diff --git a/css/global.css b/css/global.css index d16277b..a2e063d 100644 --- a/css/global.css +++ b/css/global.css @@ -115,6 +115,17 @@ hr { clear: both; } +.catalogpost { + display: inline-block; + vertical-align: top; + overflow: hidden; + white-space: nowrap; + text-align: center; + text-overflow: ellipsis; + min-width: 100px; + padding: 0px 3px 3px; +} + .login { text-align: center; } diff --git a/inc/defines.php b/inc/defines.php index b4054c4..8a4bc74 100644 --- a/inc/defines.php +++ b/inc/defines.php @@ -43,6 +43,9 @@ if (!defined('TINYIB_WORDBREAK')) { if (!defined('TINYIB_TIMEZONE')) { define('TINYIB_TIMEZONE', ''); } +if (!defined('TINYIB_CATALOG')) { + define('TINYIB_CATALOG', true); +} if (!defined('TINYIB_DBMIGRATE')) { define('TINYIB_DBMIGRATE', false); } diff --git a/inc/functions.php b/inc/functions.php index bec65de..d948560 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -240,8 +240,8 @@ function writePage($filename, $contents) { } function fixLinksInRes($html) { - $search = array(' href="css/', ' src="js/', ' href="src/', ' href="thumb/', ' href="res/', ' href="imgboard.php', ' href="favicon.ico', 'src="thumb/', 'src="inc/', 'src="sticky.png', 'src="lock.png', ' action="imgboard.php'); - $replace = array(' href="../css/', ' src="../js/', ' href="../src/', ' href="../thumb/', ' href="../res/', ' href="../imgboard.php', ' href="../favicon.ico', 'src="../thumb/', 'src="../inc/', 'src="../sticky.png', 'src="../lock.png', ' action="../imgboard.php'); + $search = array(' href="css/', ' src="js/', ' href="src/', ' href="thumb/', ' href="res/', ' href="imgboard.php', ' href="catalog.html', ' href="favicon.ico', 'src="thumb/', 'src="inc/', 'src="sticky.png', 'src="lock.png', ' action="imgboard.php', ' action="catalog.html'); + $replace = array(' href="../css/', ' src="../js/', ' href="../src/', ' href="../thumb/', ' href="../res/', ' href="../imgboard.php', ' href="../catalog.html', ' href="../favicon.ico', 'src="../thumb/', 'src="../inc/', 'src="../sticky.png', 'src="../lock.png', ' action="../imgboard.php', ' action="../catalog.html'); return str_replace($search, $replace, $html); } diff --git a/inc/html.php b/inc/html.php index b37bd80..1a9cdc8 100644 --- a/inc/html.php +++ b/inc/html.php @@ -503,7 +503,7 @@ function buildPage($htmlposts, $parent, $pages = 0, $thispage = 0) { $pagelinks .= ($pages <= $thispage) ? "Next" : '
'; $pagenavigator = << + $pagelinks @@ -511,15 +511,32 @@ function buildPage($htmlposts, $parent, $pages = 0, $thispage = 0) {
EOF; + if (TINYIB_CATALOG) { + $pagenavigator .= << + + +
+ + + +EOF; + } + } else if ($parent == -1) { + $postingmode = '[Return]
Catalog
'; } else { $postingmode = '[Return]
Posting mode: Reply
'; } - $postform = buildPostForm($parent); + $postform = ''; + if ($parent >= TINYIB_NEWTHREAD) { + $postform = buildPostForm($parent); + } $body = <<
+ [Catalog] [Manage]
+EOF; +} + +function rebuildCatalog() { + $threads = allThreads(); + $htmlposts = ''; + foreach ($threads as $post) { + $htmlposts .= buildCatalogPost($post); + } + $htmlposts .= '
'; + + writePage('catalog.html', buildPage($htmlposts, -1)); +} + function rebuildIndexes() { $page = 0; $i = 0; @@ -584,6 +628,10 @@ function rebuildIndexes() { $file = ($page == 0) ? TINYIB_INDEX : ($page . '.html'); writePage($file, buildPage($htmlposts, 0, $pages, $page)); } + + if (TINYIB_CATALOG) { + rebuildCatalog(); + } } function rebuildThread($id) { diff --git a/settings.default.php b/settings.default.php index 9abc5b4..9071dcd 100644 --- a/settings.default.php +++ b/settings.default.php @@ -27,6 +27,7 @@ define('TINYIB_PREVIEWREPLIES', 3); // Amount of replies previewed on index pa define('TINYIB_TRUNCATE', 15); // Messages are truncated to this many lines on board index pages [0 to disable] define('TINYIB_WORDBREAK', 80); // Words longer than this many characters will be broken apart [0 to disable] define('TINYIB_TIMEZONE', 'UTC'); // See https://secure.php.net/manual/en/timezones.php - e.g. America/Los_Angeles +define('TINYIB_CATALOG', true); // Generate catalog page $tinyib_hidefieldsop = array(); // Fields to hide when creating a new thread - e.g. array('name', 'email', 'subject', 'message', 'file', 'embed', 'password') $tinyib_hidefields = array(); // Fields to hide when replying