summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcopypaste <wizardchan@hush.com>2013-07-18 11:30:00 -0400
committerMichael Foster <savetheinternet@tinyboard.org>2013-07-18 11:30:00 -0400
commitf5d378fab5eca1147923bbc268cc7ea1e864041c (patch)
tree2e87bddde47ecf766765be35cf00c86af593c104
parent25ca144d0cf08a4bc82c6d8b5c2038a0423a78d0 (diff)
Catalog theme
-rw-r--r--templates/themes/catalog/catalog.css38
-rw-r--r--templates/themes/catalog/info.php42
-rw-r--r--templates/themes/catalog/theme.php64
3 files changed, 144 insertions, 0 deletions
diff --git a/templates/themes/catalog/catalog.css b/templates/themes/catalog/catalog.css
new file mode 100644
index 00000000..048dd656
--- /dev/null
+++ b/templates/themes/catalog/catalog.css
@@ -0,0 +1,38 @@
+img {
+ float:none!important;
+ margin: auto;
+ margin-bottom: 12px;
+ max-height: 150px;
+ max-width: 200px;
+ box-shadow: 0 0 4px rgba(0, 0, 0, 0.55);
+ border: 2px solid rgba(153, 153, 153, 0);
+}
+
+/*
+img:hover {
+ border: 2px solid rgba(153, 153, 153, 0.27);
+}
+*/
+
+div.thread {
+ display: inline-block;
+ vertical-align: top;
+ margin-bottom:25px;
+ margin-left: 20px;
+ margin-right: 15px;
+ text-align:center;
+ font-weight:normal;
+ width:205px;
+ overflow:hidden;
+ position: relative;
+ font-size:11px;
+ padding: 15px;
+ background: rgba(182, 182, 182, 0.12);
+ border: 2px solid rgba(111, 111, 111, 0.34);
+ max-height:300px;
+}
+
+div.thread:hover {
+ background: #D6DAF0;
+ border-color: #B7C5D9;
+} \ No newline at end of file
diff --git a/templates/themes/catalog/info.php b/templates/themes/catalog/info.php
new file mode 100644
index 00000000..1b9831ae
--- /dev/null
+++ b/templates/themes/catalog/info.php
@@ -0,0 +1,42 @@
+<?php
+ $theme = array();
+
+ // Theme name
+ $theme['name'] = 'Catalog';
+ // Description (you can use Tinyboard markup here)
+ $theme['description'] = 'Show a post catalog.';
+ $theme['version'] = 'v0.1';
+
+ // Theme configuration
+ $theme['config'] = Array();
+
+ $theme['config'][] = Array(
+ 'title' => 'Title',
+ 'name' => 'title',
+ 'type' => 'text',
+ 'default' => 'Catalog'
+ );
+
+ $__boards = listBoards();
+ $__default_boards = Array();
+ foreach ($__boards as $__board)
+ $__default_boards[] = $__board['uri'];
+
+ $theme['config'][] = Array(
+ 'title' => 'Included boards',
+ 'name' => 'boards',
+ 'type' => 'text',
+ 'comment' => '(space seperated)',
+ 'default' => implode(' ', $__default_boards)
+ );
+
+ $theme['config'][] = Array(
+ 'title' => 'CSS file',
+ 'name' => 'css',
+ 'type' => 'text',
+ 'default' => 'catalog.css',
+ 'comment' => '(eg. "catalog.css")'
+ );
+
+ // Unique function name for building everything
+ $theme['build_function'] = 'catalog_build';
diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php
new file mode 100644
index 00000000..356933ba
--- /dev/null
+++ b/templates/themes/catalog/theme.php
@@ -0,0 +1,64 @@
+<?php
+ require 'info.php';
+
+ function catalog_build($action, $settings) {
+ // Possible values for $action:
+ // - all (rebuild everything, initialization)
+ // - news (news has been updated)
+ // - boards (board list changed)
+ // - post (a post has been made)
+
+ $b = new Catalog();
+ $b->build($action, $settings);
+ }
+
+ // Wrap functions in a class so they don't interfere with normal Tinyboard operations
+ class Catalog {
+ public function build($action, $settings) {
+ global $config, $_theme;
+
+ if ($action == 'all') {
+ copy('templates/themes/catalog/catalog.css', $config['dir']['home'] . $settings['css']);
+ }
+
+ $boards = explode(' ', $settings['boards']);
+ foreach ($boards as $board) {
+ if ($action == 'all' || $action == 'post')
+ file_write($config['dir']['home'] . $board . '/catalog.html', $this->homepage($settings, $board));
+ }
+
+ }
+
+ public function homepage($settings, $board_name) {
+ global $config, $board;
+
+ $recent_images = array();
+ $recent_posts = array();
+ $stats = array();
+
+ $query = query(sprintf("SELECT *, `id` AS `thread_id`, (SELECT COUNT(*) FROM `posts_%s` WHERE `thread` = `thread_id`) AS `reply_count`, '%s' AS `board` FROM `posts_%s` WHERE `thread` IS NULL ORDER BY `bump` DESC", $board_name, $board_name, $board_name)) or error(db_error());
+
+ while ($post = $query->fetch()) {
+ openBoard($post['board']);
+
+ $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id']));
+ $post['board_name'] = $board['name'];
+ $post['file'] = $config['uri_thumb'] . $post['thumb'];
+ $recent_posts[] = $post;
+ }
+
+
+ return Element('themes/catalog/catalog.html', Array(
+ 'settings' => $settings,
+ 'config' => $config,
+ 'boardlist' => createBoardlist(),
+ 'recent_images' => $recent_images,
+ 'recent_posts' => $recent_posts,
+ 'stats' => $stats,
+ 'board' => $board_name,
+ 'link' => $config['root'] . $board['dir']
+ ));
+ }
+ };
+
+?>