highlight
This commit is contained in:
parent
96d815bd6b
commit
6f94e30854
3 changed files with 16 additions and 10 deletions
|
@ -134,7 +134,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
||||||
|
|
||||||
return f"/post/{self.id}/{output}"
|
return f"/post/{self.id}/{output}"
|
||||||
|
|
||||||
def rendered_page(self, read=None, sort=None, comment=None, comment_info=None, v=None):
|
def rendered_page(self, sort=None, last_view_utc=None, comment=None, comment_info=None, v=None):
|
||||||
|
|
||||||
# check for banned
|
# check for banned
|
||||||
if v and (v.admin_level >= 3 or self.author_id == v.id):
|
if v and (v.admin_level >= 3 or self.author_id == v.id):
|
||||||
|
@ -153,8 +153,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
||||||
return render_template(template,
|
return render_template(template,
|
||||||
v=v,
|
v=v,
|
||||||
p=self,
|
p=self,
|
||||||
sort=sort,
|
last_view_utc=last_view_utc,
|
||||||
read=read,
|
|
||||||
linked_comment=comment,
|
linked_comment=comment,
|
||||||
comment_info=comment_info,
|
comment_info=comment_info,
|
||||||
render_replies=True,
|
render_replies=True,
|
||||||
|
|
|
@ -181,11 +181,18 @@ def post_id(pid, anything=None, v=None):
|
||||||
|
|
||||||
post.preloaded_comments = [x for x in comments if not (x.author and x.author.shadowbanned) or (v and v.id == x.author_id)]
|
post.preloaded_comments = [x for x in comments if not (x.author and x.author.shadowbanned) or (v and v.id == x.author_id)]
|
||||||
|
|
||||||
if session.get("read_comments"): read = list(set(session.get("read_comments")))
|
# if session.get("read_comments"): read = list(set(session.get("read_comments")))
|
||||||
else: read = None
|
# else: read = None
|
||||||
read_comments = [x.id for x in post.preloaded_comments]
|
|
||||||
if read: session["read_comments"] += read_comments
|
# unread comment highlight
|
||||||
else: session["read_comments"] = read_comments
|
last_view_utc = session.get(str(post.id))
|
||||||
|
|
||||||
|
if last_view_utc:
|
||||||
|
last_view_utc = int(last_view_utc)
|
||||||
|
|
||||||
|
session[str(post.id)] = int(time.time())
|
||||||
|
|
||||||
|
#read_comments = [x.id for x in post.preloaded_comments]
|
||||||
|
|
||||||
post.views += 1
|
post.views += 1
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
@ -196,7 +203,7 @@ def post_id(pid, anything=None, v=None):
|
||||||
|
|
||||||
post.tree_comments()
|
post.tree_comments()
|
||||||
if request.headers.get("Authorization"): return post.json
|
if request.headers.get("Authorization"): return post.json
|
||||||
else: return post.rendered_page(v=v, read=read, sort=sort)
|
else: return post.rendered_page(v=v, last_view_utc=last_view_utc, sort=sort)
|
||||||
|
|
||||||
|
|
||||||
@app.post("/edit_post/<pid>")
|
@app.post("/edit_post/<pid>")
|
||||||
|
|
|
@ -111,7 +111,7 @@
|
||||||
|
|
||||||
<div class="comment-body">
|
<div class="comment-body">
|
||||||
|
|
||||||
<div id="{% if comment_info and comment_info.id == c.id %}context{%else%}comment-{{c.id}}-only{% endif %}" class="{% if comment_info and comment_info.id == c.id %}context{%endif%}{% if c.is_banned %} banned{% endif %}{% if c.deleted_utc %} deleted{% endif %}" {% if read and c.id not in read %}style="background-color: rgba(179,229,255,0.5)"{% endif %}>
|
<div id="{% if comment_info and comment_info.id == c.id %}context{%else%}comment-{{c.id}}-only{% endif %}" class="{% if comment_info and comment_info.id == c.id %}context{%endif%}{% if c.is_banned %} banned{% endif %}{% if c.deleted_utc %} deleted{% endif %}" {% if last_view_utc and c.created_utc > last_view_utc and not (v and v.id==c.author_id) %}style="background-color: rgba(179,229,255,0.5)"{% endif %}>
|
||||||
|
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<span class="comment-collapse d-md-none" onclick="collapse_comment('{{c.id}}')"></span>
|
<span class="comment-collapse d-md-none" onclick="collapse_comment('{{c.id}}')"></span>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue