diff options
| author | czaks <marcin@6irc.net> | 2013-12-28 18:03:49 +0100 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2013-12-28 18:03:49 +0100 |
| commit | 62fe8571e2d7c6477f0f6d9c51be5f1eeec50624 (patch) | |
| tree | c67a2b88aad50210ce5dc024d8c42fa494c38f6a /inc/functions.php | |
| parent | c8913f41a7a7a8be76a458b001c3f2b2e1ca0dea (diff) | |
json api: fix building of catalog.json (NB: this puts extra load on server; we can try to make it lighter)
Diffstat (limited to 'inc/functions.php')
| -rw-r--r-- | inc/functions.php | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/inc/functions.php b/inc/functions.php index 4616a0db..676b6554 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1365,13 +1365,27 @@ function buildIndex() { for ($page = 1; $page <= $config['max_pages']; $page++) { $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page)); - if ($config['try_smarter'] && isset($build_pages) && !empty($build_pages) + if (!$config['api']['enabled'] && $config['try_smarter'] && isset($build_pages) && !empty($build_pages) && !in_array($page, $build_pages) && is_file($filename)) continue; $content = index($page); if (!$content) break; + // json api + if ($config['api']['enabled']) { + $threads = $content['threads']; + $json = json_encode($api->translatePage($threads)); + $jsonFilename = $board['dir'] . ($page - 1) . '.json'; // pages should start from 0 + file_write($jsonFilename, $json); + + $catalog[$page-1] = $threads; + } + + if ($config['api']['enabled'] && $config['try_smarter'] && isset($build_pages) && !empty($build_pages) + && !in_array($page, $build_pages) && is_file($filename)) + continue; + if ($config['try_smarter']) { $antibot = create_antibot($board['uri'], 0 - $page); $content['current_page'] = $page; @@ -1383,16 +1397,6 @@ function buildIndex() { $content['antibot'] = $antibot; file_write($filename, Element('index.html', $content)); - - // json api - if ($config['api']['enabled']) { - $threads = $content['threads']; - $json = json_encode($api->translatePage($threads)); - $jsonFilename = $board['dir'] . ($page - 1) . '.json'; // pages should start from 0 - file_write($jsonFilename, $json); - - $catalog[$page-1] = $threads; - } } if ($page < $config['max_pages']) { |
