diff options
| author | Appleman1234 <applemansigloo@gmail.com> | 2016-12-15 18:25:42 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-15 18:25:42 +0900 |
| commit | cae526e65a20f3da2d8884c4d8e8978c54120000 (patch) | |
| tree | 2954153dd49f616f5018490058ff4bfbd17300d3 /templates/themes/ukko/theme.php | |
| parent | b58fab98147a92c8e6d22f15d23684508b6bb811 (diff) | |
| parent | 5feae402cb55d49963bfd2c6f5a33d10690ecbc1 (diff) | |
Merge pull request #79 from lainchan/clean_prod_vichan_update
Merge vichan changes from upstream and changes directly applied to the site.
Diffstat (limited to 'templates/themes/ukko/theme.php')
| -rw-r--r-- | templates/themes/ukko/theme.php | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index 05525299..a3f30dd4 100644 --- a/templates/themes/ukko/theme.php +++ b/templates/themes/ukko/theme.php @@ -11,10 +11,16 @@ return; } - if ($config['smart_build']) { + $action = generation_strategy('sb_ukko', array()); + + if ($action == 'delete') { file_unlink($settings['uri'] . '/index.html'); + if ($config['api']['enabled']) { + $jsonFilename = $settings['uri'] . '/0.json'; + file_unlink($jsonFilename); + } } - else { + elseif ($action == 'rebuild') { file_write($settings['uri'] . '/index.html', $ukko->build()); } } @@ -28,6 +34,7 @@ $body = ''; $overflow = array(); $board = array( + 'dir' => $this->settings['uri'] . "/", 'url' => $this->settings['uri'], 'uri' => $this->settings['uri'], 'name' => $this->settings['title'], @@ -45,6 +52,9 @@ $count = 0; $threads = array(); + if ($config['api']['enabled']) { + $apithreads = array(); + } while($post = $query->fetch()) { if(!isset($threads[$post['board']])) { @@ -86,6 +96,9 @@ $thread->posts = array_reverse($thread->posts); $body .= '<h2><a href="' . $config['root'] . $post['board'] . '">/' . $post['board'] . '/</a></h2>'; $body .= $thread->build(true); + if ($config['api']['enabled']) { + array_push($apithreads,$thread); + } } else { $page = 'index'; if(floor($threads[$post['board']] / $config['threads_per_page']) > 0) { @@ -99,7 +112,15 @@ $body .= '<script> var overflow = ' . json_encode($overflow) . '</script>'; $body .= '<script type="text/javascript" src="/'.$this->settings['uri'].'/ukko.js"></script>'; - + + // json api + if ($config['api']['enabled']) { + require_once __DIR__. '/../../../inc/api.php'; + $api = new Api(); + $jsonFilename = $board['dir'] . '0.json'; + $json = json_encode($api->translatePage($apithreads)); + file_write($jsonFilename, $json); + } return Element('index.html', array( 'config' => $config, 'board' => $board, |
