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 --- view_functions.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'view_functions.py') diff --git a/view_functions.py b/view_functions.py index 64dcfe0..f86952d 100644 --- a/view_functions.py +++ b/view_functions.py @@ -4,7 +4,6 @@ about files and paths. """ import os from siteconfig import siteconfig -from server import app def default_context(): @@ -14,8 +13,8 @@ def default_context(): make up the navbar """ return { - 'domain': app.config['DOMAIN'], - 'navbar': sorted(app.config['MAIN_SITE_DIRS']), + 'domain': siteconfig.DOMAIN, + 'navbar': siteconfig.MAIN_SITE_DIRS, } @@ -49,14 +48,10 @@ def index_dir(path): links = f.readlines() elif obj == siteconfig.DESC_FILE: description = True - elif obj.startswith('.'): - continue - else: + elif not obj.startswith('.'): files.append(obj) elif os.path.isdir(path + '/' + obj): - if obj.startswith('.'): - continue - else: + if not obj.startswith('.'): dirs.append(obj) return sorted(dirs), sorted(files), sorted(links), description @@ -64,8 +59,10 @@ def index_dir(path): def is_hidden_path(path): """ - Tests if last object specified in `path` is hidden. - Inspired by Unix. On Windows, directories won't actually be "hidden" but - they are still not indexed by this program + Tests if the URI path requested by the user, has any hidden paths + which should not be rendered """ - return path.split('/')[-1].startswith('.') + for d in path.split('/'): + if d.startswith('.'): + return True + return False -- cgit v1.2.3