revert the new comments system

master
Aevann 2023-03-25 20:25:38 +02:00
parent ba28e84138
commit 6e713ca930
10 changed files with 10 additions and 126 deletions

View File

@ -3,8 +3,3 @@
--black: #999;
--background: 34, 34, 34;
}
.blueish {
background-color: #312e49 !important;
border-left: 10px solid #312e49 !important;
}

View File

@ -95,8 +95,3 @@ pre {
h5.post-title a:visited {
color: #7a7a7a !important;
}
.blueish {
background-color: #312e49 !important;
border-left: 10px solid #312e49 !important;
}

View File

@ -147,8 +147,3 @@ color: var(--gray-700);
h5.post-title a:visited {
color: #6e6e6e !important;
}
.blueish {
background-color: #312e49 !important;
border-left: 10px solid #312e49 !important;
}

View File

@ -5213,10 +5213,6 @@ span.green {
background-color: #964000 !important;
border-left: 10px solid #964000 !important;
}
.blueish {
background-color: #e5e3f9 !important;
border-left: 10px solid #e5e3f9 !important;
}
.text-admin {
color: var(--primary);

View File

@ -68,8 +68,3 @@ h5.post-title a:visited {
.modal-content {
border: 1px var(--gray-500) solid;
}
.blueish {
background-color: #312e49 !important;
border-left: 10px solid #312e49 !important;
}

View File

@ -233,8 +233,3 @@
h5.post-title a:visited {
color: #b0b0b0 !important;
}
.blueish {
background-color: #312e49 !important;
border-left: 10px solid #312e49 !important;
}

View File

@ -6,14 +6,7 @@ function more_comments(cid, sort) {
form.append("formkey", formkey());
form.append("sort", sort);
const xhr = new XMLHttpRequest();
let url;
if (location.pathname.startsWith('/@') && location.pathname.endsWith('/comments'))
url = location.pathname.replace("/comments", `/more_comments/${cid}`)
else
url = `/more_comments/${cid}`
xhr.open("get", url);
xhr.open("get", `/more_comments/${cid}`);
xhr.setRequestHeader('xhr', 'xhr');
xhr.onload=function(){
if (xhr.status==200) {
@ -22,8 +15,7 @@ function more_comments(cid, sort) {
register_new_elements(e);
bs_trigger(e)
if (typeof highlight_unread === "function")
highlight_unread("old-comment-counts")
highlight_unread("old-comment-counts")
}
btn.disabled = false;
}

View File

@ -362,7 +362,7 @@ def searchmessages(v:User):
next_exists = (len(comments) > PAGE_SIZE)
comments = comments[:PAGE_SIZE]
for x in comments: x.blueish = True
for x in comments: x.unread = True
comments = [x.top_comment for x in comments]

View File

@ -1004,7 +1004,7 @@ def u_username_comments(username, v=None):
t=request.values.get("t","all")
comment_post_author = aliased(User)
comments = g.db.query(Comment) \
comments = g.db.query(Comment.id) \
.outerjoin(Comment.post) \
.outerjoin(comment_post_author, Submission.author) \
.filter(
@ -1024,97 +1024,18 @@ def u_username_comments(username, v=None):
comments = sort_objects(sort, comments, Comment)
comments = comments.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE+1).all()
next_exists = (len(comments) > PAGE_SIZE)
comments = comments[:PAGE_SIZE]
ids = [x.id for x in comments]
old_ids = set([x.id for x in comments])
ids = old_ids
next_exists = (len(ids) > PAGE_SIZE)
ids = ids[:PAGE_SIZE]
listing = []
comments.reverse()
for x in comments:
x.blueish = True
if x.replies2 == None: x.replies2 = []
if x.parent_comment_id:
if x.parent_comment.replies2 == None:
x.parent_comment.replies2 = []
x.parent_comment.replies2.append(x)
ids.add(x.id)
x.parent_comment.replies2.sort(key=lambda x: x.created_utc, reverse=True)
x = x.parent_comment
if x.author_id == u.id:
x.blueish = True
if x.id in old_ids: continue
ids.add(x.id)
if x.parent_comment_id in old_ids:
if x.parent_comment.replies2 == None:
x.parent_comment.replies2 = []
x.parent_comment.replies2.append(x)
x.parent_comment.replies2.sort(key=lambda x: x.created_utc, reverse=True)
continue
if x.top_comment_id not in [x.id for x in listing]:
listing.append(x)
listing.reverse()
ids.update([x.id for x in listing])
if v:
output = get_comments_v_properties(v, None, Comment.id.in_(ids))[1]
listing = get_comments(ids, v=v)
if v and v.client:
return {"data": [c.json(g.db) for c in listing]}
return render_template("userpage/comments.html", u=u, v=v, listing=listing, page=page, sort=sort, t=t, next_exists=next_exists, is_following=is_following, standalone=True, render_replies=True)
return render_template("userpage/comments.html", u=u, v=v, listing=listing, page=page, sort=sort, t=t,next_exists=next_exists, is_following=is_following, standalone=True)
@app.get("/@<username>/more_comments/<int:cid>")
@limiter.limit(DEFAULT_RATELIMIT)
@auth_desired_with_logingate
def profile_more_comments(v, cid, username):
uid = get_user(username).id
comments = g.db.query(Comment).filter(
Comment.top_comment_id == get_comment(cid).top_comment_id,
Comment.author_id == uid,
Comment.level > 9,
).all()
listing = []
ids = set()
for x in comments:
x.blueish = True
while x.parent_comment_id != cid and x.level > 9:
if x.id in ids: break
ids.add(x.id)
if x.parent_comment.replies2 == None:
x.parent_comment.replies2 = []
x.parent_comment.replies2.append(x)
x = x.parent_comment
if x.author_id == uid:
x.blueish = True
ids.add(x.id)
if x not in listing and x.parent_comment_id == cid:
listing.append(x)
if v:
output = get_comments_v_properties(v, None, Comment.id.in_(ids))[1]
return render_template("comments.html", v=v, comments=listing, render_replies=True)
@app.get("/@<username>/info")
@limiter.limit(DEFAULT_RATELIMIT)

View File

@ -119,7 +119,7 @@
{% endif %}
<div class="comment-body">
<div id="{% if comment_info and comment_info.id == c.id %}context{%else%}comment-{{c.id}}-only{% endif %}" class="{% if c.award_count('tilt', v) %}tilt tilt-{{c.award_count('tilt', v)}}{% endif %} {% if c.blueish %}blueish{% elif c.unread %}unread{% endif %} {% if c.award_count('glowie', v) %}glow{% endif %} comment-{{c.id}}-only comment-anchor {% if comment_info and comment_info.id == c.id %}context{%endif%}{% if c.is_banned %} banned{% endif %}{% if c.deleted_utc %} deleted{% endif %}">
<div id="{% if comment_info and comment_info.id == c.id %}context{%else%}comment-{{c.id}}-only{% endif %}" class="{% if c.award_count('tilt', v) %}tilt tilt-{{c.award_count('tilt', v)}}{% endif %} {% if c.unread %}unread{% endif %} {% if c.award_count('glowie', v) %}glow{% endif %} comment-{{c.id}}-only comment-anchor {% if comment_info and comment_info.id == c.id %}context{%endif%}{% if c.is_banned %} banned{% endif %}{% if c.deleted_utc %} deleted{% endif %}">
<div class="user-info">
<span class="comment-collapse-icon" data-nonce="{{g.nonce}}" data-onclick="collapse_comment('{{c.id}}')"></span>