summaryrefslogtreecommitdiff
path: root/templates/themes
diff options
context:
space:
mode:
authorczaks <marcin@6irc.net>2016-02-09 12:37:03 +0100
committerczaks <marcin@6irc.net>2016-02-09 12:37:03 +0100
commitc53f13bf90716461780fef0a2b4b6e2b5b3cb002 (patch)
tree5cd18f303da0b0e6fdc87f175adf5f5f86d881e2 /templates/themes
parentfe66c51a19920378885fb790d341cc50c933b046 (diff)
parent028fd3df15b2e2edc96c5b84156b0b039ea16562 (diff)
Merge branch 'master' of https://github.com/vichan-devel/vichan
Diffstat (limited to 'templates/themes')
-rw-r--r--templates/themes/basic/index.html2
-rw-r--r--templates/themes/catalog/catalog.html4
-rw-r--r--templates/themes/catalog/theme.php25
-rw-r--r--templates/themes/categories/news.html2
-rw-r--r--templates/themes/frameset/news.html2
-rw-r--r--templates/themes/recent/recent.html2
-rw-r--r--templates/themes/recent/theme.php23
-rwxr-xr-xtemplates/themes/rss/info.php61
-rw-r--r--templates/themes/rss/rss.xml28
-rwxr-xr-xtemplates/themes/rss/theme.php124
-rw-r--r--templates/themes/sitemap/theme.php47
-rw-r--r--templates/themes/ukko/info.php1
-rw-r--r--templates/themes/ukko/theme.php10
13 files changed, 292 insertions, 39 deletions
diff --git a/templates/themes/basic/index.html b/templates/themes/basic/index.html
index 3376a68f..0804faf7 100644
--- a/templates/themes/basic/index.html
+++ b/templates/themes/basic/index.html
@@ -41,7 +41,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 &copy; 2010-2014 Tinyboard Development Group
- <br><a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel</p>
+ <br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel</p>
</footer>
</body>
</html>
diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html
index aef6c139..381b1924 100644
--- a/templates/themes/catalog/catalog.html
+++ b/templates/themes/catalog/catalog.html
@@ -48,7 +48,7 @@
<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"
+ <img src="//img.youtube.com/vi/{{ post.youtube }}/0.jpg"
{% else %}
<img src="{{post.file}}"
{% endif %}
@@ -79,7 +79,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 &copy; 2010-2014 Tinyboard Development Group
- <br><a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel</p>
+ <br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel</p>
</footer>
<script type="text/javascript">{% raw %}
var styles = {
diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php
index b3b7caf7..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,7 +57,7 @@
$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'] . link_for($post));
+ $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)) {
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 &copy; 2010-2014 Tinyboard Development Group
- <br><a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel</p>
+ <br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 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 &copy; 2010-2014 Tinyboard Development Group
- <br><a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel</p>
+ <br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel</p>
</footer>
</body>
</html>
diff --git a/templates/themes/recent/recent.html b/templates/themes/recent/recent.html
index b807515b..31c839e7 100644
--- a/templates/themes/recent/recent.html
+++ b/templates/themes/recent/recent.html
@@ -56,7 +56,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 &copy; 2010-2014 Tinyboard Development Group
- <br><a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel</p>
+ <br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel</p>
</footer>
</body>
</html>
diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php
index 2ea6a7b9..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
@@ -125,15 +131,20 @@
$stats['unique_posters'] = number_format($query->fetchColumn());
// Active content
- /*$query = 'SELECT SUM(`filesize`) FROM (';
+ $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/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 1cebcdb6..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`, `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);
- }
+ 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 058fc77b..d6fc303c 100644
--- a/templates/themes/ukko/theme.php
+++ b/templates/themes/ukko/theme.php
@@ -2,6 +2,8 @@
require 'info.php';
function ukko_build($action, $settings) {
+ global $config;
+
$ukko = new ukko();
$ukko->settings = $settings;
@@ -9,8 +11,12 @@
return;
}
- file_write($settings['uri'] . '/index.html', $ukko->build());
- file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array()));
+ if ($config['smart_build']) {
+ file_unlink($settings['uri'] . '/index.html');
+ }
+ else {
+ file_write($settings['uri'] . '/index.html', $ukko->build());
+ }
}
class ukko {