From 6e713ca9306d7bf0c6a83789c32f19114e8ffba4 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 25 Mar 2023 20:25:38 +0200 Subject: [PATCH] revert the new comments system --- files/assets/css/classic_dark.css | 5 -- files/assets/css/dark.css | 5 -- files/assets/css/dramblr.css | 5 -- files/assets/css/main.css | 4 -- files/assets/css/midnight.css | 5 -- files/assets/css/tron.css | 5 -- files/assets/js/more_comments.js | 12 +--- files/routes/search.py | 2 +- files/routes/users.py | 91 ++----------------------------- files/templates/comments.html | 2 +- 10 files changed, 10 insertions(+), 126 deletions(-) diff --git a/files/assets/css/classic_dark.css b/files/assets/css/classic_dark.css index 8a9b2d82c..f37e87f21 100644 --- a/files/assets/css/classic_dark.css +++ b/files/assets/css/classic_dark.css @@ -3,8 +3,3 @@ --black: #999; --background: 34, 34, 34; } - -.blueish { - background-color: #312e49 !important; - border-left: 10px solid #312e49 !important; -} diff --git a/files/assets/css/dark.css b/files/assets/css/dark.css index 6fd5d439d..0c4cb7873 100644 --- a/files/assets/css/dark.css +++ b/files/assets/css/dark.css @@ -95,8 +95,3 @@ pre { h5.post-title a:visited { color: #7a7a7a !important; } - -.blueish { - background-color: #312e49 !important; - border-left: 10px solid #312e49 !important; -} diff --git a/files/assets/css/dramblr.css b/files/assets/css/dramblr.css index 8ef5963d2..5fde3aae4 100644 --- a/files/assets/css/dramblr.css +++ b/files/assets/css/dramblr.css @@ -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; -} diff --git a/files/assets/css/main.css b/files/assets/css/main.css index 174f250ca..9582a9aee 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -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); diff --git a/files/assets/css/midnight.css b/files/assets/css/midnight.css index d22a9bf63..c69ebd9e1 100644 --- a/files/assets/css/midnight.css +++ b/files/assets/css/midnight.css @@ -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; -} diff --git a/files/assets/css/tron.css b/files/assets/css/tron.css index 1e7974bc2..2f4b5e699 100644 --- a/files/assets/css/tron.css +++ b/files/assets/css/tron.css @@ -233,8 +233,3 @@ h5.post-title a:visited { color: #b0b0b0 !important; } - -.blueish { - background-color: #312e49 !important; - border-left: 10px solid #312e49 !important; -} diff --git a/files/assets/js/more_comments.js b/files/assets/js/more_comments.js index cf1873a48..e0f008b43 100644 --- a/files/assets/js/more_comments.js +++ b/files/assets/js/more_comments.js @@ -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; } diff --git a/files/routes/search.py b/files/routes/search.py index 84b67ca17..3beff1d21 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -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] diff --git a/files/routes/users.py b/files/routes/users.py index 4b1c1aacf..558b1e075 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -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("/@/more_comments/") -@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("/@/info") @limiter.limit(DEFAULT_RATELIMIT) diff --git a/files/templates/comments.html b/files/templates/comments.html index 423d944be..f4fd137ce 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -119,7 +119,7 @@ {% endif %}
-
+