From d21742107b9cd81d616d0c0dab198e86e6a9ae71 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 31 Aug 2021 18:50:06 +0200 Subject: [PATCH] fdfd --- files/routes/users.py | 8 +- files/templates/comments.html | 355 +++++++++++++++++----------------- files/templates/default.html | 33 ++++ 3 files changed, 219 insertions(+), 177 deletions(-) diff --git a/files/routes/users.py b/files/routes/users.py index b6b020d0b..92d062fdc 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -200,9 +200,11 @@ def messagereply(v, username, id): cache.delete_memoized(User.notification_messages, user) - if not request.referrer or request.referrer.endswith('/notifications'): return redirect(f"/notifications?all=true#comment-{id}") - else: return redirect(f"{request.referrer}#comment-{id}") - + return jsonify({"html": render_template("comments.html", + v=v, + comments=[c], + render_replies=False, + )}) @app.get("/2faqr/") @auth_required diff --git a/files/templates/comments.html b/files/templates/comments.html index 09a74e905..6b0faaef6 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -168,192 +168,200 @@ {% if not c.parent_submission and c.author_id!=NOTIFICATIONS_ACCOUNT and c.author_id!=AUTOJANNY_ACCOUNT and c.author_id!=v.id %} Reply

-					
- -

-						
-						 
-						
-						 
-						
-						 
-						
-						 
-						
-						 
-						
+	
+					
+						 
+						 
+						 
+						
+ +   + +   + + Cancel + Reply +
+ Cancel + Reply
{% endif %} {% if c.parent_submission %} - {% if v and v.id==c.author_id %} - - {% endif %} - -
-
    - - {% if v and request.path.startswith('/@') and v.admin_level == 0%} - - {% if voted==1 %} -
  • - {% endif %} - - {% elif v %} - -
  • -
  • - - {% else %} -
  • -
  • - - {% endif %} - -
  • - {{score}} -
  • - - {% if v and request.path.startswith('/@') and v.admin_level == 0 %} - - {% if voted==-1 %} -
  • - {% endif %} - - {% elif v %} -
  • -
  • - - {% else %} - -
  • -
  • - - {% endif %} - -
  • Votes
  • - - {% if v and c.id in v.saved_comment_idlist() %} -
  • Unsave
  • - {% else %} -
  • Save
  • - {% endif %} - - {% if v %} -
  • Reply
  • - - {% if v.id!=c.author_id %} -
  • Give Award
  • - {% endif %} - - {% endif %} -
  • Context
  • -
  • Copy link
  • - - {% if v %} -
  • Report
  • - {% else %} -
  • Flag
  • - {% endif %} - - - {% if v and c.parent_submission and c.author_id==v.id %} - -
  • Edit
  • - - {% if c.deleted_utc > 0 %} -
  • Undelete
  • - {% else %} -
  • Delete
  • - {% endif %} - - {% endif %} - - {% if v and v.admin_level==6 and v.id==c.author_id %} -
  • {{'Undistinguish' if c.distinguish_level else 'Distinguish'}}
  • - {% endif %} + {% if v and v.id==c.author_id %} + + {% endif %} + +
    +
      - - {% if v and v.admin_level>=3 %} -
    • Approve
    • -
    • Remove
    • - {% endif %} - - {% if v and c.parent_submission and (c.author_id==v.id or v.admin_level > 0) %} -
    • Toggle +18
    • - {% endif %} - - {% if v and v.admin_level==6 and v.id != c.author_id %} - {% if c.author.is_suspended %} -
    • Unban user
    • - {% else %} -
    • Ban user
    • - {% endif %} - {% endif %} - - {% if v and v.admin_level >=4 and c.oauth_app %} -
    • API App
    • - {% endif %} - -
    • - {% if v and request.path.startswith('/@') and v.admin_level == 0 %} - {% if voted==1 %}
    • {% endif %} - {% elif v %} -
    • - {% else %} -
    • - {% endif %} - -
    • {{score}}
    • - {% if v and request.path.startswith('/@') and v.admin_level == 0 %} - {% if voted==-1 %} -
    • + {% if v and request.path.startswith('/@') and v.admin_level == 0%} + + {% if voted==1 %} +
    • {% endif %} - {% elif v %} -
    • - {% else %} -
    • - {% endif %} -
    -
    + + {% elif v %} + +
  • +
  • + + {% else %} +
  • +
  • + + {% endif %} + +
  • + {{score}} +
  • + + {% if v and request.path.startswith('/@') and v.admin_level == 0 %} + + {% if voted==-1 %} +
  • + {% endif %} + + {% elif v %} +
  • +
  • + + {% else %} + +
  • +
  • + + {% endif %} + +
  • Votes
  • + + {% if v and c.id in v.saved_comment_idlist() %} +
  • Unsave
  • + {% else %} +
  • Save
  • + {% endif %} + + {% if v %} +
  • Reply
  • + + {% if v.id!=c.author_id %} +
  • Give Award
  • + {% endif %} + + {% endif %} +
  • Context
  • +
  • Copy link
  • + + {% if v %} +
  • Report
  • + {% else %} +
  • Flag
  • + {% endif %} + + + {% if v and c.parent_submission and c.author_id==v.id %} + +
  • Edit
  • + + {% if c.deleted_utc > 0 %} +
  • Undelete
  • + {% else %} +
  • Delete
  • + {% endif %} + + {% endif %} + + {% if v and v.admin_level==6 and v.id==c.author_id %} +
  • {{'Undistinguish' if c.distinguish_level else 'Distinguish'}}
  • + {% endif %} + + + {% if v and not v.id==c.author_id and v.admin_level == 0 %} +
  • Block user
  • + {% endif %} + + {% if v and c.post and (v.admin_level >= 1 or v.id == c.post.author_id) and c.level == 1 %} +
  • {{'Unpin' if c.is_pinned else 'Pin'}}
  • + + {% endif %} + + + {% if v and v.admin_level>=3 %} +
  • Approve
  • +
  • Remove
  • + {% endif %} + + {% if v and c.parent_submission and (c.author_id==v.id or v.admin_level > 0) %} +
  • Toggle +18
  • + {% endif %} + + {% if v and v.admin_level==6 and v.id != c.author_id %} + {% if c.author.is_suspended %} +
  • Unban user
  • + {% else %} +
  • Ban user
  • + {% endif %} + {% endif %} + + {% if v and v.admin_level >=4 and c.oauth_app %} +
  • API App
  • + {% endif %} + +
  • + {% if v and request.path.startswith('/@') and v.admin_level == 0 %} + {% if voted==1 %}
  • {% endif %} + {% elif v %} +
  • + {% else %} +
  • + {% endif %} + +
  • {{score}}
  • + {% if v and request.path.startswith('/@') and v.admin_level == 0 %} + {% if voted==-1 %} +
  • + {% endif %} + {% elif v %} +
  • + {% else %} +
  • + {% endif %} +
+
{% endif %} -
{% endif %} {% endif %} -
diff --git a/files/templates/default.html b/files/templates/default.html index d81a5c848..fa03bb02f 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -519,6 +519,39 @@ } + post_reply=function(fullname){ + + var form = new FormData(); + + form.append('formkey', formkey()); + form.append('parent_fullname', fullname); + form.append('body', document.getElementById('reply-form-body-'+fullname).value); + form.append('file', document.getElementById('file-upload-reply-'+fullname).files[0]); + var xhr = new XMLHttpRequest(); + xhr.open("post", "/comment"); + xhr.withCredentials=true; + xhr.onload=function(){ + if (xhr.status==200) { + commentForm=document.getElementById('comment-form-space-'+fullname); + commentForm.innerHTML=JSON.parse(xhr.response)["html"]; + $('#toast-comment-success').toast('dispose'); + $('#toast-comment-error').toast('dispose'); + $('#toast-comment-success').toast('show'); + } + else { + var commentError = document.getElementById("comment-error-text"); + $('#toast-comment-success').toast('dispose'); + $('#toast-comment-error').toast('dispose'); + $('#toast-comment-error').toast('show'); + commentError.textContent = JSON.parse(xhr.response)["error"]; + } + } + xhr.send(form) + + document.getElementById('save-reply-to-'+fullname).classList.add('disabled'); + + } + herald_comment=function(cid){