2021-08-11 17:01:19 +00:00
|
|
|
from files.__main__ import app
|
2021-08-13 02:35:17 +00:00
|
|
|
from .get import *
|
2021-08-21 11:06:28 +00:00
|
|
|
from files.helpers import const
|
2021-07-21 01:12:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.template_filter("full_link")
|
|
|
|
def full_link(url):
|
|
|
|
|
|
|
|
return f"https://{app.config['SERVER_NAME']}{url}"
|
|
|
|
|
|
|
|
@app.template_filter("app_config")
|
|
|
|
def app_config(x):
|
2021-08-13 02:35:17 +00:00
|
|
|
return app.config.get(x)
|
|
|
|
|
|
|
|
@app.template_filter("post_embed")
|
2021-08-13 18:55:59 +00:00
|
|
|
def post_embed(id, v):
|
2021-08-13 02:35:17 +00:00
|
|
|
|
2021-08-13 18:53:11 +00:00
|
|
|
try: id = int(id)
|
|
|
|
except: return None
|
2021-08-13 02:37:04 +00:00
|
|
|
|
2021-08-13 02:37:56 +00:00
|
|
|
p = get_post(id, graceful=True)
|
2021-08-13 02:48:33 +00:00
|
|
|
|
2021-08-21 11:06:28 +00:00
|
|
|
return render_template("submission_listing.html", listing=[p], v=v)
|
|
|
|
|
2021-09-05 19:47:05 +00:00
|
|
|
@app.template_filter("favorite_emojis")
|
2021-09-05 19:48:58 +00:00
|
|
|
def favorite_emojis(x):
|
2021-09-05 19:47:05 +00:00
|
|
|
str = ""
|
2021-09-05 21:00:28 +00:00
|
|
|
emojis = sorted(x.items(), key=lambda x: x[1], reverse=True)[:25]
|
2021-09-05 19:47:05 +00:00
|
|
|
for k, v in emojis:
|
2021-09-29 15:42:28 +00:00
|
|
|
str += f'<button class="btn m-1 px-0 emoji" onclick="getEmoji(\'{k}\', \'@form@\')" style="background: None!important; width:60px; overflow: hidden; border: none;" data-bs-toggle="tooltip" title=":{k}:" delay:="0"><img loading="lazy" width=50 src="/assets/images/emojis/{k}.webp" alt="{k}-emoji"/></button>'
|
2021-09-05 19:47:05 +00:00
|
|
|
return str
|
|
|
|
|
2021-08-21 11:06:28 +00:00
|
|
|
@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}
|
|
|
|
|