aboutsummaryrefslogtreecommitdiffstats
path: root/siteconfig.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 /siteconfig.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 'siteconfig.py')
-rw-r--r--siteconfig.py38
1 files changed, 27 insertions, 11 deletions
diff --git a/siteconfig.py b/siteconfig.py
index 4c60674..8917a20 100644
--- a/siteconfig.py
+++ b/siteconfig.py
@@ -1,28 +1,24 @@
"""
siteconfig.py - user editable configuration file
"""
+import os
class siteconfig:
- # REQUIRED SETTINGS#
-
- DOMAIN = "example.net" # Your site here!
- HOME_TITLE = "WELCOME"
- LINKS_FILE = ".links" # ".lnx" if you like
- DESC_FILE = ".description" # ".desc"
- DEFAULT_MIMETYPE = "application/octet-stream"
- # ^This usually prompts a browser to download a file if the mime
- # type is unknown. A good alternative might be "text/plain"
+ # BACKGROUND SETTINGS #
+ # These don't need to be changed
# This setting is required, don't change it unless you're running
# things in different directories
BASE_DIR = "./templates/site/"
+
# Add your desired mimetypes to the csv file
MIMETYPES = {}
with open('mimetypes.csv') as f:
for line in f.readlines():
ext, mime = line.strip().split(',')
MIMETYPES.update({ext: mime})
+
# This reads your omit file.
# Entries should be the full path from the site directory.
# For example "dontread.txt" in this project is entered as
@@ -32,16 +28,34 @@ class siteconfig:
for line in f.readlines():
RSS_OMIT.append(BASE_DIR + line.strip())
+ DEFAULT_SITE_DIRS = []
+ for x in os.listdir(BASE_DIR):
+ if os.path.isdir(BASE_DIR + x) and not x.startswith("."):
+ DEFAULT_SITE_DIRS.append(x)
+
+ # REQUIRED SETTINGS #
+
+ DOMAIN = "example.net" # Your site here!
+ HOME_TITLE = "WELCOME"
+ LINKS_FILE = ".links" # ".lnx" if you like
+ DESC_FILE = ".description" # ".desc"
+ DEFAULT_MIMETYPE = "application/octet-stream"
+ # ^This usually prompts a browser to download a file if the mime
+ # type is unknown. A good alternative might be "text/plain"
+
# OPTIONAL SETTINGS #
# Be default, ALL directories in the site toolbar are contained in
# ./templates/site/. You can change this to only specific directories, but
# these still have to be in ./templates/site
- MAIN_SITE_DIRS = None # ["dir1", "dir2", "dir3"]
+
+ MAIN_SITE_DIRS = sorted(
+ DEFAULT_SITE_DIRS
+ ) # ["dir1", "dir2", "dir3"]
# Set a custom secret key. If not set, it will be generated
# Most of the time, you don't need to set this!
- SECRET_KEY = None # Something random.
+ SECRET_KEY = os.urandom(32) # replace with random number.
# Options for Flask Compress
# see here https://pypi.org/project/Flask-Compress/
@@ -90,4 +104,6 @@ class siteconfig:
'WEBMASTER': "webmaster@example.net",
# Max amount of paragraphs to print in each description
'DESCRIPTION_LENGTH': 3,
+ # File extensions to include in RSS updates
+ 'RSS_FILE_EXT': ["txt", "html", "html!"],
}