/
config.py
120 lines (92 loc) · 3.06 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import os
from pathlib import Path
from dotenv import load_dotenv
from urlpath import URL
load_dotenv()
class Config:
''' Standard configuration '''
# MongoDB config
MONGODB_SETTINGS = {
'db': 'website',
'port': 5009,
'username': 'app',
'password': os.environ.get("DB_PWORD"),
'authentication_source': 'admin'
}
# Flask flatpages configuration
# 1. Pages are loaded on request.
# 2. File name extension for pages is Markdown.
CONTENT_ROOT = 'website/content'
CONTENT_EXTENSION = ['.md', '.markdown'] # 2
CONTENT_HTML_RENDERER = 'website.pages.services.prerender_jinja'
CONTENT_MARKDOWN_EXTENSIONS = ['attr_list', 'md_in_html']
# Images config
IMG_ROOT = 'website/static/img/'
IMG_SOURCE_DIR = 'src'
IMG_OUTPUT_DIR = 'out'
IMG_WIDTHS = [2000, 1600, 1200, 800, 400]
IMG_DEFAULT_WIDTH = 1200
IMG_DISPLAY_WIDTHS = {'min-width: 110ch': '60vw', None: '95vw'}
IMG_FORMATS = ('.jpg', '.webp')
REPROC_IMAGES = os.environ.get('REPROC_IMAGES', False)
# Views config
VIEW_POSTS_DIR_WP = 'archive'
VIEW_TEST = os.environ.get('VIEW_TEST', False)
# External Depedancies
ALPINE_VERSION = '3.4.2'
ALPINE_FILE_PATH = Path('website', 'static', 'js', 'alpine.js')
# CSS config
CSS_PREPROCESSOR = 'sass'
CSS_SRC_DIR = Path('website', 'static', 'scss')
CSS_OUT_DIR = Path('website', 'static', 'css')
SECRET_KEY = os.environ.get('SECRET_KEY')
class DevConfig(Config):
''' Development configuration: running local flask server '''
# from run.py
ENV = 'development'
DEBUG = True
TEMPLATES_AUTO_RELOAD = True
IMG_DOMAIN = URL("/static/img/out/")
VIEW_TEST = True
class ProdConfig(Config):
''' Build configuration: freezing to static files and serving locally '''
ENV = 'production'
IMG_DOMAIN = URL("http://localhost:5003/")
# Manually add fonts to list to incorporate into freezer
FONTS = { # tuple: vf, latin, woff2
'Roboto_Slab': 'RobotoSlab-VariableFont_wght-Latin.woff2',
'Public_Sans': 'PublicSans-VariableFont_wght-Min.woff2',
}
# Frozen Flask config
FREEZER_DESTINATION_IGNORE = ['404.html', 'netlify.toml']
FREEZER_STATIC_IGNORE = [
'fonts/',
'scss/',
'img/',
'css/',
'favicon/',
'js/',
'.DS_Store',
]
FREEZER_IGNORE_404_NOT_FOUND = True
CSS_OUT_DIR = Path('website', 'build', 'static', 'css')
# Flask-HTMLmin
MINIFY_HTML = True
class DeployConfig(ProdConfig):
'''
Deploy configuration: freezing to static files and deploying to netlify
'''
IMG_DOMAIN = URL("https://cdn.tomhallarchery.com/")
# Pynetlify config
NETLIFY_AUTH_TOKEN = os.environ.get('NETLIFY_AUTH_TOKEN')
NETLIFY_ROOT_ID = os.environ.get('NETLIFY_ROOT_ID')
NETLIFY_CDN_ID = os.environ.get('NETLIFY_CDN_ID')
class TestConfig(Config):
TESTING = True
map = {
'base': Config,
'development': DevConfig,
'production': ProdConfig,
'deployment': DeployConfig,
'testing': TestConfig,
}