From 7c16beb6538ccf024b552d475a26b9345bf550ec Mon Sep 17 00:00:00 2001 From: mjfernez Date: Mon, 18 Oct 2021 19:53:03 -0400 Subject: Fixes is_hidden_path, RSS. Adds txt support, RSS This commit fixes the is_hidden_path function to work for subdirectories and also remove entries from the RSS file view_functions.py has been refactored use the siteconfig file instead of the app to remove unecessary imports and avoid circularly imports This also moves logic for the default site directories from server.py to siteconfig.py so it's accessible before the app runs. This has the benefit of cleaning up the server file, but the drawback of adding the os import to the siteconfig file. Settings have been moved around for (hopefully) easier reading --- server.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'server.py') diff --git a/server.py b/server.py index 14c4182..ab66ccc 100644 --- a/server.py +++ b/server.py @@ -1,7 +1,6 @@ """ server.py - sets up and runs the flask server """ -import os from flask import Flask from siteconfig import siteconfig from flask_compress import Compress @@ -20,23 +19,8 @@ def setup(): setup - sets up the app according to the settings specified (or not specified) in `siteconfig` """ - if siteconfig.SECRET_KEY: - app.config['SECRET_KEY'] = siteconfig.SECRET_KEY - else: - SECRET_KEY = os.urandom(32) - app.config['SECRET_KEY'] = SECRET_KEY - - if siteconfig.MAIN_SITE_DIRS: - app.config.update({'MAIN_SITE_DIRS': siteconfig.MAIN_SITE_DIRS}) - else: - s = "./templates/site/" - top_dirs = [ - x - for x in os.listdir(s) - if os.path.isdir(s + x) and not x.startswith(".") - ] - app.config.update({'MAIN_SITE_DIRS': sorted(top_dirs)}) - + app.config['SECRET_KEY'] = siteconfig.SECRET_KEY + app.config.update({'MAIN_SITE_DIRS': siteconfig.MAIN_SITE_DIRS}) app.config.update({'DOMAIN': siteconfig.DOMAIN}) app.config.update({'HOME_TITLE': siteconfig.HOME_TITLE}) app.config.update( @@ -45,6 +29,7 @@ def setup(): app.config.update({'RSS_CHANNEL': get_rss_channel()}) app.config.update({'TEMPLATES_AUTO_RELOAD': True}) + # Setup needs to come first to be compatible with wsgi setup() compress.init_app(app) -- cgit v1.2.3