fsd
This commit is contained in:
parent
a12d87c358
commit
035d37b134
12 changed files with 49 additions and 40 deletions
|
@ -232,7 +232,9 @@ class Comment(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def permalink(self):
|
def permalink(self):
|
||||||
if self.post and self.post.club: return f"{SITE_FULL}/comment/{self.id}?context=8#context"
|
if self.post and self.post.club:
|
||||||
|
if self.post.sub: f"{SITE_FULL}/s/{self.post.sub}/comment/{self.id}?context=8#context"
|
||||||
|
else: f"{SITE_FULL}/comment/{self.id}?context=8#context"
|
||||||
|
|
||||||
if self.post: return f"{self.post.permalink}/{self.id}?context=8#context"
|
if self.post: return f"{self.post.permalink}/{self.id}?context=8#context"
|
||||||
else: return f"{SITE_FULL}/comment/{self.id}?context=8#context"
|
else: return f"{SITE_FULL}/comment/{self.id}?context=8#context"
|
||||||
|
|
|
@ -80,7 +80,7 @@ class ModAction(Base):
|
||||||
@lazy
|
@lazy
|
||||||
def string(self):
|
def string(self):
|
||||||
|
|
||||||
output = ACTIONTYPES[self.kind]["str"].format(self=self)
|
output = ACTIONTYPES[self.kind]["str"].format(self=self, cc=cc)
|
||||||
|
|
||||||
if self.note: output += f" <i>({self.note})</i>"
|
if self.note: output += f" <i>({self.note})</i>"
|
||||||
|
|
||||||
|
|
|
@ -29,7 +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)
|
sub = 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)
|
||||||
|
@ -193,20 +193,19 @@ class Submission(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def shortlink(self):
|
def shortlink(self):
|
||||||
if self.club: return f"/post/{self.id}"
|
link = f"/post/{self.id}"
|
||||||
|
if self.sub: link = f"/s/{self.sub}{link}"
|
||||||
|
|
||||||
|
if self.club: return link
|
||||||
|
|
||||||
output = self.title.lower()
|
output = self.title.lower()
|
||||||
|
|
||||||
output = re.sub('&\w{2,3};', '', output, re.A)
|
output = re.sub('&\w{2,3};', '', output, re.A)
|
||||||
|
|
||||||
output = [re.sub('\W', '', word, re.A) for word in output.split()]
|
output = [re.sub('\W', '', word, re.A) for word in output.split()]
|
||||||
output = [x for x in output if x][:6]
|
output = [x for x in output if x][:6]
|
||||||
|
|
||||||
output = '-'.join(output)
|
output = '-'.join(output)
|
||||||
|
|
||||||
if not output: output = '-'
|
if not output: output = '-'
|
||||||
|
|
||||||
return f"/post/{self.id}/{output}"
|
return f"{link}/{output}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
|
|
|
@ -560,4 +560,4 @@ FORTUNE_REPLIES = ('<b style="color:#6023f8">Your fortune: Allah Wills It</b>','
|
||||||
|
|
||||||
no_pass_phrase = """<p>Sorry whiteboy, we're gonna need to see some ID before you start throwin that word around like it's nothing.\n\nTake a 10 minute time-out and come back when you've learned your lesson and/or paid reparations (by purchasing a BIPOC Approved™ Rdrama NWord Pass© from the <a href="/shop">shop</a>) \n\n<em>This is an automated message; if you need help, you can message us <a href="/contact">here</a>.</em></p>"""
|
no_pass_phrase = """<p>Sorry whiteboy, we're gonna need to see some ID before you start throwin that word around like it's nothing.\n\nTake a 10 minute time-out and come back when you've learned your lesson and/or paid reparations (by purchasing a BIPOC Approved™ Rdrama NWord Pass© from the <a href="/shop">shop</a>) \n\n<em>This is an automated message; if you need help, you can message us <a href="/contact">here</a>.</em></p>"""
|
||||||
|
|
||||||
holes = ('2balkan4u','2middleeast4u')
|
subs = ('2balkan4u','2middleeast4u')
|
|
@ -26,8 +26,12 @@ CF_HEADERS = {"Authorization": f"Bearer {CF_KEY}", "Content-Type": "application/
|
||||||
@app.get("/post/<pid>/<anything>/<cid>")
|
@app.get("/post/<pid>/<anything>/<cid>")
|
||||||
@app.get("/logged_out/comment/<cid>")
|
@app.get("/logged_out/comment/<cid>")
|
||||||
@app.get("/logged_out/post/<pid>/<anything>/<cid>")
|
@app.get("/logged_out/post/<pid>/<anything>/<cid>")
|
||||||
|
@app.get("/s/<sub>/comment/<cid>")
|
||||||
|
@app.get("/s/<sub>/post/<pid>/<anything>/<cid>")
|
||||||
|
@app.get("/logged_out/s/<sub>/comment/<cid>")
|
||||||
|
@app.get("/logged_out/s/<sub>/post/<pid>/<anything>/<cid>")
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
|
||||||
|
|
||||||
if not v and not request.path.startswith('/logged_out'): return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
if not v and not request.path.startswith('/logged_out'): return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
||||||
|
|
||||||
|
@ -127,7 +131,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
||||||
else:
|
else:
|
||||||
if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html"
|
if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html"
|
||||||
else: template = "submission.html"
|
else: template = "submission.html"
|
||||||
return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True, hole=post.hole)
|
return render_template(template, v=v, p=post, sort=sort, comment_info=comment_info, render_replies=True, sub=post.sub)
|
||||||
|
|
||||||
@app.post("/comment")
|
@app.post("/comment")
|
||||||
@limiter.limit("1/second;20/minute;200/hour;1000/day")
|
@limiter.limit("1/second;20/minute;200/hour;1000/day")
|
||||||
|
|
|
@ -128,12 +128,12 @@ def notifications(v):
|
||||||
|
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
@app.get("/logged_out")
|
@app.get("/logged_out")
|
||||||
@app.get("/<hole>")
|
@app.get("/s/<sub>")
|
||||||
@app.get("/logged_out/<hole>")
|
@app.get("/logged_out/s/<sub>")
|
||||||
@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, hole=None):
|
def front_all(v, sub=None):
|
||||||
if hole and hole not in holes: hole = None
|
if sub and sub not in subs: sub = 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)
|
||||||
|
@ -165,7 +165,7 @@ def front_all(v, hole=None):
|
||||||
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
|
sub=sub
|
||||||
)
|
)
|
||||||
|
|
||||||
posts = get_posts(ids, v=v)
|
posts = get_posts(ids, v=v)
|
||||||
|
@ -247,17 +247,17 @@ def front_all(v, hole=None):
|
||||||
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, hole=hole)
|
return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page, ccmode=ccmode, sub=sub)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@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, hole=None):
|
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false", filter_words='', gt=None, lt=None, sub=None):
|
||||||
|
|
||||||
posts = g.db.query(Submission)
|
posts = g.db.query(Submission)
|
||||||
|
|
||||||
if hole: posts = posts.filter_by(hole=hole)
|
if sub: posts = posts.filter_by(sub=sub)
|
||||||
else: posts = posts.filter_by(hole=None)
|
else: posts = posts.filter_by(sub=None)
|
||||||
|
|
||||||
if t == 'all': cutoff = 0
|
if t == 'all': cutoff = 0
|
||||||
else:
|
else:
|
||||||
|
@ -327,8 +327,8 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false"
|
||||||
|
|
||||||
if (sort == "hot" or (v and v.id == Q_ID)) and page == 1 and ccmode == "false":
|
if (sort == "hot" or (v and v.id == Q_ID)) and page == 1 and ccmode == "false":
|
||||||
pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False)
|
pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False)
|
||||||
if hole: pins = pins.filter_by(hole=hole)
|
if sub: pins = pins.filter_by(sub=sub)
|
||||||
else: pins = pins.filter_by(hole=None)
|
else: pins = pins.filter_by(sub=None)
|
||||||
if v and v.admin_level == 0:
|
if v and v.admin_level == 0:
|
||||||
blocking = [x[0] for x in g.db.query(UserBlock.target_id).filter_by(user_id=v.id).all()]
|
blocking = [x[0] for x in g.db.query(UserBlock.target_id).filter_by(user_id=v.id).all()]
|
||||||
blocked = [x[0] for x in g.db.query(UserBlock.user_id).filter_by(target_id=v.id).all()]
|
blocked = [x[0] for x in g.db.query(UserBlock.user_id).filter_by(target_id=v.id).all()]
|
||||||
|
|
|
@ -88,18 +88,22 @@ def publish(pid, v):
|
||||||
return {"message": "Post published!"}
|
return {"message": "Post published!"}
|
||||||
|
|
||||||
@app.get("/submit")
|
@app.get("/submit")
|
||||||
@app.get("/submit/<hole>")
|
@app.get("/s/<sub>/submit")
|
||||||
@auth_required
|
@auth_required
|
||||||
def submit_get(v, hole=None):
|
def submit_get(v, sub=None):
|
||||||
if hole and hole not in holes: hole = None
|
if sub and sub not in subs: sub = None
|
||||||
return render_template("submit.html", v=v, hole=hole)
|
return render_template("submit.html", v=v, sub=sub)
|
||||||
|
|
||||||
@app.get("/post/<pid>")
|
@app.get("/post/<pid>")
|
||||||
@app.get("/post/<pid>/<anything>")
|
@app.get("/post/<pid>/<anything>")
|
||||||
@app.get("/logged_out/post/<pid>")
|
@app.get("/logged_out/post/<pid>")
|
||||||
@app.get("/logged_out/post/<pid>/<anything>")
|
@app.get("/logged_out/post/<pid>/<anything>")
|
||||||
|
@app.get("/s/<sub>/post/<pid>")
|
||||||
|
@app.get("/s/<sub>/post/<pid>/<anything>")
|
||||||
|
@app.get("/logged_out/s/<sub>/post/<pid>")
|
||||||
|
@app.get("/logged_out/s/<sub>/post/<pid>/<anything>")
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def post_id(pid, anything=None, v=None):
|
def post_id(pid, anything=None, v=None, sub=None):
|
||||||
if not v and not request.path.startswith('/logged_out') and not request.headers.get("Authorization"):
|
if not v and not request.path.startswith('/logged_out') and not request.headers.get("Authorization"):
|
||||||
return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
||||||
|
|
||||||
|
@ -244,7 +248,7 @@ def post_id(pid, anything=None, v=None):
|
||||||
else:
|
else:
|
||||||
if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html"
|
if post.is_banned and not (v and (v.admin_level > 1 or post.author_id == v.id)): template = "submission_banned.html"
|
||||||
else: template = "submission.html"
|
else: template = "submission.html"
|
||||||
return render_template(template, v=v, p=post, ids=list(ids), sort=sort, render_replies=True, offset=offset, hole=post.hole)
|
return render_template(template, v=v, p=post, ids=list(ids), sort=sort, render_replies=True, offset=offset, sub=post.sub)
|
||||||
|
|
||||||
@app.post("/viewmore/<pid>/<sort>/<offset>")
|
@app.post("/viewmore/<pid>/<sort>/<offset>")
|
||||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||||
|
@ -752,11 +756,11 @@ def thumbnail_thread(pid):
|
||||||
|
|
||||||
|
|
||||||
@app.post("/submit")
|
@app.post("/submit")
|
||||||
@app.post("/submit/<hole>")
|
@app.post("/s/<sub>/submit")
|
||||||
@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, hole=None):
|
def submit_post(v, sub=None):
|
||||||
if hole and hole not in holes: hole = None
|
if sub and sub not in subs: sub = 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:
|
||||||
|
@ -1010,7 +1014,7 @@ def submit_post(v, hole=None):
|
||||||
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
|
sub=sub
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(new_post)
|
g.db.add(new_post)
|
||||||
|
@ -1239,7 +1243,7 @@ def submit_post(v, hole=None):
|
||||||
if 'megathread' in new_post.title.lower(): sort = 'new'
|
if 'megathread' in new_post.title.lower(): sort = 'new'
|
||||||
else: sort = v.defaultsortingcomments
|
else: sort = v.defaultsortingcomments
|
||||||
if len(body_html) < 40000: new_post.replies = [c]
|
if len(body_html) < 40000: new_post.replies = [c]
|
||||||
return render_template('submission.html', v=v, p=new_post, sort=sort, render_replies=True, offset=0, success=True, hole=new_post.hole)
|
return render_template('submission.html', v=v, p=new_post, sort=sort, render_replies=True, offset=0, success=True, sub=new_post.sub)
|
||||||
|
|
||||||
|
|
||||||
@app.post("/delete_post/<pid>")
|
@app.post("/delete_post/<pid>")
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
<a class="mobile-nav-icon d-md-none" href="/admin"><i class="fas fa-crown align-middle text-gray-500 black"></i></a>
|
<a class="mobile-nav-icon d-md-none" href="/admin"><i class="fas fa-crown align-middle text-gray-500 black"></i></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<a class="mobile-nav-icon d-md-none" href="/submit{% if hole %}/{{hole}}{% endif %}"><i class="fas fa-feather-alt align-middle text-gray-500 black"></i></a>
|
<a class="mobile-nav-icon d-md-none" href="{% if sub %}/s/{{sub}}{% endif %}/submit"><i class="fas fa-feather-alt align-middle text-gray-500 black"></i></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="mobile-nav-icon d-md-none" href="/login"><i class="fas fa-feather-alt align-middle text-gray-500 black"></i></a>
|
<a class="mobile-nav-icon d-md-none" href="/login"><i class="fas fa-feather-alt align-middle text-gray-500 black"></i></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
|
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
|
||||||
<a class="nav-link" href="/submit{% if hole %}/{{hole}}{% endif %}" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-original-title="Create post"><i class="fas fa-feather-alt"></i></a>
|
<a class="nav-link" href="{% if sub %}/s/{{sub}}{% endif %}/submit" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-original-title="Create post"><i class="fas fa-feather-alt"></i></a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
|
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<a href="/submit{% if hole %}/{{hole}}{% endif %}">
|
<a href="{% if sub %}/s/{{sub}}{% endif %}/submit">
|
||||||
<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">
|
||||||
|
|
|
@ -550,7 +550,7 @@
|
||||||
</span>
|
</span>
|
||||||
<h2 class="h5">You haven't {% if "saved" in request.full_path %}saved{% else %}made{% endif %} a post yet</h2>
|
<h2 class="h5">You haven't {% if "saved" in request.full_path %}saved{% else %}made{% endif %} a post yet</h2>
|
||||||
<p class="text-muted mb-md-5">Your {% if "saved" in request.full_path %}saved posts{% else %}posting history{% endif %} will show here.</p>
|
<p class="text-muted mb-md-5">Your {% if "saved" in request.full_path %}saved posts{% else %}posting history{% endif %} will show here.</p>
|
||||||
{% if "saved" not in request.full_path %}<a href="/submit{% if hole %}/{{hole}}{% endif %}" class="btn btn-primary">Create a post</a>{% endif %}
|
{% if "saved" not in request.full_path %}<a href="{% if sub %}/s/{{sub}}{% endif %}/submit" class="btn btn-primary">Create a post</a>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
|
|
||||||
<div class="submit-grid-view">
|
<div class="submit-grid-view">
|
||||||
<form id="submitform" action="/submit{% if hole %}/{{hole}}{% endif %}" method="post" enctype="multipart/form-data" style="grid-column: 2">
|
<form id="submitform" action="{% if sub %}/s/{{sub}}{% endif %}/submit" method="post" enctype="multipart/form-data" style="grid-column: 2">
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
|
|
|
@ -628,7 +628,7 @@ CREATE TABLE public.submissions (
|
||||||
flair character varying(350),
|
flair character varying(350),
|
||||||
stickied_utc integer,
|
stickied_utc integer,
|
||||||
ghost boolean,
|
ghost boolean,
|
||||||
hole character varying(20)
|
sub character varying(20)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue