a fresh start :)
This commit is contained in:
@@ -2,7 +2,6 @@ from flask import Flask, session, request, render_template
|
||||
from dotenv import load_dotenv
|
||||
from .models import Avatars, Users, PostHistory, Posts, MOTD, BadgeUploads, Sessions
|
||||
from .auth import digest
|
||||
from .routes.users import is_logged_in, get_active_user, get_prefers_theme
|
||||
from .constants import (
|
||||
PermissionLevel, permission_level_string,
|
||||
InfoboxKind, InfoboxHTMLClass,
|
||||
@@ -196,36 +195,6 @@ def create_app():
|
||||
|
||||
cache.init_app(app)
|
||||
|
||||
css_dir = 'data/static/css/'
|
||||
allowed_themes = []
|
||||
for f in os.listdir(css_dir):
|
||||
if not os.path.isfile(os.path.join(css_dir, f)):
|
||||
continue
|
||||
theme_name = os.path.splitext(os.path.basename(f))[0]
|
||||
allowed_themes.append(theme_name)
|
||||
|
||||
allowed_themes.sort(key=(lambda x: (x != 'style', x)))
|
||||
app.config['allowed_themes'] = allowed_themes
|
||||
|
||||
from app.routes.app import bp as app_bp
|
||||
from app.routes.topics import bp as topics_bp
|
||||
from app.routes.threads import bp as threads_bp
|
||||
from app.routes.users import bp as users_bp
|
||||
from app.routes.mod import bp as mod_bp
|
||||
from app.routes.api import bp as api_bp
|
||||
from app.routes.posts import bp as posts_bp
|
||||
from app.routes.hyperapi import bp as hyperapi_bp
|
||||
from app.routes.guides import bp as guides_bp
|
||||
app.register_blueprint(app_bp)
|
||||
app.register_blueprint(topics_bp)
|
||||
app.register_blueprint(threads_bp)
|
||||
app.register_blueprint(users_bp)
|
||||
app.register_blueprint(mod_bp)
|
||||
app.register_blueprint(api_bp)
|
||||
app.register_blueprint(posts_bp)
|
||||
app.register_blueprint(hyperapi_bp)
|
||||
app.register_blueprint(guides_bp)
|
||||
|
||||
with app.app_context():
|
||||
from .schema import create as create_tables
|
||||
from .migrations import run_migrations
|
||||
@@ -265,16 +234,9 @@ def create_app():
|
||||
"SIG_BANNED_TAGS": SIG_BANNED_TAGS,
|
||||
}
|
||||
|
||||
@app.context_processor
|
||||
def inject_auth():
|
||||
return {"is_logged_in": is_logged_in, "get_active_user": get_active_user, "active_user": get_active_user()}
|
||||
|
||||
@app.context_processor
|
||||
def inject_funcs():
|
||||
from .routes.threads import get_post_url
|
||||
return {
|
||||
'get_post_url': get_post_url,
|
||||
'get_prefers_theme': get_prefers_theme,
|
||||
'get_motds': MOTD.get_all,
|
||||
'get_time_now': lambda: int(time.time()),
|
||||
}
|
||||
@@ -302,16 +264,6 @@ def create_app():
|
||||
def babycode_strict_filter(markup, nofrag=False):
|
||||
return babycode_to_html(markup, banned_tags=STRICT_BANNED_TAGS, fragment=not nofrag).result
|
||||
|
||||
@app.template_filter('extract_h2')
|
||||
def extract_h2(content):
|
||||
import re
|
||||
pattern = r'<h2\s+id="([^"]+)"[^>]*>(.*?)<\/h2>'
|
||||
matches = re.findall(pattern, content, re.IGNORECASE | re.DOTALL)
|
||||
return [
|
||||
{'id': id_.strip(), 'text': text.strip()}
|
||||
for id_, text in matches
|
||||
]
|
||||
|
||||
@app.template_filter('basename_noext')
|
||||
def basename_noext(subj):
|
||||
return os.path.splitext(os.path.basename(subj))[0]
|
||||
|
||||
Reference in New Issue
Block a user