From 7004f2b437acf60720957ba4c4f78cf9a7056d5d Mon Sep 17 00:00:00 2001 From: Pietro Carrara Date: Mon, 11 Jan 2021 20:21:50 -0300 Subject: [PATCH] Build overboard json --- inc/api.php | 4 +++- templates/themes/catalog/theme.php | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/inc/api.php b/inc/api.php index 8e35b511..ae68d00e 100644 --- a/inc/api.php +++ b/inc/api.php @@ -35,11 +35,13 @@ class Api { 'cycle' => 'cyclical', 'bump' => 'last_modified', 'embed' => 'embed', + 'board' => 'board', ); $this->threadsPageFields = array( 'id' => 'no', - 'bump' => 'last_modified' + 'bump' => 'last_modified', + 'board' => 'board', ); $this->fileFields = array( diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index 561df2b1..15e38edb 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -458,5 +458,21 @@ 'recent_posts' => $recent_posts, 'board' => $board ))); + + if ($config['api']['enabled']) { + $api = new Api(); + + $threads = array(); + + foreach ($recent_posts as $post) { + $threads[] = new Thread($post); + } + + $json = json_encode($api->translateCatalogPage($threads)); + file_write($config['dir']['home'] . $board_name . '/catalog.json', $json); + + $json = json_encode($api->translateCatalogPage($threads, true)); + file_write($config['dir']['home'] . $board_name . '/threads.json', $json); + } } }