diff options
| author | Simon McFarlane <simon@piston.pw> | 2015-05-26 23:31:47 -0700 |
|---|---|---|
| committer | Simon McFarlane <simon@piston.pw> | 2015-05-29 01:34:53 -0700 |
| commit | 4b40f69a4e6d190f6d342875bd084c2a6c9d8b0f (patch) | |
| tree | fcc5dc9efa24afcb0bda3740b59f0c4e81c42f62 /templates/themes | |
| parent | 2ac451ecb7aaae1ed1402425b8df6a5cb9831f2b (diff) | |
| parent | d20149b57929c27da87a7d9603d85717da15c5bc (diff) | |
Merge remote-tracking branch 'upstream/master' into vichan-merge
Diffstat (limited to 'templates/themes')
| -rw-r--r-- | templates/themes/basic/index.html | 2 | ||||
| -rw-r--r-- | templates/themes/catalog/catalog.html | 72 | ||||
| -rw-r--r-- | templates/themes/catalog/theme.php | 57 | ||||
| -rw-r--r-- | templates/themes/categories/news.html | 2 | ||||
| -rw-r--r-- | templates/themes/frameset/news.html | 2 | ||||
| -rw-r--r-- | templates/themes/public_banlist/info.php | 33 | ||||
| -rw-r--r-- | templates/themes/public_banlist/theme.php | 56 | ||||
| -rw-r--r-- | templates/themes/recent/recent.html | 2 | ||||
| -rw-r--r-- | templates/themes/recent/theme.php | 28 | ||||
| -rw-r--r-- | templates/themes/sitemap/sitemap.xml | 4 | ||||
| -rw-r--r-- | templates/themes/sitemap/theme.php | 47 | ||||
| -rw-r--r-- | templates/themes/ukko/info.php | 1 | ||||
| -rw-r--r-- | templates/themes/ukko/theme.php | 16 |
13 files changed, 233 insertions, 89 deletions
diff --git a/templates/themes/basic/index.html b/templates/themes/basic/index.html index 7bccdf4c..3e83f919 100644 --- a/templates/themes/basic/index.html +++ b/templates/themes/basic/index.html @@ -44,7 +44,7 @@ <p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> + <a href='https://int.vichan.net/devel/'>vichan</a> {{ config.version }} - <br><a href="http://tinyboard.org/">Tinyboard</a> Copyright © 2010-2014 Tinyboard Development Group - <br><a href="https://int.vichan.net/devel/">vichan</a> Copyright © 2012-2014 vichan-devel</p> + <br><a href="https://engine.vichan.net/">vichan</a> Copyright © 2012-2015 vichan-devel</p> </footer> </body> </html> diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html index 12b3cd98..92969b00 100644 --- a/templates/themes/catalog/catalog.html +++ b/templates/themes/catalog/catalog.html @@ -50,45 +50,53 @@ data-bump="{{ post.bump }}" data-time="{{ post.time }}" > - <div class="thread grid-li grid-size-small"> - <a href="{{post.link}}"> - {% if post.youtube %} - <img src="http://img.youtube.com/vi/{{ post.youtube }}/0.jpg" - {% else %} - <img src="{{post.file}}" - {% endif %} - id="img-{{ post.id }}" data-subject="{% if post.subject %}{{ post.subject|e }}{% endif %}" data-name="{{ post.name|e }}" data-muhdifference="{{ post.muhdifference }}" class="{{post.board}} thread-image" title="{{post.bump|date('%b %d %H:%M')}}"> - </a> - <div class="replies"> - <strong>R: {{ post.reply_count }} / I: {{ post.image_count }}</strong> - {% if post.subject %} - <p class="intro"> - <span class="subject"> - {{ post.subject|e }} - </span> - </p> - {% else %} - <br /> - {% endif %} - - {{ post.body }} - </div> - </div> - </li> - {% endfor %} - </ul> - </div> + <div class="thread grid-li grid-size-small"> + <a href="{{post.link}}"> + {% if post.youtube %} + <img src="//img.youtube.com/vi/{{ post.youtube }}/0.jpg" + {% else %} + <img src="{{post.file}}" + {% endif %} + id="img-{{ post.id }}" data-subject="{% if post.subject %}{{ post.subject|e }}{% endif %}" data-name="{{ post.name|e }}" data-muhdifference="{{ post.muhdifference }}" class="{{post.board}} thread-image" title="{{post.bump|date('%b %d %H:%M')}}"> + </a> + <div class="replies"> + <strong>R: {{ post.reply_count }} / I: {{ post.image_count }}</strong> + {% if post.subject %} + <p class="intro"> + <span class="subject"> + {{ post.subject|e }} + </span> + </p> + {% else %} + <br /> + {% endif %} + {{ post.body }} + </div> + </div> + </li> + {% endfor %} + </ul> + </div> + <hr/> <footer> <p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> + <a href='https://int.vichan.net/devel/'>vichan</a> {{ config.version }} - - <br><a href="http://tinyboard.org/">Tinyboard</a> Copyright © 2010-2014 Tinyboard Development Group - <br><a href="https://int.vichan.net/devel/">vichan</a> Copyright © 2012-2014 vichan-devel</p> + <br><a href="http://tinyboard.org/">Tinyboard</a> Copyright © 2010-2014 Tinyboard Development Group + <br><a href="https://engine.vichan.net/">vichan</a> Copyright © 2012-2015 vichan-devel</p> </footer> - <script type="text/javascript"> + <script type="text/javascript">{% raw %} + var styles = { + {% endraw %} + {% for name, uri in config.stylesheets %}{% raw %}'{% endraw %}{{ name|addslashes }}{% raw %}' : '{% endraw %}/stylesheets/{{ uri|addslashes }}{% raw %}', + {% endraw %}{% endfor %}{% raw %} + }; onready(init); + {% endraw %}</script> + + <script type="text/javascript">{% raw %} ready(); - </script> + {% endraw %}</script> </body> </html> {% endfilter %} diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index 357870e4..34b28e48 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -16,11 +16,22 @@ if ($action == 'all') { foreach ($boards as $board) { $b = new Catalog(); - $b->build($settings, $board); + if ($config['smart_build']) { + file_unlink($config['dir']['home'] . $board . '/catalog.html'); + } + else { + $b->build($settings, $board); + } } } elseif ($action == 'post-thread' || ($settings['update_on_posts'] && $action == 'post') || ($settings['update_on_posts'] && $action == 'post-delete') && in_array($board, $boards)) { $b = new Catalog(); - $b->build($settings, $board); + + if ($config['smart_build']) { + file_unlink($config['dir']['home'] . $board . '/catalog.html'); + } + else { + $b->build($settings, $board); + } } } @@ -28,8 +39,12 @@ class Catalog { public function build($settings, $board_name) { global $config, $board; - - openBoard($board_name); + + if ($board['uri'] != $board_name) { + if (!openBoard($board_name)) { + error(sprintf(_("Board %s doesn't exist"), $board_name)); + } + } $recent_images = array(); $recent_posts = array(); @@ -42,35 +57,37 @@ $board_name, $board_name, $board_name, $board_name, $board_name)) or error(db_error()); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { - $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])); + $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post); $post['board_name'] = $board['name']; if ($post['embed'] && preg_match('/^https?:\/\/(\w+\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9\-_]{10,11})(&.+)?$/i', $post['embed'], $matches)) { $post['youtube'] = $matches[2]; } - if (isset($post['files'])) { + if (isset($post['files']) && $post['files']) { $files = json_decode($post['files']); - if ($files[0]->file == 'deleted') { - if (count($files) > 1) { - foreach ($files as $file) { - if (($file == $files[0]) || ($file->file == 'deleted')) continue; - $post['file'] = $config['uri_thumb'] . $file->thumb; - } + if ($files[0]) { + if ($files[0]->file == 'deleted') { + if (count($files) > 1) { + foreach ($files as $file) { + if (($file == $files[0]) || ($file->file == 'deleted')) continue; + $post['file'] = $config['uri_thumb'] . $file->thumb; + } - if (empty($post['file'])) $post['file'] = $config['image_deleted']; + if (empty($post['file'])) $post['file'] = $config['image_deleted']; + } + else { + $post['file'] = $config['image_deleted']; + } + } + else if($files[0]->thumb == 'spoiler') { + $post['file'] = '/' . $config['spoiler_image']; } else { - $post['file'] = $config['image_deleted']; + $post['file'] = $config['uri_thumb'] . $files[0]->thumb; } } - else if($files[0]->thumb == 'spoiler') { - $post['file'] = '/' . $config['spoiler_image']; - } - else { - $post['file'] = $config['uri_thumb'] . $files[0]->thumb; - } } if (empty($post['image_count'])) $post['image_count'] = 0; diff --git a/templates/themes/categories/news.html b/templates/themes/categories/news.html index e75f9dea..95b330b6 100644 --- a/templates/themes/categories/news.html +++ b/templates/themes/categories/news.html @@ -35,7 +35,7 @@ <p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> + <a href='https://int.vichan.net/devel/'>vichan</a> {{ config.version }} - <br><a href="http://tinyboard.org/">Tinyboard</a> Copyright © 2010-2014 Tinyboard Development Group - <br><a href="https://int.vichan.net/devel/">vichan</a> Copyright © 2012-2014 vichan-devel</p> + <br><a href="https://engine.vichan.net/">vichan</a> Copyright © 2012-2015 vichan-devel</p> </footer> </body> </html> diff --git a/templates/themes/frameset/news.html b/templates/themes/frameset/news.html index 17290305..9f779b74 100644 --- a/templates/themes/frameset/news.html +++ b/templates/themes/frameset/news.html @@ -34,7 +34,7 @@ <p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> + <a href='https://int.vichan.net/devel/'>vichan</a> {{ config.version }} - <br><a href="http://tinyboard.org/">Tinyboard</a> Copyright © 2010-2014 Tinyboard Development Group - <br><a href="https://int.vichan.net/devel/">vichan</a> Copyright © 2012-2014 vichan-devel</p> + <br><a href="https://engine.vichan.net/">vichan</a> Copyright © 2012-2015 vichan-devel</p> </footer> </body> </html> diff --git a/templates/themes/public_banlist/info.php b/templates/themes/public_banlist/info.php new file mode 100644 index 00000000..006ac38e --- /dev/null +++ b/templates/themes/public_banlist/info.php @@ -0,0 +1,33 @@ +<?php + $theme = Array(); + + // Theme name + $theme['name'] = 'Public Banlist'; + // Description (you can use Tinyboard markup here) + $theme['description'] = +'Shows a public list of bans, that were issued on all boards. Basically, this theme +copies the banlist interface from moderation panel.'; + $theme['version'] = 'v0.1'; + + // Theme configuration + $theme['config'] = Array(); + + $theme['config'][] = Array( + 'title' => 'JSON feed file', + 'name' => 'file_json', + 'type' => 'text', + 'default' => 'bans.json', + 'comment' => '(eg. "bans.json")' + ); + + $theme['config'][] = Array( + 'title' => 'Main HTML file', + 'name' => 'file_bans', + 'type' => 'text', + 'default' => 'bans.html', + 'comment' => '(eg. "bans.html")' + ); + + // Unique function name for building everything + $theme['build_function'] = 'pbanlist_build'; +?> diff --git a/templates/themes/public_banlist/theme.php b/templates/themes/public_banlist/theme.php new file mode 100644 index 00000000..f2b65839 --- /dev/null +++ b/templates/themes/public_banlist/theme.php @@ -0,0 +1,56 @@ +<?php + require 'info.php'; + + function pbanlist_build($action, $settings, $board) { + // Possible values for $action: + // - all (rebuild everything, initialization) + // - news (news has been updated) + // - boards (board list changed) + // - bans (ban list changed) + + PBanlist::build($action, $settings); + } + + // Wrap functions in a class so they don't interfere with normal Tinyboard operations + class PBanlist { + public static function build($action, $settings) { + global $config; + + if ($action == 'all') + file_write($config['dir']['home'] . $settings['file_bans'], PBanlist::homepage($settings)); + + if ($action == 'all' || $action == 'bans') + file_write($config['dir']['home'] . $settings['file_json'], PBanlist::gen_json($settings)); + } + + public static function gen_json($settings) { + ob_start(); + Bans::stream_json(false, true, true, array()); + $out = ob_get_contents(); + ob_end_clean(); + return $out; + } + + // Build homepage + public static function homepage($settings) { + global $config; + + return Element('page.html', array( + 'config' => $config, + 'mod' => false, + 'hide_dashboard_link' => true, + 'title' => _("Ban list"), + 'subtitle' => "", + 'nojavascript' => true, + 'body' => Element('mod/ban_list.html', array( + 'mod' => false, + 'boards' => "[]", + 'token' => false, + 'token_json' => false, + 'uri_json' => $config['dir']['home'] . $settings['file_json'], + )) + )); + } + }; + +?> diff --git a/templates/themes/recent/recent.html b/templates/themes/recent/recent.html index 03fe9ecb..e1743ad8 100644 --- a/templates/themes/recent/recent.html +++ b/templates/themes/recent/recent.html @@ -61,7 +61,7 @@ <p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> + <a href='https://int.vichan.net/devel/'>vichan</a> {{ config.version }} - <br><a href="http://tinyboard.org/">Tinyboard</a> Copyright © 2010-2014 Tinyboard Development Group - <br><a href="https://int.vichan.net/devel/">vichan</a> Copyright © 2012-2014 vichan-devel</p> + <br><a href="https://engine.vichan.net/">vichan</a> Copyright © 2012-2015 vichan-devel</p> </footer> </body> </html> diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index ad6f99e4..f44e2529 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -24,8 +24,14 @@ $this->excluded = explode(' ', $settings['exclude']); - if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') - file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); + if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') { + if ($config['smart_build']) { + file_unlink($config['dir']['home'] . $settings['html']); + } + else { + file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); + } + } } // Build news page @@ -62,7 +68,7 @@ // board settings won't be available in the template file, so generate links now $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] - . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])) . '#' . $post['id']; + . link_for($post) . '#' . $post['id']; if ($files) { if ($files[0]->thumb == 'spoiler') { @@ -92,7 +98,7 @@ while ($post = $query->fetch(PDO::FETCH_ASSOC)) { openBoard($post['board']); - $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])) . '#' . $post['id']; + $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post) . '#' . $post['id']; if ($post['body'] != "") $post['snippet'] = pm_snippet($post['body'], 30); else @@ -124,15 +130,21 @@ $query = query($query) or error(db_error()); $stats['unique_posters'] = number_format($query->fetchColumn()); - /*$query = 'SELECT SUM(`filesize`) FROM ('; + // Active content + $query = 'SELECT DISTINCT(`files`) FROM ('; foreach ($boards as &$_board) { if (in_array($_board['uri'], $this->excluded)) continue; - $query .= sprintf("SELECT `filesize` FROM ``posts_%s`` UNION ALL ", $_board['uri']); + $query .= sprintf("SELECT `files` FROM ``posts_%s`` UNION ALL ", $_board['uri']); } - $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); + $query = preg_replace('/UNION ALL $/', ' WHERE `num_files` > 0) AS `posts_all`', $query); $query = query($query) or error(db_error()); - $stats['active_content'] = $query->fetchColumn();*/ + $files = $query->fetchAll(); + $stats['active_content'] = 0; + foreach ($files as &$file) { + preg_match_all('/"size":([0-9]*)/', $file[0], $matches); + $stats['active_content'] += array_sum($matches[1]); + } return Element('themes/recent/recent.html', Array( 'settings' => $settings, diff --git a/templates/themes/sitemap/sitemap.xml b/templates/themes/sitemap/sitemap.xml index 733da607..95dfdd26 100644 --- a/templates/themes/sitemap/sitemap.xml +++ b/templates/themes/sitemap/sitemap.xml @@ -9,11 +9,11 @@ {% 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> + <loc>{{ settings.url ~ (config.board_path | format(board)) ~ config.dir.res ~ link_for(thread) }}</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 +{% endfilter %} diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php index 3e048dd5..52779d53 100644 --- a/templates/themes/sitemap/theme.php +++ b/templates/themes/sitemap/theme.php @@ -10,30 +10,37 @@ // - boards (board list changed) // - post (a post has been made) // - thread (a thread has been made) + + if ($action != 'all') { + if ($action != 'post-thread' && $action != 'post-delete') + return; - if ($action != 'post-thread' && $action != 'post-delete') - return; - - if (isset($settings['regen_time']) && $settings['regen_time'] > 0) { - if ($last_gen = @filemtime($settings['path'])) { - if (time() - $last_gen < (int)$settings['regen_time']) - return; // Too soon + if (isset($settings['regen_time']) && $settings['regen_time'] > 0) { + if ($last_gen = @filemtime($settings['path'])) { + if (time() - $last_gen < (int)$settings['regen_time']) + return; // Too soon + } } } + + if ($config['smart_build']) { + file_unlink($settings['path']); + } + else { + $boards = explode(' ', $settings['boards']); - $boards = explode(' ', $settings['boards']); - - $threads = array(); + $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); - } + foreach ($boards as $board) { + $query = query(sprintf("SELECT `id`, `id` AS `thread_id`, `slug`, (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, - ))); + 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 index 45a687fc..9a0a53e6 100644 --- a/templates/themes/ukko/info.php +++ b/templates/themes/ukko/info.php @@ -49,6 +49,7 @@ function ukko_install($settings) { if (!file_exists($settings['uri'])) @mkdir($settings['uri'], 0777) or error("Couldn't create " . $settings['uri'] . ". Check permissions.", true); + file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); } } diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index b2624ed7..d6fc303c 100644 --- a/templates/themes/ukko/theme.php +++ b/templates/themes/ukko/theme.php @@ -2,11 +2,21 @@ require 'info.php'; function ukko_build($action, $settings) { + global $config; + $ukko = new ukko(); $ukko->settings = $settings; - - file_write($settings['uri'] . '/index.html', $ukko->build()); - file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); + + if (! ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete')) { + return; + } + + if ($config['smart_build']) { + file_unlink($settings['uri'] . '/index.html'); + } + else { + file_write($settings['uri'] . '/index.html', $ukko->build()); + } } class ukko { |
