aboutsummaryrefslogtreecommitdiffstats
path: root/view_functions.py
diff options
context:
space:
mode:
authormjfernez <mjf@mjfer.net>2021-10-18 19:53:03 -0400
committermjfernez <mjf@mjfer.net>2021-10-18 19:53:03 -0400
commit7c16beb6538ccf024b552d475a26b9345bf550ec (patch)
tree3d0d7bde43f8f7db5a3a75e54aa0a904b6c83eaf /view_functions.py
parent04431658597c9b9ae489be3363c6b9478d946fcd (diff)
downloadezcms-7c16beb6538ccf024b552d475a26b9345bf550ec.tar.gz
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
Diffstat (limited to 'view_functions.py')
-rw-r--r--view_functions.py23
1 files changed, 10 insertions, 13 deletions
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