diff options
-rw-r--r-- | config.py | 33 | ||||
-rw-r--r-- | siteconfig.py | 41 |
2 files changed, 40 insertions, 34 deletions
diff --git a/config.py b/config.py new file mode 100644 index 0000000..6f796fe --- /dev/null +++ b/config.py @@ -0,0 +1,33 @@ +import os + +class config: + # 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 + # 'thoughts/rants/donread.txt' + RSS_OMIT = [] + with open('omit') as f: + 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) + + GENERATED_SECRET_KEY = os.urandom(32) + diff --git a/siteconfig.py b/siteconfig.py index 8917a20..2f0f592 100644 --- a/siteconfig.py +++ b/siteconfig.py @@ -1,38 +1,11 @@ """ siteconfig.py - user editable configuration file """ -import os - - -class siteconfig: - # 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 - # 'thoughts/rants/donread.txt' - RSS_OMIT = [] - with open('omit') as f: - 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) +# config defines default configuration values which you can override in +# this file +from config import config +class siteconfig(config): # REQUIRED SETTINGS # DOMAIN = "example.net" # Your site here! @@ -50,16 +23,16 @@ class siteconfig: # these still have to be in ./templates/site MAIN_SITE_DIRS = sorted( - DEFAULT_SITE_DIRS + config.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 = os.urandom(32) # replace with random number. + SECRET_KEY = config.GENERATED_SECRET_KEY # replace with random number. # Options for Flask Compress # see here https://pypi.org/project/Flask-Compress/ - COMPRESS_MIMETYPES = list(MIMETYPES.values()) + COMPRESS_MIMETYPES = list(config.MIMETYPES.values()) # Options for Flask Caching # https://flask-caching.readthedocs.io/en/latest/#configuring-flask-caching |