From 61d2729a40e8249fef8b3c0c584a9b5f7ae0777c Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 2 Apr 2015 20:54:28 +0200 Subject: [PATCH] themes can use smart_build now --- templates/themes/catalog/theme.php | 23 +++++++++++++++++++---- templates/themes/recent/theme.php | 10 ++++++++-- templates/themes/ukko/theme.php | 10 +++++++++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index f8f1146e..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(); diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index ce64c80e..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 diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index 058fc77b..e1fa0a3f 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,7 +11,13 @@ return; } - file_write($settings['uri'] . '/index.html', $ukko->build()); + if ($config['smart_build']) { + file_unlink($settings['uri'] . '/index.html'); + } + else { + file_write($settings['uri'] . '/index.html', $ukko->build()); + } + file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); }