rDrama/files/helpers/jinja2.py

22 lines
445 B
Python
Raw Normal View History

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-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-13 18:55:59 +00:00
return render_template("submission_listing.html", listing=[p], v=v)