diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js
index 6d69a7482..b4df77f14 100644
--- a/files/assets/js/comments_v.js
+++ b/files/assets/js/comments_v.js
@@ -89,7 +89,7 @@ function openReplyBox(id) {
element.getElementsByTagName('textarea')[0].focus()
}
-toggleEdit=function(id){
+function toggleEdit(id){
comment=document.getElementById("comment-text-"+id);
form=document.getElementById("comment-edit-"+id);
box=document.getElementById('comment-edit-body-'+id);
@@ -121,7 +121,7 @@ function delete_commentModal(id) {
};
-post_reply=function(id){
+function post_reply(id){
var form = new FormData();
@@ -148,7 +148,7 @@ post_reply=function(id){
xhr.send(form)
}
-comment_edit=function(id){
+function comment_edit(id){
var form = new FormData();
@@ -177,7 +177,7 @@ comment_edit=function(id){
xhr.send(form)
}
-post_comment=function(fullname){
+function post_comment(fullname){
const btn = document.getElementById('save-reply-to-'+fullname)
btn.classList.add('disabled');
diff --git a/files/assets/js/emoji_modal.js b/files/assets/js/emoji_modal.js
index 54e2304d5..1cafe309a 100644
--- a/files/assets/js/emoji_modal.js
+++ b/files/assets/js/emoji_modal.js
@@ -832,7 +832,7 @@ function loadEmojis(form) {
{
let arr2 = EMOJIS_STRINGS[i].tagged;
for (const [key, value] of Object.entries(arr2)) {
- if (str.includes(`${key}`)) continue;
+ if (str.includes(`'${key}'`)) continue;
if (key.match(search_bar.value.toLowerCase()) || search_bar.value.toLowerCase().match(key)) {
str += ``;
}
diff --git a/files/assets/js/submit.js b/files/assets/js/submit.js
index 90ad0d4e0..2aa4ecf43 100644
--- a/files/assets/js/submit.js
+++ b/files/assets/js/submit.js
@@ -78,7 +78,7 @@ function charLimit(form, text) {
}
-hide_image=function(){
+function hide_image(){
x=document.getElementById('image-upload-block');
url=document.getElementById('post-URL').value;
if (url.length>=1){
diff --git a/files/routes/posts.py b/files/routes/posts.py
index 975098b93..cb48be657 100644
--- a/files/routes/posts.py
+++ b/files/routes/posts.py
@@ -189,8 +189,7 @@ def post_id(pid, anything=None, v=None):
elif sort == "bottom":
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
- offset = int(request.values.get("offset", 0))
- if offset: comments = comments.offset(offset)
+ offset = 0
comments = comments.all()
@@ -222,6 +221,87 @@ def post_id(pid, anything=None, v=None):
else: template = "submission.html"
return render_template(template, v=v, p=post, sort=sort, render_replies=True, offset=offset)
+@app.post("/viewmore///")
+@limiter.limit("1/second")
+@auth_desired
+def viewmore(v, pid, sort, offset):
+ if v:
+ votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
+
+ blocking = v.blocking.subquery()
+
+ blocked = v.blocked.subquery()
+
+ comments = g.db.query(
+ Comment,
+ votes.c.vote_type,
+ blocking.c.id,
+ blocked.c.id,
+ )
+
+ if not (v and v.shadowbanned) and not (v and v.admin_level > 1):
+ comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
+
+ comments=comments.filter(Comment.parent_submission == pid, Comment.author_id != AUTOPOLLER_ID).join(
+ votes,
+ votes.c.comment_id == Comment.id,
+ isouter=True
+ ).join(
+ blocking,
+ blocking.c.target_id == Comment.author_id,
+ isouter=True
+ ).join(
+ blocked,
+ blocked.c.user_id == Comment.author_id,
+ isouter=True
+ )
+
+ output = []
+ for c in comments.all():
+ comment = c[0]
+ comment.voted = c[1] or 0
+ comment.is_blocking = c[2] or 0
+ comment.is_blocked = c[3] or 0
+ output.append(comment)
+
+ pinned = [c[0] for c in comments.filter(Comment.is_pinned != None).all()]
+
+ comments = comments.filter(Comment.level == 1, Comment.is_pinned == None)
+
+ if sort == "new":
+ comments = comments.order_by(Comment.created_utc.desc())
+ elif sort == "old":
+ comments = comments.order_by(Comment.created_utc.asc())
+ elif sort == "controversial":
+ comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes)
+ elif sort == "top":
+ comments = comments.order_by(-Comment.upvotes - Comment.downvotes)
+ elif sort == "bottom":
+ comments = comments.order_by(Comment.upvotes - Comment.downvotes)
+
+ if offset: comments = comments.offset(int(offset))
+
+ comments = [c[0] for c in comments.all()]
+ else:
+ comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == pid, Comment.author_id != AUTOPOLLER_ID, Comment.level == 1, Comment.is_pinned == None)
+
+ if sort == "new":
+ comments = comments.order_by(Comment.created_utc.desc())
+ elif sort == "old":
+ comments = comments.order_by(Comment.created_utc.asc())
+ elif sort == "controversial":
+ comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes)
+ elif sort == "top":
+ comments = comments.order_by(-Comment.upvotes - Comment.downvotes)
+ elif sort == "bottom":
+ comments = comments.order_by(Comment.upvotes - Comment.downvotes)
+
+ if offset: comments = comments.offset(int(offset))
+
+ comments = comments.all()
+
+ return render_template("comments.html", v=v, comments=comments, render_replies=True)
+
@app.post("/edit_post/")
@limiter.limit("1/second")
diff --git a/files/templates/comments.html b/files/templates/comments.html
index 08ca7997a..5e5964f26 100644
--- a/files/templates/comments.html
+++ b/files/templates/comments.html
@@ -749,7 +749,7 @@
{% if v %}
-
+
{% endif %}
diff --git a/files/templates/emoji_modal.html b/files/templates/emoji_modal.html
index 79b0bc342..551514880 100644
--- a/files/templates/emoji_modal.html
+++ b/files/templates/emoji_modal.html
@@ -84,7 +84,7 @@
-
+