diff options
Diffstat (limited to 'templates/themes')
| -rw-r--r-- | templates/themes/basic/index.html | 10 | ||||
| -rw-r--r-- | templates/themes/catalog/catalog.html | 28 | ||||
| -rw-r--r-- | templates/themes/catalog/index.rss | 19 | ||||
| -rw-r--r-- | templates/themes/catalog/theme.php | 40 | ||||
| -rw-r--r-- | templates/themes/categories/news.html | 8 | ||||
| -rw-r--r-- | templates/themes/frameset/news.html | 8 | ||||
| -rw-r--r-- | templates/themes/recent/recent.html | 2 | ||||
| -rw-r--r-- | templates/themes/recent/theme.php | 7 | ||||
| -rwxr-xr-x | templates/themes/rss/info.php | 61 | ||||
| -rw-r--r-- | templates/themes/rss/rss.xml | 28 | ||||
| -rwxr-xr-x | templates/themes/rss/theme.php | 124 | ||||
| -rw-r--r-- | templates/themes/sitemap/theme.php | 6 | ||||
| -rw-r--r-- | templates/themes/ukko/theme.php | 6 |
13 files changed, 302 insertions, 45 deletions
diff --git a/templates/themes/basic/index.html b/templates/themes/basic/index.html index 3e83f919..ad5b92ca 100644 --- a/templates/themes/basic/index.html +++ b/templates/themes/basic/index.html @@ -12,7 +12,7 @@ <!--{% if config.default_stylesheet.1 != '' %}<link rel="stylesheet" type="text/css" id="stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_stylesheet.1 }}">{% endif %}--> {% if config.font_awesome %}<link rel="stylesheet" href="{{ config.root }}{{ config.font_awesome_css }}">{% endif %} </head> -<body> +<body class="8chan vichan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %}" data-stylesheet="{% if config.default_stylesheet.1 != '' %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}"> <div class="bar top"> {{ boardlist.top }} </div> @@ -41,10 +41,10 @@ <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://engine.vichan.net/">vichan</a> Copyright © 2012-2015 vichan-devel</p> + <p class="unimportant" style="margin-top:20px;text-align:center;">- Tinyboard + + <a href="https://engine.vichan.net/">vichan</a> {{ config.version }} - + <br>Tinyboard Copyright © 2010-2014 Tinyboard Development Group + <br><a href="https://engine.vichan.net/">vichan</a> Copyright © 2012-2016 vichan-devel</p> </footer> </body> </html> diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html index f23298bf..e556b4a9 100644 --- a/templates/themes/catalog/catalog.html +++ b/templates/themes/catalog/catalog.html @@ -4,12 +4,12 @@ <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <script type='text/javascript'> - active_page = "catalog"; + var active_page = "catalog" + , board_name = "{{ board }}"; </script> {% include 'header.html' %} - <title>{{ settings.title }} (/{{ board }}/)</title> </head> -<body class="theme-catalog board-{{ board }}"> +<body class="8chan vichan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %} theme-catalog active-catalog" data-stylesheet="{% if config.default_stylesheet.1 != '' %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}"> <div class="top bar topbar"> {{ boardlist.top }} </div> @@ -42,14 +42,16 @@ </select> </div> - <div class="threads"> - <ul id="Grid"> - {% for post in recent_posts %} - <li class="mix" + <div class="threads"> + <div id="Grid"> + {% for post in recent_posts %} + <div class="mix" data-reply="{{ post.reply_count }}" - data-bump="{{ post.bump }}" - data-time="{{ post.time }}" - data-board="{{ post.board }}" + data-bump="{{ post.bump }}" + data-time="{{ post.time }}" + data-id="{{ post.id }}" + data-sticky="{% if post.sticky %}true{% else %}false{% endif %}" + data-locked="{% if post.locked %}true{% else %}false{% endif %}" > <div class="thread grid-li grid-size-small"> <a href="{{post.link}}"> @@ -61,7 +63,7 @@ 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> + <strong>R: {{ post.reply_count }} / I: {{ post.image_count }}{% if post.sticky %} (sticky){% endif %}</strong> {% if post.subject %} <p class="intro"> <span class="subject"> @@ -75,9 +77,9 @@ {{ post.body }} </div> </div> - </li> + </div> {% endfor %} - </ul> + </div> </div> <hr/> diff --git a/templates/themes/catalog/index.rss b/templates/themes/catalog/index.rss new file mode 100644 index 00000000..e6576ffc --- /dev/null +++ b/templates/themes/catalog/index.rss @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> +<channel> + <title>/{{ board.uri }}/ - {{ board.title|e }}</title> + <link>{{ config.root }}{{ board.uri }}/</link> + <description>Live feed of new threads on the board /{{ board.uri }}/ - {{ board.title|e }}.</description> + <atom:link href="{{ config.root }}{{ board.uri }}/index.rss" rel="self" type="application/rss+xml"/> + {% for post in recent_posts %} + <item> + <title>{% if post.subject %}{{ post.subject|e }}{% else %}{{ post.body_nomarkup[:256]|remove_modifiers|e }}{% endif %}</title> + <link>{{ config.root }}{{ board.uri }}/res/{{ post.id }}.html</link> + <guid>{{ config.root }}{{ board.uri }}/res/{{ post.id }}.html</guid> + <comments>{{ config.root }}{{ board.uri }}/res/{{ post.id }}.html</comments> + <pubDate>{{ post.pubdate }}</pubDate> + <description><![CDATA[ <a href='{{ config.root }}{{ board.uri }}/res/{{ post.id }}.html' target=_blank><img style='float:left;margin:8px' border=0 src='{% if not config.uri_thumb %}{{ config.root }}{% endif %}{{ post.file }}'></a> {{ post.body }} ]]></description> + </item> + {% endfor %} +</channel> +</rss> diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index 1199b54a..24cdcbb8 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -15,23 +15,30 @@ // - post-thread (a thread has been made) if ($action === 'all') { foreach ($boards as $board) { - if ($config['smart_build']) { + $b = new Catalog(); + + $action = generation_strategy("sb_catalog", array($board)); + if ($action == 'delete') { file_unlink($config['dir']['home'] . $board . '/catalog.html'); - } else { - $b->build($board); + file_unlink($config['dir']['home'] . $board . '/index.rss'); + } + elseif ($action == 'rebuild') { + $b->build($settings, $board); } } - } elseif (in_array($board, $boards) && - $action == 'post-thread' || - ($settings['update_on_posts'] && $action == 'post') || - ($settings['update_on_posts'] && $action == 'post-delete')) - { - if ($config['smart_build']) { + } elseif ($action == 'post-thread' || ($settings['update_on_posts'] && $action == 'post') || ($settings['update_on_posts'] && $action == 'post-delete') && in_array($board, $boards)) { + $b = new Catalog(); + + $action = generation_strategy("sb_catalog", array($board)); + if ($action == 'delete') { file_unlink($config['dir']['home'] . $board . '/catalog.html'); - } else { - $b->build($board); + file_unlink($config['dir']['home'] . $board . '/index.rss'); } - } + elseif ($action == 'rebuild') { + $b->build($settings, $board); + } + + } // FIXME: Check that Ukko is actually enabled if ($settings['enable_ukko'] && ( @@ -210,10 +217,13 @@ $post['file'] = $config['uri_thumb'] . $files[0]->thumb; } } + } else { + $post['file'] = $config['root'] . $config['image_deleted']; } if (empty($post['image_count'])) $post['image_count'] = 0; + $post['pubdate'] = date('r', $post['time']); $posts[] = $post; } @@ -247,5 +257,11 @@ 'board' => $board_name, 'link' => $board_link ))); + + file_write($config['dir']['home'] . $board_name . '/index.rss', Element('themes/catalog/index.rss', Array( + 'config' => $config, + 'recent_posts' => $recent_posts, + 'board' => $board + ))); } } diff --git a/templates/themes/categories/news.html b/templates/themes/categories/news.html index 95b330b6..4ce65128 100644 --- a/templates/themes/categories/news.html +++ b/templates/themes/categories/news.html @@ -32,10 +32,10 @@ </div> <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://engine.vichan.net/">vichan</a> Copyright © 2012-2015 vichan-devel</p> + <p class="unimportant" style="margin-top:20px;text-align:center;">- Tinyboard + + <a href="https://engine.vichan.net/">vichan</a> {{ config.version }} - + <br>Tinyboard Copyright © 2010-2014 Tinyboard Development Group + <br><a href="https://engine.vichan.net/">vichan</a> Copyright © 2012-2016 vichan-devel</p> </footer> </body> </html> diff --git a/templates/themes/frameset/news.html b/templates/themes/frameset/news.html index 9f779b74..320c64d3 100644 --- a/templates/themes/frameset/news.html +++ b/templates/themes/frameset/news.html @@ -31,10 +31,10 @@ </div> <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://engine.vichan.net/">vichan</a> Copyright © 2012-2015 vichan-devel</p> + <p class="unimportant" style="margin-top:20px;text-align:center;">- Tinyboard + + <a href="https://engine.vichan.net/">vichan</a> {{ config.version }} - + <br>Tinyboard Copyright © 2010-2014 Tinyboard Development Group + <br><a href="https://engine.vichan.net/">vichan</a> Copyright © 2012-2016 vichan-devel</p> </footer> </body> </html> diff --git a/templates/themes/recent/recent.html b/templates/themes/recent/recent.html index 763f8bec..f0276ac7 100644 --- a/templates/themes/recent/recent.html +++ b/templates/themes/recent/recent.html @@ -9,6 +9,8 @@ <link rel="stylesheet" media="screen" href="https://lainchan.org/stylesheets/font-awesome/css/font-awesome.min.css"/> {% if config.url_favicon %}<link rel="shortcut icon" href="{{ config.url_favicon }}" />{% endif %} + {% if config.default_stylesheet.1 != '' %}<link rel="stylesheet" type="text/css" id="stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_stylesheet.1 }}">{% endif %} + {% if config.font_awesome %}<link rel="stylesheet" href="{{ config.root }}{{ config.font_awesome_css }}">{% endif %} </head> <body> <div class="bar top"> diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index f44e2529..a826048f 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -25,10 +25,11 @@ $this->excluded = explode(' ', $settings['exclude']); if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') { - if ($config['smart_build']) { + $action = generation_strategy('sb_recent', array()); + if ($action == 'delete') { file_unlink($config['dir']['home'] . $settings['html']); } - else { + elseif ($action == 'rebuild') { file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); } } @@ -64,7 +65,7 @@ if (isset($post['files'])) $files = json_decode($post['files']); - if ($files[0]->file == 'deleted') continue; + if ($files[0]->file == 'deleted' || $files[0]->thumb == 'file') continue; // board settings won't be available in the template file, so generate links now $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] diff --git a/templates/themes/rss/info.php b/templates/themes/rss/info.php new file mode 100755 index 00000000..14b39eb9 --- /dev/null +++ b/templates/themes/rss/info.php @@ -0,0 +1,61 @@ +<?php + $theme = Array(); + + // Theme name + $theme['name'] = 'RSS'; + // Description (you can use Tinyboard markup here) + $theme['description'] = 'Show recent posts and images as a RSS'; + $theme['version'] = 'v0.1'; + + // Theme configuration + $theme['config'] = Array(); + + $theme['config'][] = Array( + 'title' => 'Title', + 'name' => 'title', + 'type' => 'text', + 'default' => 'Recent Posts RSS' + ); + + $theme['config'][] = Array( + 'title' => 'Excluded boards', + 'name' => 'exclude', + 'type' => 'text', + 'comment' => '(space seperated)' + ); + + $theme['config'][] = Array( + 'title' => '# of recent posts', + 'name' => 'limit_posts', + 'type' => 'text', + 'default' => '30', + 'comment' => '(maximum posts to display)' + ); + + $theme['config'][] = Array( + 'title' => 'XML file', + 'name' => 'xml', + 'type' => 'text', + 'default' => 'recent.xml', + 'comment' => '(eg. "recent.xml")' + ); + + $theme['config'][] = Array( + 'title' => 'Base URL', + 'name' => 'base_url', + 'type' => 'text', + 'default' => 'http://test.com', + 'comment' => '(eg. "http://test.com")' + ); + + // Unique function name for building everything + $theme['build_function'] = 'rss_recentposts_build'; + $theme['install_callback'] = 'rss_recentposts_install'; + + if (!function_exists('rss_recentposts_install')) { + function rss_recentposts_install($settings) { + if (!is_numeric($settings['limit_posts']) || $settings['limit_posts'] < 0) + return Array(false, '<strong>' . utf8tohtml($settings['limit_posts']) . '</strong> is not a non-negative integer.'); + } + } + diff --git a/templates/themes/rss/rss.xml b/templates/themes/rss/rss.xml new file mode 100644 index 00000000..30fdb473 --- /dev/null +++ b/templates/themes/rss/rss.xml @@ -0,0 +1,28 @@ +{% filter remove_whitespace %} +<?xml version="1.0" encoding="utf-8"?> +<rss xmlns:dc="http://purl.org/dc/elements/1.1/" + version="2.0"> + <channel> + <description> + <![CDATA[{{ settings.subtitle }}]]> + </description> + <title>{{ settings.title }}</title> + <generator>Tinyboard {{ config.version }}</generator> + <link>{{ settings.base_url }}{{ config.root }}{{ settings.html }}</link> + {% for post in recent_posts %} + <item> + <title>{{ post.board_name }}</title> + <description> + <![CDATA[ + <a href="{{ settings.base_url }}{{ post.link }}"> + {{ post.snippet }} + </a> + ]]> + </description> + <link>{{ settings.base_url }}{{ post.link }}</link> + <guid>{{ settings.base_url }}{{ post.link }}</guid> + </item> + {% endfor %} + </channel> +</rss> +{% endfilter %} diff --git a/templates/themes/rss/theme.php b/templates/themes/rss/theme.php new file mode 100755 index 00000000..33c1b210 --- /dev/null +++ b/templates/themes/rss/theme.php @@ -0,0 +1,124 @@ +<?php + require 'info.php'; + + function rss_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 RSSRecentPosts(); + $b->build($action, $settings); + } + + // Wrap functions in a class so they don't interfere with normal Tinyboard operations + class RSSRecentPosts { + public function build($action, $settings) { + global $config, $_theme; + + /*if ($action == 'all') { + copy('templates/themes/recent/' . $settings['basecss'], $config['dir']['home'] . $settings['css']); + }*/ + + $this->excluded = explode(' ', $settings['exclude']); + + if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') + file_write($config['dir']['home'] . $settings['xml'], $this->homepage($settings)); + } + + // Build news page + public function homepage($settings) { + global $config, $board; + + //$recent_images = Array(); + $recent_posts = Array(); + //$stats = Array(); + + $boards = listBoards(); + + /*$query = ''; + foreach ($boards as &$_board) { + if (in_array($_board['uri'], $this->excluded)) + continue; + $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `file` IS NOT NULL AND `file` != 'deleted' AND `thumb` != 'spoiler' UNION ALL ", $_board['uri'], $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_images'], $query); + $query = query($query) or error(db_error()); + + while ($post = $query->fetch(PDO::FETCH_ASSOC)) { + openBoard($post['board']); + + // 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']; + $post['src'] = $config['uri_thumb'] . $post['thumb']; + + //$recent_images[] = $post; + }*/ + + + $query = ''; + foreach ($boards as &$_board) { + if (in_array($_board['uri'], $this->excluded)) + continue; + $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` UNION ALL ", $_board['uri'], $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT ' . (int)$settings['limit_posts'], $query); + $query = query($query) or error(db_error()); + + 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['snippet'] = pm_snippet($post['body'], 30); + $post['board_name'] = $board['name']; + + $recent_posts[] = $post; + } + + // Total posts + /*$query = 'SELECT SUM(`top`) FROM ('; + foreach ($boards as &$_board) { + if (in_array($_board['uri'], $this->excluded)) + continue; + $query .= sprintf("SELECT MAX(`id`) AS `top` FROM ``posts_%s`` UNION ALL ", $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); + $query = query($query) or error(db_error());*/ + //$stats['total_posts'] = number_format($query->fetchColumn()); + + // Unique IPs + /*$query = 'SELECT COUNT(DISTINCT(`ip`)) FROM ('; + foreach ($boards as &$_board) { + if (in_array($_board['uri'], $this->excluded)) + continue; + $query .= sprintf("SELECT `ip` FROM ``posts_%s`` UNION ALL ", $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); + $query = query($query) or error(db_error()); + //$stats['unique_posters'] = number_format($query->fetchColumn());*/ + + // Active content + /*$query = 'SELECT SUM(`filesize`) 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 = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); + $query = query($query) or error(db_error()); + //$stats['active_content'] = $query->fetchColumn();*/ + + return Element('themes/rss/rss.xml', Array( + 'settings' => $settings, + 'config' => $config, + //'boardlist' => createBoardlist(), + //'recent_images' => $recent_images, + 'recent_posts' => $recent_posts, + //'stats' => $stats + )); + } + }; + +?> diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php index 52779d53..6bc035bb 100644 --- a/templates/themes/sitemap/theme.php +++ b/templates/themes/sitemap/theme.php @@ -23,10 +23,12 @@ } } - if ($config['smart_build']) { + $action = generation_strategy('sb_sitemap', array()); + + if ($action == 'delete') { file_unlink($settings['path']); } - else { + elseif ($action == 'rebuild') { $boards = explode(' ', $settings['boards']); $threads = array(); diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index 92dfb317..ee2707bf 100644 --- a/templates/themes/ukko/theme.php +++ b/templates/themes/ukko/theme.php @@ -11,10 +11,12 @@ return; } - if ($config['smart_build']) { + $action = generation_strategy('sb_ukko', array()); + + if ($action == 'delete') { file_unlink($settings['uri'] . '/index.html'); } - else { + elseif ($action == 'rebuild') { file_write($settings['uri'] . '/index.html', $ukko->build()); } } |
