Merge remote-tracking branch 'upstream/config' into frontpage

This commit is contained in:
Comatoast 2021-01-22 21:46:26 -08:00
commit 23c55aa9f1
9 changed files with 37 additions and 32 deletions

View file

@ -21,28 +21,28 @@
{% if config.font_awesome %}
<i class="fa fa-thumb-tack" title="Sticky"></i>
{% else %}
<img class="icon" title="Sticky" src="{{ config.image_sticky }}" alt="Sticky" />
<img class="icon" title="Sticky" src="{{ config.root }}{{ config.image_sticky }}" alt="Sticky" />
{% endif %}
{% endif %}
{% if post.locked %}
{% if config.font_awesome %}
<i class="fa fa-lock" title="Locked"></i>
{% else %}
<img class="icon" title="Locked" src="{{ config.image_locked }}" alt="Locked" />
<img class="icon" title="Locked" src="{{ config.root }}{{ config.image_locked }}" alt="Locked" />
{% endif %}
{% endif %}
{% if post.bumplocked and (config.mod.view_bumplock < 0 or (post.mod and post.mod|hasPermission(config.mod.view_bumplock, board.uri))) %}
{% if post.sage and (config.mod.view_bumplock < 0 or (post.mod and post.mod|hasPermission(config.mod.view_bumplock, board.uri))) %}
{% if config.font_awesome %}
<i class="fa fa-anchor" title="Bumplocked"></i>
{% else %}
<img class="icon" title="Bumplocked" src="{{ config.image_bumplocked }}" alt="Bumplocked" />
<img class="icon" title="Bumplocked" src="{{ config.root }}{{ config.image_bumplocked }}" alt="Bumplocked" />
{% endif %}
{% endif %}
{% if post.cycle %}
{% if config.font_awesome %}
<i class="fa fa-refresh" title="Cyclical"></i>
{% else %}
<img class="icon" title="Cyclical" src="{{ config.image_sticky }}" alt="Cyclical" />
<img class="icon" title="Cyclical" src="{{ config.root }}{{ config.image_cycled }}" alt="Cyclical" />
{% endif %}
{% endif %}
{% if index %}

View file

@ -70,7 +70,7 @@
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.replies }} / I: {{ post.images }}{% if post.sticky %} (sticky){% endif %}{% if post.locked %} <span class="fa fa-lock">&nbsp;</span>{% endif %}</strong>
<strong>R: {{ post.replies }} / I: {{ post.images }}{% if post.sticky %} (sticky){% endif %}{% if post.sage %} (sage){% endif %}{% if (config.reply_limit > 0) and (post.replies >= config.reply_limit) %} (full){% endif %}{% if post.locked %} <span class="fa fa-lock">&nbsp;</span>{% endif %}</strong>
{% if post.subject %}
<p class="intro">
<span class="subject">

View file

@ -97,6 +97,18 @@
return $query->fetchAll(PDO::FETCH_ASSOC);
}
/**
* Retrieve count of images and posts in a thread
*/
private function fetchThreadCount($board, $thread_id, $preview_count) {
$query = prepare("SELECT SUM(t.num_files) as file_count, COUNT(t.id) as post_count FROM (SELECT * FROM ``posts_$board`` WHERE `thread` = :id ORDER BY `time` DESC LIMIT :offset , 18446744073709551615) as t;");
$query->bindValue(':id', $thread_id, PDO::PARAM_INT);
$query->bindValue(':offset', $preview_count, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
return $query->fetch(PDO::FETCH_ASSOC);
}
/**
* Intersperse random threads between those in bump order
*/
@ -138,27 +150,15 @@
$config['threads_preview'];
$replies = $this->fetchReplies($post['board'], $post['id'], $preview_count);
// Chomp the last few replies
$disp_replies = $replies;
$disp_img_count = 0;
foreach ($disp_replies as $reply) {
if ($reply['files'] !== '')
++$disp_img_count;
// Append the reply to the thread as it's being built
$thread->add(new Post($reply, $mod ? '?/' : $config['root'], $mod));
}
// Count the number of omitted image replies
$omitted_img_count = count(array_filter($replies, function($p) {
return $p['files'] !== '';
}));
// Set the corresponding omitted numbers on the thread
if (!empty($replies)) {
$thread->omitted = count($replies);
$thread->omitted_images = $omitted_img_count;
}
$threadCount = $this->fetchThreadCount($post['board'], $post['id'], $preview_count);
$thread->omitted = $threadCount['post_count'];
$thread->omitted_images = $threadCount['file_count'];
// Board name and link
$html = '<h2><a href="' . $config['root'] . $post['board'] . '/">/' .