Browse Source

themes can use smart_build now

pull/40/head
czaks 9 years ago
parent
commit
61d2729a40
  1. 17
      templates/themes/catalog/theme.php
  2. 8
      templates/themes/recent/theme.php
  3. 8
      templates/themes/ukko/theme.php

17
templates/themes/catalog/theme.php

@ -16,20 +16,35 @@
if ($action == 'all') {
foreach ($boards as $board) {
$b = new Catalog();
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();
if ($config['smart_build']) {
file_unlink($config['dir']['home'] . $board . '/catalog.html');
}
else {
$b->build($settings, $board);
}
}
}
// Wrap functions in a class so they don't interfere with normal Tinyboard operations
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();

8
templates/themes/recent/theme.php

@ -24,9 +24,15 @@
$this->excluded = explode(' ', $settings['exclude']);
if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete')
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
public function homepage($settings) {

8
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;
}
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()));
}

Loading…
Cancel
Save