summaryrefslogtreecommitdiff
path: root/templates/themes/catalog
diff options
context:
space:
mode:
authorSimon McFarlane <simon@piston.pw>2015-05-26 23:31:47 -0700
committerSimon McFarlane <simon@piston.pw>2015-05-29 01:34:53 -0700
commit4b40f69a4e6d190f6d342875bd084c2a6c9d8b0f (patch)
treefcc5dc9efa24afcb0bda3740b59f0c4e81c42f62 /templates/themes/catalog
parent2ac451ecb7aaae1ed1402425b8df6a5cb9831f2b (diff)
parentd20149b57929c27da87a7d9603d85717da15c5bc (diff)
Merge remote-tracking branch 'upstream/master' into vichan-merge
Diffstat (limited to 'templates/themes/catalog')
-rw-r--r--templates/themes/catalog/catalog.html72
-rw-r--r--templates/themes/catalog/theme.php57
2 files changed, 77 insertions, 52 deletions
diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html
index 12b3cd98..92969b00 100644
--- a/templates/themes/catalog/catalog.html
+++ b/templates/themes/catalog/catalog.html
@@ -50,45 +50,53 @@
data-bump="{{ post.bump }}"
data-time="{{ post.time }}"
>
- <div class="thread grid-li grid-size-small">
- <a href="{{post.link}}">
- {% if post.youtube %}
- <img src="http://img.youtube.com/vi/{{ post.youtube }}/0.jpg"
- {% else %}
- <img src="{{post.file}}"
- {% endif %}
- id="img-{{ post.id }}" data-subject="{% if post.subject %}{{ post.subject|e }}{% endif %}" data-name="{{ post.name|e }}" data-muhdifference="{{ post.muhdifference }}" class="{{post.board}} thread-image" title="{{post.bump|date('%b %d %H:%M')}}">
- </a>
- <div class="replies">
- <strong>R: {{ post.reply_count }} / I: {{ post.image_count }}</strong>
- {% if post.subject %}
- <p class="intro">
- <span class="subject">
- {{ post.subject|e }}
- </span>
- </p>
- {% else %}
- <br />
- {% endif %}
-
- {{ post.body }}
- </div>
- </div>
- </li>
- {% endfor %}
- </ul>
- </div>
+ <div class="thread grid-li grid-size-small">
+ <a href="{{post.link}}">
+ {% if post.youtube %}
+ <img src="//img.youtube.com/vi/{{ post.youtube }}/0.jpg"
+ {% else %}
+ <img src="{{post.file}}"
+ {% endif %}
+ id="img-{{ post.id }}" data-subject="{% if post.subject %}{{ post.subject|e }}{% endif %}" data-name="{{ post.name|e }}" data-muhdifference="{{ post.muhdifference }}" class="{{post.board}} thread-image" title="{{post.bump|date('%b %d %H:%M')}}">
+ </a>
+ <div class="replies">
+ <strong>R: {{ post.reply_count }} / I: {{ post.image_count }}</strong>
+ {% if post.subject %}
+ <p class="intro">
+ <span class="subject">
+ {{ post.subject|e }}
+ </span>
+ </p>
+ {% else %}
+ <br />
+ {% endif %}
+ {{ post.body }}
+ </div>
+ </div>
+ </li>
+ {% endfor %}
+ </ul>
+ </div>
+
<hr/>
<footer>
<p class="unimportant" style="margin-top:20px;text-align:center;">- <a href="http://tinyboard.org/">Tinyboard</a> +
<a href='https://int.vichan.net/devel/'>vichan</a> {{ config.version }} -
- <br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
- <br><a href="https://int.vichan.net/devel/">vichan</a> Copyright &copy; 2012-2014 vichan-devel</p>
+ <br><a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2014 Tinyboard Development Group
+ <br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2015 vichan-devel</p>
</footer>
- <script type="text/javascript">
+ <script type="text/javascript">{% raw %}
+ var styles = {
+ {% endraw %}
+ {% for name, uri in config.stylesheets %}{% raw %}'{% endraw %}{{ name|addslashes }}{% raw %}' : '{% endraw %}/stylesheets/{{ uri|addslashes }}{% raw %}',
+ {% endraw %}{% endfor %}{% raw %}
+ }; onready(init);
+ {% endraw %}</script>
+
+ <script type="text/javascript">{% raw %}
ready();
- </script>
+ {% endraw %}</script>
</body>
</html>
{% endfilter %}
diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php
index 357870e4..34b28e48 100644
--- a/templates/themes/catalog/theme.php
+++ b/templates/themes/catalog/theme.php
@@ -16,11 +16,22 @@
if ($action == 'all') {
foreach ($boards as $board) {
$b = new Catalog();
- $b->build($settings, $board);
+ if ($config['smart_build']) {
+ file_unlink($config['dir']['home'] . $board . '/catalog.html');
+ }
+ else {
+ $b->build($settings, $board);
+ }
}
} elseif ($action == 'post-thread' || ($settings['update_on_posts'] && $action == 'post') || ($settings['update_on_posts'] && $action == 'post-delete') && in_array($board, $boards)) {
$b = new Catalog();
- $b->build($settings, $board);
+
+ if ($config['smart_build']) {
+ file_unlink($config['dir']['home'] . $board . '/catalog.html');
+ }
+ else {
+ $b->build($settings, $board);
+ }
}
}
@@ -28,8 +39,12 @@
class Catalog {
public function build($settings, $board_name) {
global $config, $board;
-
- openBoard($board_name);
+
+ if ($board['uri'] != $board_name) {
+ if (!openBoard($board_name)) {
+ error(sprintf(_("Board %s doesn't exist"), $board_name));
+ }
+ }
$recent_images = array();
$recent_posts = array();
@@ -42,35 +57,37 @@
$board_name, $board_name, $board_name, $board_name, $board_name)) or error(db_error());
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
- $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id']));
+ $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post);
$post['board_name'] = $board['name'];
if ($post['embed'] && preg_match('/^https?:\/\/(\w+\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9\-_]{10,11})(&.+)?$/i', $post['embed'], $matches)) {
$post['youtube'] = $matches[2];
}
- if (isset($post['files'])) {
+ if (isset($post['files']) && $post['files']) {
$files = json_decode($post['files']);
- if ($files[0]->file == 'deleted') {
- if (count($files) > 1) {
- foreach ($files as $file) {
- if (($file == $files[0]) || ($file->file == 'deleted')) continue;
- $post['file'] = $config['uri_thumb'] . $file->thumb;
- }
+ if ($files[0]) {
+ if ($files[0]->file == 'deleted') {
+ if (count($files) > 1) {
+ foreach ($files as $file) {
+ if (($file == $files[0]) || ($file->file == 'deleted')) continue;
+ $post['file'] = $config['uri_thumb'] . $file->thumb;
+ }
- if (empty($post['file'])) $post['file'] = $config['image_deleted'];
+ if (empty($post['file'])) $post['file'] = $config['image_deleted'];
+ }
+ else {
+ $post['file'] = $config['image_deleted'];
+ }
+ }
+ else if($files[0]->thumb == 'spoiler') {
+ $post['file'] = '/' . $config['spoiler_image'];
}
else {
- $post['file'] = $config['image_deleted'];
+ $post['file'] = $config['uri_thumb'] . $files[0]->thumb;
}
}
- else if($files[0]->thumb == 'spoiler') {
- $post['file'] = '/' . $config['spoiler_image'];
- }
- else {
- $post['file'] = $config['uri_thumb'] . $files[0]->thumb;
- }
}
if (empty($post['image_count'])) $post['image_count'] = 0;