From 81b4d603a55c28fcbcba432403afd8bbecddf554 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 19 Jan 2022 12:07:11 +0200 Subject: [PATCH] fds --- files/helpers/const.py | 27 +-------------------------- files/helpers/jinja2.py | 27 +++++++++++++++++++++++++++ files/routes/feeds.py | 2 +- 3 files changed, 29 insertions(+), 27 deletions(-) create mode 100644 files/helpers/jinja2.py diff --git a/files/helpers/const.py b/files/helpers/const.py index 1758265d2..4f7a01c45 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -2,8 +2,6 @@ from os import environ, listdir import re from copy import deepcopy from json import loads -from files.__main__ import app -from .get import get_post SITE = environ.get("DOMAIN", '').strip() SITE_NAME = environ.get("SITE_NAME", '').strip() @@ -794,27 +792,4 @@ NOTIFIED_USERS = { } num_banners = len(listdir('files/assets/images/Drama/banners')) + 1 -num_sidebar = len(listdir('files/assets/images/Drama/sidebar')) + 1 - -@app.template_filter("full_link") -def full_link(url): - - return f"{SITE_FULL}{url}" - -@app.template_filter("app_config") -def app_config(x): - return app.config.get(x) - -@app.template_filter("post_embed") -def post_embed(id, v): - - try: id = int(id) - except: return None - - p = get_post(id, v, graceful=True) - - return render_template("submission_listing.html", listing=[p], v=v) - -@app.context_processor -def inject_constants(): - return {"num_banners":num_banners, "num_sidebar":num_sidebar, "environ":environ, "SITE_NAME":SITE_NAME, "AUTOJANNY_ID":AUTOJANNY_ID, "NOTIFICATIONS_ID":NOTIFICATIONS_ID, "PUSHER_ID":PUSHER_ID, "CC":CC, "CC_TITLE":CC_TITLE} \ No newline at end of file +num_sidebar = len(listdir('files/assets/images/Drama/sidebar')) + 1 \ No newline at end of file diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py new file mode 100644 index 000000000..1a1253982 --- /dev/null +++ b/files/helpers/jinja2.py @@ -0,0 +1,27 @@ +from files.__main__ import app +from .get import * +from os import listdir, environ +from .const import * + +@app.template_filter("full_link") +def full_link(url): + + return f"{SITE_FULL}{url}" + +@app.template_filter("app_config") +def app_config(x): + return app.config.get(x) + +@app.template_filter("post_embed") +def post_embed(id, v): + + try: id = int(id) + except: return None + + p = get_post(id, v, graceful=True) + + return render_template("submission_listing.html", listing=[p], v=v) + +@app.context_processor +def inject_constants(): + return {"num_banners":num_banners, "num_sidebar":num_sidebar, "environ":environ, "SITE_NAME":SITE_NAME, "AUTOJANNY_ID":AUTOJANNY_ID, "NOTIFICATIONS_ID":NOTIFICATIONS_ID, "PUSHER_ID":PUSHER_ID, "CC":CC, "CC_TITLE":CC_TITLE} diff --git a/files/routes/feeds.py b/files/routes/feeds.py index d7e4e857c..06e7e2592 100644 --- a/files/routes/feeds.py +++ b/files/routes/feeds.py @@ -1,7 +1,7 @@ import html from .front import frontlist from datetime import datetime -from files.helpers.const import * +from files.helpers.jinja2 import full_link from files.helpers.get import * from yattag import Doc from files.helpers.wrappers import *