Browse Source

Correctly page the overboard json

pull/40/head
Pietro Carrara 3 years ago
parent
commit
eafcce12cf
  1. 27
      templates/themes/catalog/theme.php

27
templates/themes/catalog/theme.php

@ -378,19 +378,26 @@
if ($config['api']['enabled']) { if ($config['api']['enabled']) {
$api = new Api(); $api = new Api();
$threads = array(); // Separate the threads into pages
$pages = array(array());
foreach ($recent_posts as $post) { $totalThreads = count($recent_posts);
$threads[] = new Thread($post); $page = 0;
for ($i = 1; $i <= $totalThreads; $i++) {
$pages[$page][] = new Thread($recent_posts[$i-1]);
// If we have not yet visited all threads,
// and we hit the limit on the current page,
// skip to the next page
if ($i < $totalThreads && ($i % $config['threads_per_page'] == 0)) {
$page++;
$pages[$page] = array();
}
} }
// Page 0, the only page $json = json_encode($api->translateCatalog($pages));
$threads = array($threads);
$json = json_encode($api->translateCatalog($threads));
file_write($config['dir']['home'] . $board_name . '/catalog.json', $json); file_write($config['dir']['home'] . $board_name . '/catalog.json', $json);
$json = json_encode($api->translateCatalog($threads, true)); $json = json_encode($api->translateCatalog($pages, true));
file_write($config['dir']['home'] . $board_name . '/threads.json', $json); file_write($config['dir']['home'] . $board_name . '/threads.json', $json);
} }
} }

Loading…
Cancel
Save