forked from MarseyWorld/MarseyWorld
master
parent
4556aa9c32
commit
4a4efee50d
|
@ -16,7 +16,7 @@ for k, val in result.items():
|
|||
marseys[k] = val['author']
|
||||
|
||||
del result
|
||||
|
||||
|
||||
AJ_REPLACEMENTS = {
|
||||
' your ': " you're ",
|
||||
' to ': " too ",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from files.__main__ import app
|
||||
from .get import *
|
||||
from files.helpers import const
|
||||
|
||||
from os import listdir, environ
|
||||
from .const import *
|
||||
|
||||
@app.template_filter("full_link")
|
||||
def full_link(url):
|
||||
|
@ -26,5 +26,4 @@ def post_embed(id, v):
|
|||
|
||||
@app.context_processor
|
||||
def inject_constants():
|
||||
constants = [c for c in dir(const) if not c.startswith("_")]
|
||||
return {c:getattr(const, c) for c in constants}
|
||||
return {"num_banners":num_banners, "environ":environ, "SITE_NAME":SITE_NAME, "AUTOJANNY_ID": AUTOJANNY_ID, "NOTIFICATIONS_ID": NOTIFICATIONS_ID}
|
|
@ -6,6 +6,7 @@ from .get import *
|
|||
from os import path, environ
|
||||
import re
|
||||
from mistletoe import markdown
|
||||
from json import loads, dump
|
||||
|
||||
site = environ.get("DOMAIN").strip()
|
||||
|
||||
|
@ -185,6 +186,9 @@ def sanitize(sanitized, noimages=False, alert=False):
|
|||
|
||||
sanitized = re.sub('\|\|(.*?)\|\|', r'<span class="spoiler">\1</span>', sanitized)
|
||||
|
||||
with open("marsey_count.json", 'r') as f:
|
||||
marsey_count = loads(f.read())
|
||||
|
||||
for i in re.finditer("[^a]>\s*(:[!#]{0,2}\w+:\s*)+<\/", sanitized):
|
||||
old = i.group(0)
|
||||
if 'marseylong1' in old or 'marseylong2' in old or 'marseyllama1' in old or 'marseyllama2' in old: new = old.lower().replace(">", " class='mb-0'>")
|
||||
|
@ -206,6 +210,7 @@ def sanitize(sanitized, noimages=False, alert=False):
|
|||
|
||||
if path.isfile(f'files/assets/images/emojis/{remoji}.webp'):
|
||||
new = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" {classes}src="/static/assets/images/emojis/{remoji}.webp" >', new, flags=re.I)
|
||||
if emoji in marsey_count: marsey_count[emoji] += 1
|
||||
|
||||
sanitized = sanitized.replace(old, new)
|
||||
|
||||
|
@ -216,9 +221,11 @@ def sanitize(sanitized, noimages=False, alert=False):
|
|||
emoji = emoji[1:]
|
||||
if path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
|
||||
sanitized = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}:" title=":!{emoji}:" delay="0" height=30 class="emoji mirrored" src="/static/assets/images/emojis/{emoji}.webp">', sanitized, flags=re.I)
|
||||
if emoji in marsey_count: marsey_count[emoji] += 1
|
||||
|
||||
elif path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
|
||||
sanitized = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=30 class="emoji" src="/static/assets/images/emojis/{emoji}.webp">', sanitized, flags=re.I)
|
||||
if emoji in marsey_count: marsey_count[emoji] += 1
|
||||
|
||||
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube")
|
||||
|
||||
|
@ -250,6 +257,8 @@ def sanitize(sanitized, noimages=False, alert=False):
|
|||
sanitized = re.sub(' (https:\/\/[^ <>]*)', r' <a target="_blank" rel="nofollow noopener noreferrer" href="\1">\1</a>', sanitized)
|
||||
sanitized = re.sub('<p>(https:\/\/[^ <>]*)', r'<p><a target="_blank" rel="nofollow noopener noreferrer" href="\1">\1</a></p>', sanitized)
|
||||
|
||||
with open('marsey_count.json', 'w') as f: dump(marsey_count, f)
|
||||
|
||||
return sanitized
|
||||
|
||||
def filter_emojis_only(title):
|
||||
|
@ -265,9 +274,9 @@ def filter_emojis_only(title):
|
|||
emoji = emoji[1:]
|
||||
if path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
|
||||
title = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}:" title=":!{emoji}:" delay="0" height=30 src="/static/assets/images/emojis/{emoji}.webp" class="emoji mirrored">', title, flags=re.I)
|
||||
|
||||
|
||||
elif path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
|
||||
title = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=30 class="emoji" src="/static/assets/images/emojis/{emoji}.webp">', title, flags=re.I)
|
||||
|
||||
|
||||
if len(title) > 1500: abort(400)
|
||||
else: return title
|
|
@ -20,7 +20,13 @@ def privacy(v):
|
|||
@app.get("/marseys")
|
||||
@auth_required
|
||||
def emojis(v):
|
||||
return render_template("marseys.html", v=v)
|
||||
with open("marsey_count.json", 'r') as file:
|
||||
marsey_count = loads(file.read())
|
||||
marsey_counted = []
|
||||
for k, val in marseys.items():
|
||||
marsey_counted.append((k, val, marsey_count[k]))
|
||||
marsey_counted = sorted(marsey_counted, key=lambda x: x[2], reverse=True)
|
||||
return render_template("marseys.html", v=v, marseys=marsey_counted)
|
||||
|
||||
@app.get("/terms")
|
||||
@auth_required
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue