rtMerge branch 'frost' of https://github.com/Aevann1/Drama into frost

master
Aevann1 2022-02-11 16:23:16 +00:00
commit 4dfb6d1720
16 changed files with 49 additions and 51 deletions

View File

@ -95,7 +95,7 @@ def submit_get(v, sub=None):
if request.path.startswith('/s/') and not sub: abort(404)
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).all()), v=v, sub=sub)
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, sub=sub)
@app.get("/post/<pid>")
@app.get("/post/<pid>/<anything>")
@ -724,7 +724,10 @@ def thumbnail_thread(pid):
for t in ("submission","comment"):
word = random.choice(('rdrama','marsey'))
for i in requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q={word}&size=1').json()["data"]:
try: data = requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q={word}&size=1').json()["data"]
except: break
for i in data:
body_html = sanitize(f'New {word} mention: https://old.reddit.com{i["permalink"]}?context=89', noimages=True)
@ -769,8 +772,11 @@ def thumbnail_thread(pid):
if SITE == 'pcmemes.net':
for t in ("submission","comment"):
for i in requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q=pcmemes.net&size=1').json()["data"]:
try: data = requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q=pcmemes.net&size=1').json()["data"]
except: break
for i in data:
body_html = sanitize(f'New pcmemes mention: https://old.reddit.com{i["permalink"]}?context=89', noimages=True)
existing_comment = db.query(Comment.id).filter_by(author_id=NOTIFICATIONS_ID, parent_submission=None, distinguish_level=6, body_html=body_html, level=1, sentto=0).first()
@ -882,7 +888,7 @@ def submit_post(v, sub=None):
if domain_obj:
reason = f"Remove the {domain_obj.domain} link from your post and try again. {domain_obj.reason}"
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error":reason}, 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).all()), v=v, error=reason, title=title, url=url, body=request.values.get("body", "")), 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error=reason, title=title, url=url, body=request.values.get("body", "")), 400
elif "twitter.com" == domain:
try: embed = requests.get("https://publish.twitter.com/oembed", timeout=5, params={"url":url, "omit_script":"t"}).json()["html"]
except: embed = None
@ -904,16 +910,16 @@ def submit_post(v, sub=None):
if not url and not request.values.get("body") and not request.files.get("file", None):
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "`url` or `body` parameter required."}, 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).all()), v=v, error="Please enter a url or some text.", title=title, url=url, body=request.values.get("body", "")), 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error="Please enter a url or some text.", title=title, url=url, body=request.values.get("body", "")), 400
if not title:
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "Please enter a better title"}, 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).all()), v=v, error="Please enter a better title.", title=title, url=url, body=request.values.get("body", "")), 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error="Please enter a better title.", title=title, url=url, body=request.values.get("body", "")), 400
elif len(title) > 500:
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "500 character limit for titles"}, 400
else: render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).all()), v=v, error="500 character limit for titles.", title=title[:500], url=url, body=request.values.get("body", "")), 400
else: render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error="500 character limit for titles.", title=title[:500], url=url, body=request.values.get("body", "")), 400
if v.marseyawarded:
marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", title, re.A))
@ -982,12 +988,12 @@ def submit_post(v, sub=None):
if len(str(body)) > 20000:
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error":"There's a 20000 character limit for text body."}, 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).all()), v=v, error="There's a 20000 character limit for text body.", title=title, url=url, body=request.values.get("body", "")), 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error="There's a 20000 character limit for text body.", title=title, url=url, body=request.values.get("body", "")), 400
if len(url) > 2048:
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error":"2048 character limit for URLs."}, 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).all()), v=v, error="2048 character limit for URLs.", title=title, url=url,body=request.values.get("body", "")), 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error="2048 character limit for URLs.", title=title, url=url,body=request.values.get("body", "")), 400
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999)($|\s|\n))', body, re.M|re.A):
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
@ -1025,7 +1031,7 @@ def submit_post(v, sub=None):
body += f"\n\n{url}"
else:
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "Image/Video files only"}, 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).all()), v=v, error="Image/Video files only."), 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error="Image/Video files only."), 400
if '#fortune' in body:
body = body.replace('#fortune', '')
@ -1048,7 +1054,7 @@ def submit_post(v, sub=None):
reason = f"Remove the {ban.domain} link from your post and try again."
if ban.reason: reason += f" {ban.reason}"
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": reason}, 403
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).all()), v=v, error=reason, title=title, url=url, body=request.values.get("body", "")), 403
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error=reason, title=title, url=url, body=request.values.get("body", "")), 403
if v.club_allowed == False: club = False
else: club = bool(request.values.get("club",""))
@ -1134,7 +1140,7 @@ def submit_post(v, sub=None):
new_post.url = url
else:
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "File type not allowed"}, 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).all()), v=v, error="File type not allowed.", title=title, body=request.values.get("body", "")), 400
return render_template("submit.html", SUBS=() if SITE_NAME == 'Drama' else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error="File type not allowed.", title=title, body=request.values.get("body", "")), 400
if not new_post.thumburl and new_post.url:

View File

@ -278,7 +278,7 @@ def submit_contact(v):
body = request.values.get("message")
if not body: abort(400)
body = f'This message has been sent automatically to all admins via [/contact](/contact), user email is "{v.email}"\n\nMessage:\n\n' + body
body = f'This message has been sent automatically to all admins via [/contact](/contact)\n\nMessage:\n\n' + body
body_html = sanitize(body, noimages=True)
if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":

View File

@ -7,7 +7,7 @@ from .front import frontlist
valid_sub_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$")
@app.get("/s/<sub>/mods")
@auth_required
@is_not_permabanned
def mods(v, sub):
sub = g.db.query(Sub).filter_by(name=sub.lower()).one_or_none()
if not sub: abort(404)
@ -18,7 +18,7 @@ def mods(v, sub):
@app.post("/s/<sub>/add_mod")
@auth_required
@is_not_permabanned
def add_mod(v, sub):
sub = g.db.query(Sub).filter_by(name=sub.lower()).one_or_none()
if not sub: abort(404)
@ -43,13 +43,13 @@ def add_mod(v, sub):
@app.get("/create_sub")
@auth_required
@is_not_permabanned
def create_sub(v):
return render_template("sub/create_sub.html", v=v)
@app.post("/create_sub")
@auth_required
@is_not_permabanned
def create_sub2(v):
name = request.values.get('name')
if not name: abort(400)
@ -77,7 +77,7 @@ def create_sub2(v):
return redirect(f'/s/{sub.name}')
@app.post("/kick/<pid>")
@auth_required
@is_not_permabanned
def kick(v, pid):
try: pid = int(pid)
except: abort(400)
@ -97,7 +97,7 @@ def kick(v, pid):
@app.get('/s/<sub>/settings')
@auth_required
@is_not_permabanned
def sub_settings(v, sub):
sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none()
if not sub: abort(404)
@ -109,7 +109,7 @@ def sub_settings(v, sub):
@app.post('/s/<sub>/sidebar')
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@auth_required
@is_not_permabanned
def post_sub_sidebar(v, sub):
sub = g.db.query(Sub).filter_by(name=sub.lower()).one_or_none()
if not sub: abort(404)
@ -133,7 +133,7 @@ def post_sub_sidebar(v, sub):
@app.post("/s/<sub>/banner")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@auth_required
@is_not_permabanned
def sub_banner(v, sub):
if v and v.patron:
if request.content_length > 8 * 1024 * 1024: return {"error":"Max file size is 8 MB."}, 413
@ -164,7 +164,7 @@ def sub_banner(v, sub):
@app.post("/s/<sub>/sidebar_image")
@limiter.limit("1/second;30/minute;200/hour;1000/day")
@auth_required
@is_not_permabanned
def sub_sidebar(v, sub):
if v and v.patron:
if request.content_length > 8 * 1024 * 1024: return {"error":"Max file size is 8 MB."}, 413
@ -190,12 +190,4 @@ def sub_sidebar(v, sub):
g.db.add(sub)
g.db.commit()
return redirect(f'/s/{sub.name}/settings')
#mods id seq
#css
#exile
#guild mod log
#remove mod
#search sub
return redirect(f'/s/{sub.name}/settings')

View File

@ -15,7 +15,7 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=21">
{% if v.agendaposter %}
<style>
html {
@ -39,7 +39,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=108"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/main.css?a=108"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=21">
{% endif %}
</head>

View File

@ -8,7 +8,7 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117">
<link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=21">
{% if v.agendaposter %}
<style>
html {
@ -32,7 +32,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=21">
{% endif %}
<meta charset="utf-8">
@ -225,7 +225,7 @@
</a>
{% elif sub %}
<a href="/">
<img alt="sub banner" src="{{sub.banner_url}}" height=100 width=100% style="object-fit:cover">
<img alt="/s/{[sub.name]} banner" src="{{sub.banner_url}}" max-height=190px width=100% style="object-fit:cover">
</a>
{% else %}
<a href="/">
@ -276,7 +276,7 @@
{% endblock %}
</div>
{% if home %}
{% if home or sub and (request.path.startswith('/post') or request.path.startswith('/comment')) %}
{% block sidebar %}
{% include "sidebar_" + SITE_NAME + ".html" %}
{% endblock %}

View File

@ -35,7 +35,7 @@
{% set icon = ('marseyblm','marseykween','marseydynamite','marseyblack','marseymyeisha','marseyetika','marseyobama','marseyblackcop','marseysosa','marseyblackface')|random() %}
<img alt="header icon" height=33 src="/static/assets/images/emojis/{{icon}}.webp?a=1008">
{% else %}
<img alt="header icon" height=33 src="/static/assets/images/{{SITE_NAME}}/headericon.webp?a=1010">
<img alt="header icon" height=33 src="/static/assets/images/{{SITE_NAME}}/headericon.webp?a=1011">
{% endif %}
{% if SITE_NAME == 'Drama' %}

View File

@ -6,7 +6,7 @@
{% block content %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=21">
{% if v.agendaposter %}
<style>
html {
@ -30,7 +30,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=21">
{% endif %}
<div class="row justify-content-around">

View File

@ -19,7 +19,7 @@
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=21">
</head>

View File

@ -14,7 +14,7 @@
<title>2-Step Login - {{SITE_NAME}}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=21">
</head>

View File

@ -34,7 +34,7 @@
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=21">
{% if v.agendaposter %}
<style>
html {

View File

@ -39,10 +39,10 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=21">
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=21">
{% endif %}
</head>

View File

@ -31,7 +31,7 @@
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}Sign up - {{SITE_NAME}}{% endif %}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=21">
</head>

View File

@ -32,7 +32,7 @@
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}{{SITE_NAME}}{% endif %}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=21">
</head>

View File

@ -57,7 +57,7 @@
<div class="d-flex">
<div class="title w-lg-75 text-md-center">
<img loading="lazy" alt="sub banner" src="{{sub.banner_url}}" class="banner-pic-135">
<img loading="lazy" alt="/s/{[sub.name]} banner" src="{{sub.banner_url}}" class="banner-pic-135">
</div>
<div class="body w-lg-100 my-auto">

View File

@ -296,7 +296,7 @@
{% if p.sub and v.mods(p.sub) %}
<a class="list-inline-item text-danger" role="button" onclick="post_toast('/kick/{{p.id}}')"><i class="fas fa-sign-out text-danger"></i>Kick</a>
<a class="dropdown-item list-inline-item text-danger" role="button" onclick="post_toast('/kick/{{p.id}}')"><i class="fas fa-sign-out text-danger"></i>Kick</a>
{% endif %}

View File

@ -26,7 +26,7 @@
{% block stylesheets %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/main.css?a=117"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=21">
{% if v.agendaposter %}
<style>
html {
@ -51,7 +51,7 @@
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?a=117">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=20">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?a=21">
{% endif %}
{% endblock %}