fd
This commit is contained in:
parent
7978ba9309
commit
a7d9fa3902
27 changed files with 144 additions and 249 deletions
|
@ -72,7 +72,7 @@ def notifications(v):
|
|||
render_replies=True,
|
||||
is_notification_page=True)
|
||||
|
||||
@cache.memoize(timeout=1500)
|
||||
@cache.memoize()
|
||||
def frontlist(v=None, sort="hot", page=1,t="all", ids_only=True, filter_words='', **kwargs):
|
||||
|
||||
posts = g.db.query(Submission).options(lazyload('*')).filter_by(is_banned=False,stickied=False,private=False).filter(Submission.deleted_utc == 0)
|
||||
|
@ -174,10 +174,13 @@ def frontlist(v=None, sort="hot", page=1,t="all", ids_only=True, filter_words=''
|
|||
|
||||
posts = [x for x in posts if not (x.author and x.author.shadowbanned) or (v and v.id == x.author_id)][:26]
|
||||
|
||||
if ids_only:
|
||||
posts = [x.id for x in posts]
|
||||
return posts
|
||||
return posts
|
||||
next_exists = (len(posts) == 26)
|
||||
|
||||
posts = posts[:25]
|
||||
|
||||
if ids_only: posts = [x.id for x in posts]
|
||||
|
||||
return posts, next_exists
|
||||
|
||||
@app.get("/")
|
||||
@auth_desired
|
||||
|
@ -201,7 +204,7 @@ def front_all(v):
|
|||
sort=request.args.get("sort", defaultsorting)
|
||||
t=request.args.get('t', defaulttime)
|
||||
|
||||
ids = frontlist(sort=sort,
|
||||
ids, next_exists = frontlist(sort=sort,
|
||||
page=page,
|
||||
t=t,
|
||||
v=v,
|
||||
|
@ -210,17 +213,12 @@ def front_all(v):
|
|||
filter_words=v.filter_words if v else [],
|
||||
)
|
||||
|
||||
# check existence of next page
|
||||
next_exists = (len(ids) == 26)
|
||||
ids = ids[:25]
|
||||
|
||||
# check if ids exist
|
||||
posts = get_posts(ids, v=v)
|
||||
|
||||
if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists}
|
||||
else: return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page)
|
||||
|
||||
@cache.memoize(timeout=1500)
|
||||
@cache.memoize()
|
||||
def changeloglist(v=None, sort="new", page=1 ,t="all", **kwargs):
|
||||
|
||||
posts = g.db.query(Submission).options(lazyload('*')).filter_by(is_banned=False,stickied=False,private=False,).filter(Submission.deleted_utc == 0)
|
||||
|
@ -334,7 +332,7 @@ def random_post(v):
|
|||
post = x.order_by(Submission.id.asc()).offset(n).limit(1).first()
|
||||
return redirect(post.permalink)
|
||||
|
||||
@cache.memoize(600)
|
||||
@cache.memoize()
|
||||
def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", **kwargs):
|
||||
|
||||
posts = g.db.query(Submission).options(lazyload('*'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue