rDrama/files/helpers/jinja2.py

23 lines
538 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")
def crosspost_embed(id):
2021-08-13 02:37:04 +00:00
id = int(id)
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 02:55:52 +00:00
if hasattr(g, 'v') and g.v: return render_template("submission_listing.html", listing=[p], v=g.v)
else: return render_template("submission_listing.html", listing=[p], postembed=True)