add: group by thread
This commit is contained in:
parent
1516f56cbd
commit
0b6a0e4d5f
@ -116,3 +116,10 @@ a {
|
||||
.isso-comment-footer a {
|
||||
cursor: pointer;
|
||||
}
|
||||
.thread-title {
|
||||
margin-left: 3em;
|
||||
}
|
||||
.group {
|
||||
float: left;
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
@ -137,10 +137,10 @@ class Comments:
|
||||
sql_args.append(parent)
|
||||
|
||||
# custom sanitization
|
||||
if order_by not in ['id', 'created', 'modified', 'likes', 'dislikes']:
|
||||
if order_by not in ['id', 'created', 'modified', 'likes', 'dislikes', 'tid']:
|
||||
order_by = 'id'
|
||||
sql.append('ORDER BY ')
|
||||
sql.append('comments.' + order_by)
|
||||
sql.append('comments.' + order_by + ", comments.created")
|
||||
sql.append(' DESC')
|
||||
|
||||
if limit:
|
||||
|
@ -77,6 +77,9 @@ function delete_com(com_id, hash) {
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="group">
|
||||
Group by thread: <input type="checkbox" {% if order_by == "tid" %}checked{% endif %} onClick="javascript:window.location='?mode={{mode}}&page={{page}}&order_by={% if order_by == "tid" %}id{% else %}tid{% endif %}';" />
|
||||
</div>
|
||||
<div class="pagination">
|
||||
Pages:
|
||||
{% if page > 0 %}
|
||||
@ -94,7 +97,14 @@ function delete_com(com_id, hash) {
|
||||
</div>
|
||||
</div>
|
||||
<main>
|
||||
{% set thread_id = "no_id" %}
|
||||
{% for comment in comments %}
|
||||
{% if order_by == "tid" %}
|
||||
{% if thread_id != comment.tid %}
|
||||
{% set thread_id = comment.tid %}
|
||||
<h2 class="thread-title">{{comment.title}}</h2>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<div class='isso-comment' id='isso-{{comment.id}}'>
|
||||
{% if conf.avatar %}
|
||||
<div class='avatar'>
|
||||
@ -103,6 +113,9 @@ function delete_com(com_id, hash) {
|
||||
{% endif %}
|
||||
<div class='text-wrapper'>
|
||||
<div class='isso-comment-header' role='meta'>
|
||||
{% if order_by != "tid" %}
|
||||
Thread: {{comment.title}}<br />
|
||||
{% endif %}
|
||||
{% if comment.author %}
|
||||
<span class='author'>{{comment.author}}</span>
|
||||
{% else %}
|
||||
|
@ -520,9 +520,11 @@ class API(object):
|
||||
return render_template('login.html')
|
||||
page_size = 100
|
||||
page = req.args.get('page', 0)
|
||||
order_by = req.args.get('order_by', "id")
|
||||
mode = req.args.get('mode', 2)
|
||||
comments = self.comments.fetchall(mode=mode, page=page,
|
||||
limit=page_size)
|
||||
limit=page_size,
|
||||
order_by=order_by)
|
||||
comments_enriched = []
|
||||
for comment in list(comments):
|
||||
comment['hash'] = self.isso.sign(comment['id'])
|
||||
@ -532,4 +534,5 @@ class API(object):
|
||||
return render_template('admin.html', comments=comments_enriched,
|
||||
page=int(page), mode=int(mode),
|
||||
conf=self.conf, max_page=max_page,
|
||||
counts=comment_mode_count)
|
||||
counts=comment_mode_count,
|
||||
order_by=order_by)
|
||||
|
Loading…
Reference in New Issue
Block a user