VIEW MORE
This commit is contained in:
parent
77f928cd47
commit
41dce9037e
9 changed files with 110 additions and 15 deletions
|
@ -89,7 +89,7 @@ function openReplyBox(id) {
|
||||||
element.getElementsByTagName('textarea')[0].focus()
|
element.getElementsByTagName('textarea')[0].focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleEdit=function(id){
|
function toggleEdit(id){
|
||||||
comment=document.getElementById("comment-text-"+id);
|
comment=document.getElementById("comment-text-"+id);
|
||||||
form=document.getElementById("comment-edit-"+id);
|
form=document.getElementById("comment-edit-"+id);
|
||||||
box=document.getElementById('comment-edit-body-'+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();
|
var form = new FormData();
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ post_reply=function(id){
|
||||||
xhr.send(form)
|
xhr.send(form)
|
||||||
}
|
}
|
||||||
|
|
||||||
comment_edit=function(id){
|
function comment_edit(id){
|
||||||
|
|
||||||
var form = new FormData();
|
var form = new FormData();
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ comment_edit=function(id){
|
||||||
xhr.send(form)
|
xhr.send(form)
|
||||||
}
|
}
|
||||||
|
|
||||||
post_comment=function(fullname){
|
function post_comment(fullname){
|
||||||
const btn = document.getElementById('save-reply-to-'+fullname)
|
const btn = document.getElementById('save-reply-to-'+fullname)
|
||||||
btn.classList.add('disabled');
|
btn.classList.add('disabled');
|
||||||
|
|
||||||
|
|
|
@ -832,7 +832,7 @@ function loadEmojis(form) {
|
||||||
{
|
{
|
||||||
let arr2 = EMOJIS_STRINGS[i].tagged;
|
let arr2 = EMOJIS_STRINGS[i].tagged;
|
||||||
for (const [key, value] of Object.entries(arr2)) {
|
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)) {
|
if (key.match(search_bar.value.toLowerCase()) || search_bar.value.toLowerCase().match(key)) {
|
||||||
str += `<button class="btn m-1 px-0 emoji2" onclick="getEmoji('${key}')" data-bs-toggle="tooltip" title=":${key}:" delay:="0"><img loading="lazy" width=50 src="/assets/images/emojis/${key}.webp" alt="${key}-emoji"></button>`;
|
str += `<button class="btn m-1 px-0 emoji2" onclick="getEmoji('${key}')" data-bs-toggle="tooltip" title=":${key}:" delay:="0"><img loading="lazy" width=50 src="/assets/images/emojis/${key}.webp" alt="${key}-emoji"></button>`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ function charLimit(form, text) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hide_image=function(){
|
function hide_image(){
|
||||||
x=document.getElementById('image-upload-block');
|
x=document.getElementById('image-upload-block');
|
||||||
url=document.getElementById('post-URL').value;
|
url=document.getElementById('post-URL').value;
|
||||||
if (url.length>=1){
|
if (url.length>=1){
|
||||||
|
|
|
@ -189,8 +189,7 @@ def post_id(pid, anything=None, v=None):
|
||||||
elif sort == "bottom":
|
elif sort == "bottom":
|
||||||
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
|
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
|
||||||
|
|
||||||
offset = int(request.values.get("offset", 0))
|
offset = 0
|
||||||
if offset: comments = comments.offset(offset)
|
|
||||||
|
|
||||||
comments = comments.all()
|
comments = comments.all()
|
||||||
|
|
||||||
|
@ -222,6 +221,87 @@ def post_id(pid, anything=None, v=None):
|
||||||
else: template = "submission.html"
|
else: template = "submission.html"
|
||||||
return render_template(template, v=v, p=post, sort=sort, render_replies=True, offset=offset)
|
return render_template(template, v=v, p=post, sort=sort, render_replies=True, offset=offset)
|
||||||
|
|
||||||
|
@app.post("/viewmore/<pid>/<sort>/<offset>")
|
||||||
|
@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/<pid>")
|
@app.post("/edit_post/<pid>")
|
||||||
@limiter.limit("1/second")
|
@limiter.limit("1/second")
|
||||||
|
|
|
@ -749,7 +749,7 @@
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<script src="https://cdn.jsdelivr.net/npm/marked@3.0.8/lib/marked.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked@3.0.8/lib/marked.min.js"></script>
|
||||||
<script src="/assets/js/comments_v.js?v=80"></script>
|
<script src="/assets/js/comments_v.js?v=81"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/assets/js/emoji_modal.js?v=133"></script>
|
<script src="/assets/js/emoji_modal.js?v=136"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
a.emojitab {
|
a.emojitab {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
block_user=function() {
|
function block_user() {
|
||||||
|
|
||||||
var exileForm = document.getElementById("exile-form");
|
var exileForm = document.getElementById("exile-form");
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
{% if v and (v.id == p.author_id or v.admin_level > 1 and v.admin_level > 2) %}
|
{% if v and (v.id == p.author_id or v.admin_level > 1 and v.admin_level > 2) %}
|
||||||
<script>
|
<script>
|
||||||
togglePostEdit=function(id){
|
function togglePostEdit(id){
|
||||||
|
|
||||||
body=document.getElementById("post-body");
|
body=document.getElementById("post-body");
|
||||||
title=document.getElementById("post-title");
|
title=document.getElementById("post-title");
|
||||||
|
@ -823,10 +823,25 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if offset %}
|
{% if offset %}
|
||||||
|
<script>
|
||||||
|
function viewmore() {
|
||||||
|
var form = new FormData();
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("post", "/viewmore/{{p.id}}/{{sort}}/{{offset}}");
|
||||||
|
xhr.withCredentials=true;
|
||||||
|
xhr.onload=function(){
|
||||||
|
if (xhr.status==200) {
|
||||||
|
document.getElementById("viewmore").innerHTML = xhr.response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr.send(form)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<br>
|
<br>
|
||||||
<a class="pt-2" href="{{request.path}}?sort={{sort}}&offset={{offset}}">VIEW MORE</a>
|
<div id="viewmore"><a class="btn btn-primary" href="javascript:void(0)" onclick="viewmore()">VIEW MORE COMMENTS</a></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% elif not p.replies and p.deleted_utc == 0 %}
|
{% elif not p.replies and p.deleted_utc == 0 %}
|
||||||
<div class="comment-section text-center py-7">
|
<div class="comment-section text-center py-7">
|
||||||
<span class="fa-stack fa-2x text-muted mb-4">
|
<span class="fa-stack fa-2x text-muted mb-4">
|
||||||
|
@ -884,7 +899,7 @@
|
||||||
|
|
||||||
{% if not p.comment_count %}
|
{% if not p.comment_count %}
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<script src="/assets/js/comments_v.js?v=80"></script>
|
<script src="/assets/js/comments_v.js?v=81"></script>
|
||||||
{% include "award_modal.html" %}
|
{% include "award_modal.html" %}
|
||||||
{% include "emoji_modal.html" %}
|
{% include "emoji_modal.html" %}
|
||||||
{% include "gif_modal.html" %}
|
{% include "gif_modal.html" %}
|
||||||
|
|
|
@ -177,7 +177,7 @@
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/marked@3.0.8/lib/marked.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked@3.0.8/lib/marked.min.js"></script>
|
||||||
|
|
||||||
<script src="/assets/js/submit.js?v=72"></script>
|
<script src="/assets/js/submit.js?v=73"></script>
|
||||||
|
|
||||||
|
|
||||||
{% include "emoji_modal.html" %}
|
{% include "emoji_modal.html" %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue