master
Aevann1 2022-02-04 16:49:27 +02:00
parent 98a5e75ed9
commit 7fadf2d7ba
5 changed files with 19 additions and 10 deletions

View File

@ -29,6 +29,7 @@ class Submission(Base):
distinguish_level = Column(Integer, default=0)
stickied = Column(String)
stickied_utc = Column(Integer)
hole = Column(String)
is_pinned = Column(Boolean, default=False)
private = Column(Boolean, default=False)
club = Column(Boolean, default=False)

View File

@ -128,9 +128,11 @@ def notifications(v):
@app.get("/")
@app.get("/logged_out")
@app.get("/<hole>")
@app.get("/logged_out/<hole>")
@limiter.limit("3/second;30/minute;400/hour;2000/day")
@auth_desired
def front_all(v):
def front_all(v, hole=None):
if g.webview and not session.get("session_id"):
session.permanent = True
session["session_id"] = secrets.token_hex(49)
@ -162,6 +164,7 @@ def front_all(v):
filter_words=v.filter_words if v else [],
gt=int(request.values.get("utc_greater_than", 0)),
lt=int(request.values.get("utc_less_than", 0)),
hole=hole
)
posts = get_posts(ids, v=v)
@ -243,15 +246,18 @@ def front_all(v):
g.db.commit()
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)
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)
if hole: posts = posts.filter_by(hole=hole)
else: posts = posts.filter_by(hole=None)
if t == 'all': cutoff = 0
else:
now = int(time.time())

View File

@ -88,10 +88,10 @@ def publish(pid, v):
return {"message": "Post published!"}
@app.get("/submit")
@app.get("/submit/<hole>")
@auth_required
def submit_get(v):
return render_template("submit.html",
v=v)
def submit_get(v, hole=None):
return render_template("submit.html", v=v, hole=hole)
@app.get("/post/<pid>")
@app.get("/post/<pid>/<anything>")
@ -751,9 +751,10 @@ def thumbnail_thread(pid):
@app.post("/submit")
@app.post("/submit/<hole>")
@limiter.limit("1/second;6/minute;200/hour;1000/day")
@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 and v.patron:
@ -1006,7 +1007,8 @@ def submit_post(v):
embed_url=embed,
title=title[:500],
title_html=title_html,
created_utc=int(time.time())
created_utc=int(time.time()),
hole=hole
)
g.db.add(new_post)

View File

@ -114,7 +114,7 @@
</div>
<div class="card-body">
{% if v %}
<a href="/submit">
<a href="/submit{% if hole %}/{{hole}}{% endif %}">
<input autocomplete="off" type="text" class="form-control"
aria-label="Username"
aria-describedby="basic-addon1">

View File

@ -63,7 +63,7 @@
<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">