Browse Source

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.
pull/40/head
Dedushka 3 years ago
parent
commit
aa21f4cc6d
No known key found for this signature in database GPG Key ID: DC969A6BA7657A70
  1. 5
      js/catalog.js
  2. 13
      templates/themes/catalog/catalog.html
  3. 27
      templates/themes/catalog/theme.php

5
js/catalog.js

@ -45,4 +45,9 @@ if (active_page == 'catalog') $(function(){
$(this).css('width', 'auto');
}
});
$('#post-form-opener').on('click', function(e) {
$('#post-form-container').css('display', 'unset');
$('#post-form-opener').css('display', 'none');
});
});

13
templates/themes/catalog/catalog.html

@ -6,9 +6,9 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<script type='text/javascript'>
var active_page = "catalog"
, board_name = "{{ board }}";
, board_name = "{{ board.uri }}";
</script>
<title>{{ settings.title }} ( /{{ board }}/ )</title>
<title>{{ settings.title }} ( /{{ board.title|e }}/ )</title>
{% include 'header.html' %}
</head>
<body class="8chan vichan {% if mod %}is-moderator{% else %}is-not-moderator{% endif %} theme-catalog active-catalog" data-stylesheet="{% if config.default_stylesheet.1 != '' %}{{ config.default_stylesheet.1 }}{% else %}default{% endif %}">
@ -16,10 +16,15 @@
{{ boardlist.top }}
</div>
<header>
<h1 class="glitch" data-text="{{ settings.title }} /{{ board }}/"> {{ settings.title }} (<a href="{{link}}">/{{ board }}/</a>)</h1>
<h1 class="glitch" data-text="{{ settings.title }} /{{ board.title|e }}/"> {{ settings.title }} (<a href="{{link}}">/{{ board.title|e }}/</a>)</h1>
<div class="subtitle">{{ settings.subtitle }}</div>
</header>
{% if not no_post_form %}
<center><a href="#" id="post-form-opener">[ {% trans 'Create new thread' %} ]</a></center>
<div id="post-form-container" style="display:none;">
{% include 'post_form.html' %}
</div>
{% endif %}
<div class="controls">
<ul style="display: none">
<li id="sort-bump-order" class="sort" data-sort="data-bump" data-order="asc">{% trans 'Bump order' %}</li>

27
templates/themes/catalog/theme.php

@ -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,

Loading…
Cancel
Save