Allow posting from catalog.

Addresses #134.

The catalog template has been modified to use the board array, which
is expected by the post form template. Because the overboard is a
"virtual board", we created a "fake" overboard array to supply
necessary information to the modified template.

Javascript was also added to hide form on first visit.
This commit is contained in:
Dedushka 2021-01-18 17:30:21 -05:00
parent 48650d8ddd
commit 1eb75f1cee
3 changed files with 41 additions and 16 deletions

View file

@ -372,7 +372,7 @@
// Generate data for the template
$recent_posts = $this->generateRecentPosts($threads);
$this->saveForBoard($board_name, $recent_posts, '/' . $settings['overboard_location']);
$this->saveForBoard($board_name, $recent_posts, '/' . $settings['overboard_location'], true);
// Build the overboard JSON outputs
if ($config['api']['enabled']) {
@ -455,7 +455,7 @@
return $posts;
}
private function saveForBoard($board_name, $recent_posts, $board_link = null) {
private function saveForBoard($board_name, $recent_posts, $board_link = null, $is_overboard = false) {
global $board, $config;
if ($board_link === null) {
@ -471,16 +471,31 @@
$config['additional_javascript'][] = $s;
}
file_write($config['dir']['home'] . $board_name . '/catalog.html', Element('themes/catalog/catalog.html', Array(
$template_config = Array(
'settings' => $this->settings,
'config' => $config,
'boardlist' => createBoardlist(),
'recent_images' => array(),
'recent_posts' => $recent_posts,
'stats' => array(),
'board' => $board_name,
'link' => $board_link
)));
'board' => $board,
'link' => $board_link,
'no_post_form' => false,
);
if ($is_overboard) {
// fake board, I vomit
$template_config['board'] = Array(
'uri' => $board_name,
'title' => $board_name,
'name' => $board_name,
'dir' => $board_name . '/',
'url' => '/' . $board_name . '/'
);
$template_config['no_post_form'] = true;
}
file_write($config['dir']['home'] . $board_name . '/catalog.html', Element('themes/catalog/catalog.html', $template_config));
file_write($config['dir']['home'] . $board_name . '/index.rss', Element('themes/catalog/index.rss', Array(
'config' => $config,