diff options
| author | Czterooki <czterooki1337@gmail.com> | 2013-07-20 00:19:08 -0400 |
|---|---|---|
| committer | Czterooki <czterooki1337@gmail.com> | 2013-07-20 00:19:08 -0400 |
| commit | aef44255920c18f443af28d100fb06d9699d4895 (patch) | |
| tree | b1d72ffc9a0e4f6a009ca16e9e3af2260806c193 /templates/themes | |
| parent | 81892ebcdcd2929128c2c320f7de975cab8ed368 (diff) | |
| parent | f04566f6d30553560d5a69e25e38de72a60f297c (diff) | |
merge with vichan-gold
Diffstat (limited to 'templates/themes')
| -rw-r--r-- | templates/themes/basic/theme.php | 2 | ||||
| -rw-r--r-- | templates/themes/catalog/catalog.css | 38 | ||||
| -rw-r--r-- | templates/themes/catalog/catalog.html | 36 | ||||
| -rw-r--r-- | templates/themes/catalog/info.php | 42 | ||||
| -rw-r--r-- | templates/themes/catalog/theme.php | 60 | ||||
| -rw-r--r-- | templates/themes/categories/theme.php | 2 | ||||
| -rw-r--r-- | templates/themes/frameset/theme.php | 2 | ||||
| -rw-r--r-- | templates/themes/recent/theme.php | 5 | ||||
| -rw-r--r-- | templates/themes/rrdtool/theme.php | 2 | ||||
| -rw-r--r-- | templates/themes/sitemap/info.php | 53 | ||||
| -rw-r--r-- | templates/themes/sitemap/sitemap.xml | 19 | ||||
| -rw-r--r-- | templates/themes/sitemap/theme.php | 32 | ||||
| -rw-r--r-- | templates/themes/ukko/info.php | 53 | ||||
| -rw-r--r-- | templates/themes/ukko/theme.php | 111 | ||||
| -rw-r--r-- | templates/themes/ukko/thumb.png | bin | 0 -> 15123 bytes | |||
| -rw-r--r-- | templates/themes/ukko/ukko.js | 37 |
16 files changed, 488 insertions, 6 deletions
diff --git a/templates/themes/basic/theme.php b/templates/themes/basic/theme.php index 806a331a..7ba0d1e7 100644 --- a/templates/themes/basic/theme.php +++ b/templates/themes/basic/theme.php @@ -1,7 +1,7 @@ <?php require 'info.php'; - function basic_build($action, $settings) { + function basic_build($action, $settings, $board) { // Possible values for $action: // - all (rebuild everything, initialization) // - news (news has been updated) 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/catalog.html b/templates/themes/catalog/catalog.html new file mode 100644 index 00000000..7b8c075a --- /dev/null +++ b/templates/themes/catalog/catalog.html @@ -0,0 +1,36 @@ +{% filter remove_whitespace %} +<!doctype html> +<html> +<head> + <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> + <title>{{ settings.title }}</title> + <link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}"/> + <link rel="stylesheet" media="screen" href="{{ config.root }}{{ settings.css }}"/> + {% if config.url_favicon %}<link rel="shortcut icon" href="{{ config.url_favicon }}" />{% endif %} +</head> +<body> + {{ boardlist.top }} + <header> + <h1>{{ settings.title }} (<a href="{{link}}">/{{ board }}/</a>)</h1> + <div class="subtitle">{{ settings.subtitle }}</div> + </header> + + <ul> + {% for post in recent_posts %} + <div class="thread"> + <a href="{{post.link}}"> + <img src="{{post.file}}" class="{{post.board}}" title="{{post.bump|date('%b %d %H:%M')}}"> + </a> + <span class="replies"> + <strong>{% trans %}1 reply{% plural post.reply_count %}{{ count }} replies{% endtrans %}</strong><br/> + {{ post.body }} + </span> + </div> + {% endfor %} + </ul> + + <hr/> + <p class="unimportant" style="margin-top:20px;text-align:center;">Powered by <a href="http://tinyboard.org/">Tinyboard</a> {{ config.version }} | <a href="http://tinyboard.org/">Tinyboard</a> Copyright © 2010-2013 Tinyboard Development Group</p> +</body> +</html> +{% endfilter %} 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..e585cf17 --- /dev/null +++ b/templates/themes/catalog/theme.php @@ -0,0 +1,60 @@ +<?php + require 'info.php'; + + function catalog_build($action, $settings, $board) { + global $config; + + // Possible values for $action: + // - all (rebuild everything, initialization) + // - news (news has been updated) + // - boards (board list changed) + // - post (a reply has been made) + // - post-thread (a thread has been made) + + $boards = explode(' ', $settings['boards']); + + if ($action == 'all') { + copy('templates/themes/catalog/catalog.css', $config['dir']['home'] . $settings['css']); + + foreach ($boards as $board) { + $b = new Catalog(); + $b->build($settings, $board); + } + } elseif ($action == 'post-thread' && in_array($board, $boards)) { + $b = new Catalog(); + $b->build($settings, $board); + } + } + + // Wrap functions in a class so they don't interfere with normal Tinyboard operations + class Catalog { + public function build($settings, $board_name) { + global $config, $board; + + openBoard($board_name); + + $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()) { + $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; + } + + file_write($config['dir']['home'] . $board_name . '/catalog.html', 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'] + ))); + } + }; diff --git a/templates/themes/categories/theme.php b/templates/themes/categories/theme.php index 11fcbbaf..7d468d0d 100644 --- a/templates/themes/categories/theme.php +++ b/templates/themes/categories/theme.php @@ -1,7 +1,7 @@ <?php require 'info.php'; - function categories_build($action, $settings) { + function categories_build($action, $settings, $board) { // Possible values for $action: // - all (rebuild everything, initialization) // - news (news has been updated) diff --git a/templates/themes/frameset/theme.php b/templates/themes/frameset/theme.php index 015eebaf..5fd9d29e 100644 --- a/templates/themes/frameset/theme.php +++ b/templates/themes/frameset/theme.php @@ -1,7 +1,7 @@ <?php require 'info.php'; - function frameset_build($action, $settings) { + function frameset_build($action, $settings, $board) { // Possible values for $action: // - all (rebuild everything, initialization) // - news (news has been updated) diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index b436ab0f..75907e77 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -1,12 +1,13 @@ <?php require 'info.php'; - function recentposts_build($action, $settings) { + function recentposts_build($action, $settings, $board) { // Possible values for $action: // - all (rebuild everything, initialization) // - news (news has been updated) // - boards (board list changed) // - post (a post has been made) + // - post-thread (a thread has been made) $b = new RecentPosts(); $b->build($action, $settings); @@ -23,7 +24,7 @@ $this->excluded = explode(' ', $settings['exclude']); - if ($action == 'all' || $action == 'post') + if ($action == 'all' || $action == 'post' || $action == 'post-thread') file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); } diff --git a/templates/themes/rrdtool/theme.php b/templates/themes/rrdtool/theme.php index eed2ac9a..68fc1850 100644 --- a/templates/themes/rrdtool/theme.php +++ b/templates/themes/rrdtool/theme.php @@ -1,7 +1,7 @@ <?php require 'info.php'; - function rrdtool_build($action, $settings) { + function rrdtool_build($action, $settings, $board) { // Possible values for $action: // - all (rebuild everything, initialization) // - news (news has been updated) diff --git a/templates/themes/sitemap/info.php b/templates/themes/sitemap/info.php new file mode 100644 index 00000000..1198c2e3 --- /dev/null +++ b/templates/themes/sitemap/info.php @@ -0,0 +1,53 @@ +<?php + $theme = Array(); + + // Theme name + $theme['name'] = 'Sitemap Generator'; + // Description (you can use Tinyboard markup here) + $theme['description'] = 'Generates an XML sitemap to help search engines find all threads and pages.'; + $theme['version'] = 'v1.0'; + + // Theme configuration + $theme['config'] = Array(); + + $theme['config'][] = Array( + 'title' => 'Sitemap Path', + 'name' => 'path', + 'type' => 'text', + 'default' => 'sitemap.xml', + 'size' => '20' + ); + + $theme['config'][] = Array( + 'title' => 'URL prefix', + 'name' => 'url', + 'type' => 'text', + 'comment' => '(with trailing slash)', + 'default' => 'http://' . (isset ($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : "localhost") . $config['root'], + 'size' => '20' + ); + + $theme['config'][] = Array( + 'title' => 'Thread change frequency', + 'name' => 'changefreq', + 'type' => 'text', + 'comment' => '(eg. "hourly", "daily", etc.)', + 'default' => 'hourly', + 'size' => '20' + ); + + $__boards = listBoards(); + $__default_boards = Array(); + foreach ($__boards as $__board) + $__default_boards[] = $__board['uri']; + + $theme['config'][] = Array( + 'title' => 'Boards', + 'name' => 'boards', + 'type' => 'text', + 'comment' => '(boards to include; space seperated)', + 'size' => 24, + 'default' => implode(' ', $__default_boards) + ); + + $theme['build_function'] = 'sitemap_build'; diff --git a/templates/themes/sitemap/sitemap.xml b/templates/themes/sitemap/sitemap.xml new file mode 100644 index 00000000..733da607 --- /dev/null +++ b/templates/themes/sitemap/sitemap.xml @@ -0,0 +1,19 @@ +{% filter remove_whitespace %} +<?xml version="1.0" encoding="UTF-8"?> +<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> + {% for board in boards %} + <url> + <loc>{{ settings.url ~ (config.board_path | format(board)) ~ config.file_index }}</loc> + </url> + {% endfor %} + {% for board, thread_list in threads %} + {% for thread in thread_list %} + <url> + <loc>{{ settings.url ~ (config.board_path | format(board)) ~ config.dir.res ~ (config.file_page | format(thread.thread_id)) }}</loc> + <lastmod>{{ thread.lastmod | date('%Y-%m-%dT%H:%M:%S') }}{{ timezone() }}</lastmod> + <changefreq>{{ settings.changefreq }}</changefreq> + </url> + {% endfor %} + {% endfor %} +</urlset> +{% endfilter %}
\ No newline at end of file diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php new file mode 100644 index 00000000..e210316b --- /dev/null +++ b/templates/themes/sitemap/theme.php @@ -0,0 +1,32 @@ +<?php + require 'info.php'; + + function sitemap_build($action, $settings, $board) { + global $config; + + // Possible values for $action: + // - all (rebuild everything, initialization) + // - news (news has been updated) + // - boards (board list changed) + // - post (a post has been made) + // - thread (a thread has been made) + + if ($action != 'post' && $action != 'post-thread') + return; + + $boards = explode(' ', $settings['boards']); + + $threads = array(); + + foreach ($boards as $board) { + $query = query(sprintf("SELECT `id` AS `thread_id`, (SELECT `time` FROM `posts_%s` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM `posts_%s` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); + $threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC); + } + + file_write($settings['path'], Element('themes/sitemap/sitemap.xml', Array( + 'settings' => $settings, + 'config' => $config, + 'threads' => $threads, + 'boards' => $boards, + ))); + } diff --git a/templates/themes/ukko/info.php b/templates/themes/ukko/info.php new file mode 100644 index 00000000..34d59d4e --- /dev/null +++ b/templates/themes/ukko/info.php @@ -0,0 +1,53 @@ +<?php + $theme = Array(); + + // Theme name + $theme['name'] = 'Ukko'; + // Description (you can use Tinyboard markup here) + $theme['description'] = 'Board with threads and messages from all boards'; + $theme['version'] = 'v0.1'; + + // Theme configuration + $theme['config'] = Array(); + + $theme['config'][] = Array( + 'title' => 'Board name', + 'name' => 'title', + 'type' => 'text', + 'default' => 'Ukko' + ); + $theme['config'][] = Array( + 'title' => 'Board URI', + 'name' => 'uri', + 'type' => 'text', + 'comment' => '(ukko for example)' + ); + $theme['config'][] = Array( + 'title' => 'Subtitle', + 'name' => 'subtitle', + 'type' => 'text', + 'comment' => '(%s = thread limit. for example "%s freshly bumped threads")' + ); + $theme['config'][] = Array( + 'title' => 'Excluded boards', + 'name' => 'exclude', + 'type' => 'text', + 'comment' => '(space seperated)' + ); + $theme['config'][] = Array( + 'title' => 'Number of threads', + 'name' => 'thread_limit', + 'type' => 'text', + 'default' => '15', + ); + // Unique function name for building everything + $theme['build_function'] = 'ukko_build'; + $theme['install_callback'] = 'ukko_install'; + + if(!function_exists('ukko_install')) { + function ukko_install($settings) { + if (!file_exists($settings['uri'])) + @mkdir($settings['uri'], 0777) or error("Couldn't create " . $settings['uri'] . ". Check permissions.", true); + } + } + diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php new file mode 100644 index 00000000..6fa5fa7e --- /dev/null +++ b/templates/themes/ukko/theme.php @@ -0,0 +1,111 @@ +<?php + require 'info.php'; + + function ukko_build($action, $settings) { + $ukko = new ukko(); + $ukko->settings = $settings; + $ukko->build(); + } + + class ukko { + public $settings; + public function build($mod = false) { + global $config; + $boards = listBoards(); + + $body = ''; + $overflow = array(); + $board = array( + 'url' => $this->settings['uri'], + 'name' => $this->settings['title'], + 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit']) + ); + + $query = ''; + foreach($boards as &$_board) { + if(in_array($_board['uri'], explode(' ', $this->settings['exclude']))) + continue; + $query .= sprintf("SELECT *, '%s' AS `board` FROM `posts_%s` WHERE `thread` IS NULL UNION ALL ", $_board['uri'], $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', 'ORDER BY `bump` DESC', $query); + $query = query($query) or error(db_error()); + + $count = 0; + $threads = array(); + while($post = $query->fetch()) { + + if(!isset($threads[$post['board']])) { + $threads[$post['board']] = 1; + } else { + $threads[$post['board']] += 1; + } + + if($count < $this->settings['thread_limit']) { + openBoard($post['board']); + $thread = new Thread( + $post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], + $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], + $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['sage'], $post['embed'], $mod ? '?/' : $config['root'], $mod + ); + + $posts = prepare(sprintf("SELECT * FROM `posts_%s` WHERE `thread` = :id ORDER BY `id` DESC LIMIT :limit", $post['board'])); + $posts->bindValue(':id', $post['id']); + $posts->bindValue(':limit', ($post['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']), PDO::PARAM_INT); + $posts->execute() or error(db_error($posts)); + + $num_images = 0; + while ($po = $posts->fetch()) { + if ($po['file']) + $num_images++; + + $thread->add(new Post( + $po['id'], $post['id'], $po['subject'], $po['email'], $po['name'], $po['trip'], $po['capcode'], $po['body'], $po['time'], + $po['thumb'], $po['thumbwidth'], $po['thumbheight'], $po['file'], $po['filewidth'], $po['fileheight'], $po['filesize'], + $po['filename'], $po['ip'], $po['embed'], $mod ? '?/' : $config['root'], $mod) + ); + + } + if ($posts->rowCount() == ($post['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) { + $ct = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM `posts_%s` WHERE `thread` = :thread UNION ALL SELECT COUNT(`id`) FROM `posts_%s` WHERE `file` IS NOT NULL AND `thread` = :thread", $post['board'], $post['board'])); + $ct->bindValue(':thread', $post['id'], PDO::PARAM_INT); + $ct->execute() or error(db_error($count)); + + $c = $ct->fetch(); + $thread->omitted = $c['num'] - ($post['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']); + + $c = $ct->fetch(); + $thread->omitted_images = $c['num'] - $num_images; + } + + + $thread->posts = array_reverse($thread->posts); + $body .= '<h2><a href="' . $config['root'] . $post['board'] . '">/' . $post['board'] . '/</a></h2>'; + $body .= $thread->build(true); + } else { + $page = 'index'; + if(floor($threads[$post['board']] / $config['threads_per_page']) > 0) { + $page = floor($threads[$post['board']] / $config['threads_per_page']) + 1; + } + $overflow[] = array('id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html'); + } + + $count += 1; + } + + $body .= '<script> var overflow = ' . json_encode($overflow) . '</script>'; + $body .= '<script type="text/javascript" src="ukko.js"></script>'; + + file_write($this->settings['uri'] . '/index.html', Element('index.html', array( + 'config' => $config, + 'board' => $board, + 'no_post_form' => true, + 'body' => $body, + 'boardlist' => createBoardlist($mod) + ))); + + file_write($this->settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); + } + + }; + +?> diff --git a/templates/themes/ukko/thumb.png b/templates/themes/ukko/thumb.png Binary files differnew file mode 100644 index 00000000..49c4237b --- /dev/null +++ b/templates/themes/ukko/thumb.png diff --git a/templates/themes/ukko/ukko.js b/templates/themes/ukko/ukko.js new file mode 100644 index 00000000..baf0f78d --- /dev/null +++ b/templates/themes/ukko/ukko.js @@ -0,0 +1,37 @@ +var cache = new Array(), + thread = false, + loading = false; +$(document).ready(function() { + $(window).on('scroll', function() { + if($(window).scrollTop() + $(window).height() + 100 > $(document).height() && !loading && overflow.length > 0) { + var page = '../' + overflow[0].board + '/' + overflow[0].page; + if($.inArray(page, cache) != -1) { + thread = $('div#thread_' + overflow[0].id); + if(thread.length > 0) { + thread.prepend('<h2><a href="/' + overflow[0].board + '/">/' + overflow[0].board + '/</a></h2>'); + $('div[id*="thread_"]').last().after(thread.attr('data-board', overflow[0].board).css('display', 'block')); + overflow.shift(); + } + } else { + loading = true; + $.get(page, function(data) { + cache.push(page); + + $(data).find('div[id*="thread_"]').each(function() { + $('body').prepend($(this).css('display', 'none').attr('data-board', overflow[0].board)); + }); + + thread = $('div#thread_' + overflow[0].id + '[data-board="' + overflow[0].board + '"]'); + if(thread.length > 0) { + thread.prepend('<h2><a href="/' + overflow[0].board + '/">/' + overflow[0].board + '/</a></h2>'); + $('div[id*="thread_"]').last().after(thread.attr('data-board', overflow[0].board).css('display', 'block')); + overflow.shift(); + } + + loading = false; + }); + } + } + }); + +});
\ No newline at end of file |
