xvc
This commit is contained in:
parent
d046afdc59
commit
8263e4268e
5 changed files with 19 additions and 10 deletions
|
@ -29,6 +29,7 @@ class Submission(Base):
|
||||||
distinguish_level = Column(Integer, default=0)
|
distinguish_level = Column(Integer, default=0)
|
||||||
stickied = Column(String)
|
stickied = Column(String)
|
||||||
stickied_utc = Column(Integer)
|
stickied_utc = Column(Integer)
|
||||||
|
hole = Column(String)
|
||||||
is_pinned = Column(Boolean, default=False)
|
is_pinned = Column(Boolean, default=False)
|
||||||
private = Column(Boolean, default=False)
|
private = Column(Boolean, default=False)
|
||||||
club = Column(Boolean, default=False)
|
club = Column(Boolean, default=False)
|
||||||
|
|
|
@ -128,9 +128,11 @@ def notifications(v):
|
||||||
|
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
@app.get("/logged_out")
|
@app.get("/logged_out")
|
||||||
|
@app.get("/<hole>")
|
||||||
|
@app.get("/logged_out/<hole>")
|
||||||
@limiter.limit("3/second;30/minute;400/hour;2000/day")
|
@limiter.limit("3/second;30/minute;400/hour;2000/day")
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def front_all(v):
|
def front_all(v, hole=None):
|
||||||
if g.webview and not session.get("session_id"):
|
if g.webview and not session.get("session_id"):
|
||||||
session.permanent = True
|
session.permanent = True
|
||||||
session["session_id"] = secrets.token_hex(49)
|
session["session_id"] = secrets.token_hex(49)
|
||||||
|
@ -162,6 +164,7 @@ def front_all(v):
|
||||||
filter_words=v.filter_words if v else [],
|
filter_words=v.filter_words if v else [],
|
||||||
gt=int(request.values.get("utc_greater_than", 0)),
|
gt=int(request.values.get("utc_greater_than", 0)),
|
||||||
lt=int(request.values.get("utc_less_than", 0)),
|
lt=int(request.values.get("utc_less_than", 0)),
|
||||||
|
hole=hole
|
||||||
)
|
)
|
||||||
|
|
||||||
posts = get_posts(ids, v=v)
|
posts = get_posts(ids, v=v)
|
||||||
|
@ -243,15 +246,18 @@ def front_all(v):
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists}
|
if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists}
|
||||||
return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page, ccmode=ccmode)
|
return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page, ccmode=ccmode, hole=hole)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@cache.memoize(timeout=86400)
|
@cache.memoize(timeout=86400)
|
||||||
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false", filter_words='', gt=None, lt=None):
|
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false", filter_words='', gt=None, lt=None, hole=None):
|
||||||
|
|
||||||
posts = g.db.query(Submission)
|
posts = g.db.query(Submission)
|
||||||
|
|
||||||
|
if hole: posts = posts.filter_by(hole=hole)
|
||||||
|
else: posts = posts.filter_by(hole=None)
|
||||||
|
|
||||||
if t == 'all': cutoff = 0
|
if t == 'all': cutoff = 0
|
||||||
else:
|
else:
|
||||||
now = int(time.time())
|
now = int(time.time())
|
||||||
|
|
|
@ -88,10 +88,10 @@ def publish(pid, v):
|
||||||
return {"message": "Post published!"}
|
return {"message": "Post published!"}
|
||||||
|
|
||||||
@app.get("/submit")
|
@app.get("/submit")
|
||||||
|
@app.get("/submit/<hole>")
|
||||||
@auth_required
|
@auth_required
|
||||||
def submit_get(v):
|
def submit_get(v, hole=None):
|
||||||
return render_template("submit.html",
|
return render_template("submit.html", v=v, hole=hole)
|
||||||
v=v)
|
|
||||||
|
|
||||||
@app.get("/post/<pid>")
|
@app.get("/post/<pid>")
|
||||||
@app.get("/post/<pid>/<anything>")
|
@app.get("/post/<pid>/<anything>")
|
||||||
|
@ -751,9 +751,10 @@ def thumbnail_thread(pid):
|
||||||
|
|
||||||
|
|
||||||
@app.post("/submit")
|
@app.post("/submit")
|
||||||
|
@app.post("/submit/<hole>")
|
||||||
@limiter.limit("1/second;6/minute;200/hour;1000/day")
|
@limiter.limit("1/second;6/minute;200/hour;1000/day")
|
||||||
@auth_required
|
@auth_required
|
||||||
def submit_post(v):
|
def submit_post(v, hole=None):
|
||||||
if v.is_suspended: return {"error": "You can't perform this action while banned."}, 403
|
if v.is_suspended: return {"error": "You can't perform this action while banned."}, 403
|
||||||
|
|
||||||
if v and v.patron:
|
if v and v.patron:
|
||||||
|
@ -1006,7 +1007,8 @@ def submit_post(v):
|
||||||
embed_url=embed,
|
embed_url=embed,
|
||||||
title=title[:500],
|
title=title[:500],
|
||||||
title_html=title_html,
|
title_html=title_html,
|
||||||
created_utc=int(time.time())
|
created_utc=int(time.time()),
|
||||||
|
hole=hole
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(new_post)
|
g.db.add(new_post)
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<a href="/submit">
|
<a href="/submit{% if hole %}/{{hole}}{% endif %}">
|
||||||
<input autocomplete="off" type="text" class="form-control"
|
<input autocomplete="off" type="text" class="form-control"
|
||||||
aria-label="Username"
|
aria-label="Username"
|
||||||
aria-describedby="basic-addon1">
|
aria-describedby="basic-addon1">
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
|
|
||||||
<div class="submit-grid-view">
|
<div class="submit-grid-view">
|
||||||
<form id="submitform" action="/submit" method="post" enctype="multipart/form-data" style="grid-column: 2">
|
<form id="submitform" action="/submit{% if hole %}/{{hole}}{% endif %}" method="post" enctype="multipart/form-data" style="grid-column: 2">
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue