summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/index.html9
-rw-r--r--templates/themes/catalog/info.php7
-rw-r--r--templates/themes/catalog/theme.php47
-rw-r--r--templates/themes/rand/theme.php1
-rw-r--r--templates/themes/semirand/theme.php1
-rw-r--r--templates/themes/ukko/theme.php1
6 files changed, 64 insertions, 2 deletions
diff --git a/templates/index.html b/templates/index.html
index 1878d455..2241b13c 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -58,6 +58,11 @@
{% if config.global_message %}<hr /><div class="blotter">{{ config.global_message }}</div>{% endif %}
<hr />
+ {% if config.catalog_link %}
+ | <a href="{{ config.root }}{{ board.dir }}{{ config.catalog_link }}">Catalog</a>
+ {% endif %}
+ <hr />
+
<form name="postcontrols" action="{{ config.post_url }}" method="post">
<input type="hidden" name="board" value="{{ board.uri }}" />
{% if mod %}<input type="hidden" name="mod" value="1" />{% endif %}
@@ -72,8 +77,8 @@
<a href='https://int.vichan.net/devel/'>vichan</a> +
<a href='https://github.com/lainchan/lainchan'>lainchan</a> {{ config.version }} -
<br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
- <br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel
- <br><a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2015 lainchan Administration</p>
+ <br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2016 vichan-devel
+ <br><a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2016 lainchan Administration</p>
{% for footer in config.footer %}<p class="unimportant" style="text-align:center;">{{ footer }}</p>{% endfor %}
</footer>
diff --git a/templates/themes/catalog/info.php b/templates/themes/catalog/info.php
index e2b13307..66c45082 100644
--- a/templates/themes/catalog/info.php
+++ b/templates/themes/catalog/info.php
@@ -47,6 +47,13 @@
);
$theme['config'][] = Array(
+ 'title' => 'Enable Rand catalog',
+ 'name' => 'enable_rand',
+ 'type' => 'checkbox',
+ 'default' => false,
+ 'comment' => 'Enable catalog for the Rand theme. This requires the Rand theme to be enabled.'
+ );
+ $theme['config'][] = Array(
'title' => 'Use tooltipster',
'name' => 'use_tooltipster',
'type' => 'checkbox',
diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php
index 9ecdb9d1..1199b54a 100644
--- a/templates/themes/catalog/theme.php
+++ b/templates/themes/catalog/theme.php
@@ -40,6 +40,14 @@
{
$b->buildUkko();
}
+
+ // FIXME: Check that Rand is actually enabled
+ if ($settings['enable_rand'] && (
+ $action === 'all' || $action === 'post' ||
+ $action === 'post-thread' || $action === 'post-delete'))
+ {
+ $b->buildRand();
+ }
}
// Wrap functions in a class so they don't interfere with normal Tinyboard operations
@@ -90,6 +98,45 @@
$this->saveForBoard($ukkoSettings['uri'], $recent_posts,
$config['root'] . $ukkoSettings['uri']);
}
+
+ /**
+ * Build and save the HTML of the catalog for the Rand theme
+ */
+ public function buildRand() {
+ global $config;
+
+ $randSettings = themeSettings('rand');
+ $queries = array();
+ $threads = array();
+
+ $exclusions = explode(' ', $randSettings['exclude']);
+ $boards = array_diff(listBoards(true), $exclusions);
+
+ foreach ($boards as $b) {
+ if (array_key_exists($b, $this->threadsCache)) {
+ $threads = array_merge($threads, $this->threadsCache[$b]);
+ } else {
+ $queries[] = $this->buildThreadsQuery($b);
+ }
+ }
+
+ // Fetch threads from boards that haven't beenp processed yet
+ if (!empty($queries)) {
+ $sql = implode(' UNION ALL ', $queries);
+ $res = query($sql) or error(db_error());
+ $threads = array_merge($threads, $res->fetchAll(PDO::FETCH_ASSOC));
+ }
+
+ // Sort in bump order
+ usort($threads, function($a, $b) {
+ return strcmp($b['bump'], $a['bump']);
+ });
+ // Generate data for the template
+ $recent_posts = $this->generateRecentPosts($threads);
+
+ $this->saveForBoard($randSettings['uri'], $recent_posts,
+ $config['root'] . $randSettings['uri']);
+ }
/**
* Build and save the HTML of the catalog for the given board
diff --git a/templates/themes/rand/theme.php b/templates/themes/rand/theme.php
index b4cfb4ff..e3814c4e 100644
--- a/templates/themes/rand/theme.php
+++ b/templates/themes/rand/theme.php
@@ -18,6 +18,7 @@
$body = '';
$overflow = array();
$board = array(
+ 'dir' => $this->settings['uri'] . "/",
'url' => $this->settings['uri'],
'name' => $this->settings['title'],
'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit'])
diff --git a/templates/themes/semirand/theme.php b/templates/themes/semirand/theme.php
index 1acecbfb..e8d3e56c 100644
--- a/templates/themes/semirand/theme.php
+++ b/templates/themes/semirand/theme.php
@@ -225,6 +225,7 @@
return Element('index.html', array(
'config' => $config,
'board' => array(
+ 'dir' => $this->settings['uri'] . "/",
'url' => $this->settings['uri'],
'title' => $this->settings['title'],
'subtitle' => str_replace('%s', $this->settings['thread_limit'],
diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php
index 05525299..92dfb317 100644
--- a/templates/themes/ukko/theme.php
+++ b/templates/themes/ukko/theme.php
@@ -28,6 +28,7 @@
$body = '';
$overflow = array();
$board = array(
+ 'dir' => $this->settings['uri'] . "/",
'url' => $this->settings['uri'],
'uri' => $this->settings['uri'],
'name' => $this->settings['title'],