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:
parent
11d59a9181
commit
aa21f4cc6d
|
@ -45,4 +45,9 @@ if (active_page == 'catalog') $(function(){
|
||||||
$(this).css('width', 'auto');
|
$(this).css('width', 'auto');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#post-form-opener').on('click', function(e) {
|
||||||
|
$('#post-form-container').css('display', 'unset');
|
||||||
|
$('#post-form-opener').css('display', 'none');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
var active_page = "catalog"
|
var active_page = "catalog"
|
||||||
, board_name = "{{ board }}";
|
, board_name = "{{ board.uri }}";
|
||||||
</script>
|
</script>
|
||||||
<title>{{ settings.title }} ( /{{ board }}/ )</title>
|
<title>{{ settings.title }} ( /{{ board.title|e }}/ )</title>
|
||||||
{% include 'header.html' %}
|
{% include 'header.html' %}
|
||||||
</head>
|
</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 %}">
|
<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 }}
|
{{ boardlist.top }}
|
||||||
</div>
|
</div>
|
||||||
<header>
|
<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>
|
<div class="subtitle">{{ settings.subtitle }}</div>
|
||||||
</header>
|
</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">
|
<div class="controls">
|
||||||
<ul style="display: none">
|
<ul style="display: none">
|
||||||
<li id="sort-bump-order" class="sort" data-sort="data-bump" data-order="asc">{% trans 'Bump order' %}</li>
|
<li id="sort-bump-order" class="sort" data-sort="data-bump" data-order="asc">{% trans 'Bump order' %}</li>
|
||||||
|
|
|
@ -372,7 +372,7 @@
|
||||||
// Generate data for the template
|
// Generate data for the template
|
||||||
$recent_posts = $this->generateRecentPosts($threads);
|
$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
|
// Build the overboard JSON outputs
|
||||||
if ($config['api']['enabled']) {
|
if ($config['api']['enabled']) {
|
||||||
|
@ -455,7 +455,7 @@
|
||||||
return $posts;
|
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;
|
global $board, $config;
|
||||||
|
|
||||||
if ($board_link === null) {
|
if ($board_link === null) {
|
||||||
|
@ -471,16 +471,31 @@
|
||||||
$config['additional_javascript'][] = $s;
|
$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,
|
'settings' => $this->settings,
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
'boardlist' => createBoardlist(),
|
'boardlist' => createBoardlist(),
|
||||||
'recent_images' => array(),
|
'recent_images' => array(),
|
||||||
'recent_posts' => $recent_posts,
|
'recent_posts' => $recent_posts,
|
||||||
'stats' => array(),
|
'stats' => array(),
|
||||||
'board' => $board_name,
|
'board' => $board,
|
||||||
'link' => $board_link
|
'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(
|
file_write($config['dir']['home'] . $board_name . '/index.rss', Element('themes/catalog/index.rss', Array(
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
|
|
Loading…
Reference in New Issue