2022-08-13 07:42:06 +00:00
|
|
|
from files.__main__ import app, cache
|
2022-09-27 06:02:02 +00:00
|
|
|
from jinja2 import pass_context
|
2022-01-19 10:07:11 +00:00
|
|
|
from .get import *
|
|
|
|
from os import listdir, environ
|
|
|
|
from .const import *
|
2022-04-06 22:54:09 +00:00
|
|
|
import time
|
2022-09-24 06:40:26 +00:00
|
|
|
from files.helpers.assetcache import assetcache_path
|
2022-10-15 07:31:24 +00:00
|
|
|
from files.helpers.wrappers import calc_users
|
2022-10-24 21:11:17 +00:00
|
|
|
from files.helpers.hosts import current_host
|
2022-01-19 10:07:11 +00:00
|
|
|
|
|
|
|
@app.template_filter("post_embed")
|
|
|
|
def post_embed(id, v):
|
2022-07-08 18:28:56 +00:00
|
|
|
p = get_post(id, v, graceful=True)
|
2022-01-19 10:07:11 +00:00
|
|
|
|
2022-01-28 19:27:16 +00:00
|
|
|
if p: return render_template("submission_listing.html", listing=[p], v=v)
|
|
|
|
return ''
|
2022-01-19 10:07:11 +00:00
|
|
|
|
2022-04-06 22:54:09 +00:00
|
|
|
|
2022-09-24 06:40:26 +00:00
|
|
|
@app.template_filter("asset")
|
2022-09-27 06:02:02 +00:00
|
|
|
@pass_context
|
|
|
|
def template_asset(ctx, asset_path):
|
2022-09-24 06:40:26 +00:00
|
|
|
return assetcache_path(asset_path)
|
|
|
|
|
|
|
|
|
2022-09-24 07:14:20 +00:00
|
|
|
@app.template_filter("asset_siteimg")
|
|
|
|
def template_asset_siteimg(asset_path):
|
|
|
|
# TODO: Add hashing for these using files.helpers.assetcache
|
|
|
|
return f'/i/{SITE_NAME}/{asset_path}?v=3010'
|
|
|
|
|
|
|
|
|
2022-04-06 22:54:09 +00:00
|
|
|
@app.template_filter("timestamp")
|
|
|
|
def timestamp(timestamp):
|
2022-10-15 18:11:43 +00:00
|
|
|
return make_age_string(timestamp)
|
2022-04-06 22:54:09 +00:00
|
|
|
|
2022-01-19 10:07:11 +00:00
|
|
|
@app.context_processor
|
|
|
|
def inject_constants():
|
2022-05-30 01:43:16 +00:00
|
|
|
return {"environ":environ, "SITE":SITE, "SITE_NAME":SITE_NAME, "SITE_FULL":SITE_FULL,
|
2022-07-08 19:03:04 +00:00
|
|
|
"AUTOJANNY_ID":AUTOJANNY_ID, "PUSHER_ID":PUSHER_ID,
|
2022-09-19 17:51:40 +00:00
|
|
|
"CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "AEVANN_ID":AEVANN_ID,
|
2022-06-24 15:08:57 +00:00
|
|
|
"PIZZASHILL_ID":PIZZASHILL_ID, "DEFAULT_COLOR":DEFAULT_COLOR,
|
2022-09-01 19:12:05 +00:00
|
|
|
"COLORS":COLORS, "time":time, "PERMS":PERMS, "FEATURES":FEATURES,
|
|
|
|
"HOLE_NAME":HOLE_NAME, "HOLE_STYLE_FLAIR":HOLE_STYLE_FLAIR, "HOLE_REQUIRED":HOLE_REQUIRED,
|
2022-10-11 13:19:55 +00:00
|
|
|
"GUMROAD_LINK":GUMROAD_LINK, "DEFAULT_THEME":DEFAULT_THEME, "DESCRIPTION":DESCRIPTION,
|
2022-09-01 19:12:05 +00:00
|
|
|
"has_sidebar":has_sidebar, "has_logo":has_logo, "has_app":has_app,
|
2022-10-05 22:53:36 +00:00
|
|
|
"FP":FP, "NOTIF_MODACTION_JL_MIN":NOTIF_MODACTION_JL_MIN, "cache":cache,
|
2022-10-08 00:43:04 +00:00
|
|
|
"ONLINE_STR":ONLINE_STR, "patron":patron, "DUES":DUES,
|
2022-10-05 22:53:36 +00:00
|
|
|
"SIDEBAR_THREAD":SIDEBAR_THREAD, "BANNER_THREAD":BANNER_THREAD,
|
|
|
|
"BADGE_THREAD":BADGE_THREAD, "SNAPPY_THREAD":SNAPPY_THREAD,
|
|
|
|
"KOFI_TOKEN":KOFI_TOKEN, "KOFI_LINK":KOFI_LINK,
|
|
|
|
"approved_embed_hosts":approved_embed_hosts,
|
|
|
|
"site_settings":app.config['SETTINGS'],
|
2022-10-19 10:39:03 +00:00
|
|
|
"EMAIL":EMAIL, "calc_users":calc_users, "TELEGRAM_LINK":TELEGRAM_LINK,
|
|
|
|
"EMAIL_REGEX_PATTERN":EMAIL_REGEX_PATTERN,
|
2022-10-21 18:39:45 +00:00
|
|
|
"CONTENT_SECURITY_POLICY_DEFAULT":CONTENT_SECURITY_POLICY_DEFAULT,
|
|
|
|
"CONTENT_SECURITY_POLICY_HOME":CONTENT_SECURITY_POLICY_HOME,
|
2022-10-24 22:11:16 +00:00
|
|
|
"current_host": current_host()
|
2022-10-05 22:53:36 +00:00
|
|
|
}
|