remotes/1693045480750635534/spooky-22
Aevann1 2022-02-18 21:12:14 +02:00
parent 939f6719c0
commit 2875f28b82
6 changed files with 36 additions and 6 deletions

View File

@ -8,7 +8,8 @@ def process_image(filename=None, resize=0):
i = Image.open(filename)
if resize and i.width > resize:
subprocess.call(["convert", filename, "-coalesce", "-resize", f"{resize}>", filename])
try: subprocess.call(["convert", filename, "-coalesce", "-resize", f"{resize}>", filename])
except: pass
elif i.format.lower() != "webp":
exif = i.getexif()

View File

@ -302,6 +302,12 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
def filter_emojis_only(title, edit=False, graceful=False):
signal.signal(signal.SIGALRM, handler)
signal.alarm(1)
if title.count(':') > 100: abort(418)
if title.count('@') > 50: abort(418)
title = title.replace('<','&lt;').replace('>','&gt;').replace("\n", "").replace("\r", "").replace("\t", "").strip()
title = bleach.clean(title, tags=[])
@ -334,5 +340,7 @@ def filter_emojis_only(title, edit=False, graceful=False):
if path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
title = re.sub(f'(?<!"):{old}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{old}:" title=":{old}:" delay="0" class="{classes}" src="/static/assets/images/emojis/{emoji}.webp">', title, re.I)
signal.alarm(0)
if len(title) > 1500 and not graceful: abort(400)
else: return title

View File

@ -40,6 +40,8 @@ discounts = {
73: 0.10,
}
titleheaders = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36"}
def ghost_price(v):
if v.patron == 1: discount = 0.90
elif v.patron == 2: discount = 0.85
@ -1493,4 +1495,23 @@ def api_pin_post(post_id, v):
g.db.commit()
if post.is_pinned: return {"message": "Post pinned!"}
else: return {"message": "Post unpinned!"}
else: return {"message": "Post unpinned!"}
@app.get("/submit/title")
@limiter.limit("6/minute")
@auth_required
def get_post_title(v):
url = request.values.get("url", None)
if not url: abort(400)
try: x = requests.get(url, headers=titleheaders, timeout=5)
except: abort(400)
soup = BeautifulSoup(x.content, 'html.parser')
title = soup.find('title')
if not title: abort(400)
return {"url": url, "title": title.string}

View File

@ -356,7 +356,7 @@ def leaderboard(v):
sq = g.db.query(User.id, func.rank().over(order_by=User.truecoins.desc()).label("rank")).subquery()
pos10 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
sq = g.db.query(Badge.user_id, func.count(Badge.user_id).label("count"), func.rank().over(order_by=func.count(Badge.user_id).desc()).label("rank")).group_by(Badge.user_id).subquery()
sq = g.db.query(Badge.user_id, func.count(Badge.user_id).label("count"), func.rank().over(order_by=func.count(Badge.user_id).desc()).label("rank")).group_by(Badge.user_id).order_by=func.count(Badge.user_id).subquery()
users11 = g.db.query(User, sq.c.count).join(sq, User.id==sq.c.user_id).order_by(sq.c.count.desc())
pos11 = g.db.query(User.id, sq.c.rank, sq.c.count).join(sq, User.id==sq.c.user_id).filter(User.id == v.id).one_or_none()
if pos11: pos11 = (pos11[1],pos11[2])

View File

@ -532,7 +532,7 @@
{% if not p.club or v and (v.paid_dues or v.id == p.author_id) %}
{% if p.realbody(v) %}
<div class="d-none card rounded border py-3 my-2 {% if p.author.agendaposter %}agendaposter{% endif %}" id="post-text-{{p.id}}">
<div class="d-none card rounded border pt-3 pb-2 my-2 {% if p.author.agendaposter %}agendaposter{% endif %}" id="post-text-{{p.id}}">
{{p.realbody(v) | safe}}
</div>
{% endif %}

View File

@ -110,7 +110,7 @@
<div id="urlblock">
<label for="URL" class="mt-3">URL</label>
<input autocomplete="off" class="form-control" id="post-URL" aria-describedby="URLHelp" name="url" placeholder="Optional if you have text." value="{{request.values.get('url','')}}" required oninput="checkForRequired();hide_image()">
<input autocomplete="off" class="form-control" id="post-URL" aria-describedby="URLHelp" name="url" placeholder="Optional if you have text." value="{{request.values.get('url','')}}" required oninput="checkForRequired();hide_image();autoSuggestTitle()">
<small class="form-text text-muted">To post an image, use a direct image link such as i.imgur.com</small>
</div>
<div id="image-upload-block">
@ -271,7 +271,7 @@
<script src="/static/assets/js/marked.js?a=242"></script>
<script src="/static/assets/js/formatting.js?a=240"></script>
<script src="/static/assets/js/submit.js?a=243"></script>
<script src="/static/assets/js/submit.js?a=244"></script>
{% include "emoji_modal.html" %}
{% include "gif_modal.html" %}