Merge branch 'main' of https://gitlab.com/sagev9000/undercover
This commit is contained in:
commit
80350b370a
|
@ -1,33 +1,34 @@
|
||||||
# Copyright Sage Vaillancourt 2021
|
# Copyright Sage Vaillancourt 2021
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from flask import Flask
|
||||||
from flask import (
|
|
||||||
Flask, redirect, url_for, render_template, send_from_directory
|
|
||||||
)
|
|
||||||
|
|
||||||
import writing
|
import writing
|
||||||
|
|
||||||
INDEX = None
|
INDEX = None
|
||||||
|
|
||||||
|
|
||||||
def optimize_css():
|
def optimize_css(css: str) -> str:
|
||||||
import re
|
import re
|
||||||
|
minified_with_comments = "".join(list(map(
|
||||||
|
lambda line: re.sub(r'\s*([:{])\s*', '\1', re.sub(r'^\s*', '', line)),
|
||||||
|
css.split('\n')
|
||||||
|
)))
|
||||||
|
return re.sub(r'/\*[\s\S]*?\*/', "", minified_with_comments)
|
||||||
|
|
||||||
|
|
||||||
|
def optimize_css_file():
|
||||||
root = os.path.dirname(os.getcwd())
|
root = os.path.dirname(os.getcwd())
|
||||||
static_dir = root + '/undercover/flaskr/static/'
|
static_dir = root + '/undercover/flaskr/static/'
|
||||||
css = open(static_dir + 'styles.css', 'r').read()
|
css = open(static_dir + 'styles.css', 'r').read()
|
||||||
minified_with_comments = "".join(list(map(
|
minified = optimize_css(css)
|
||||||
lambda line: re.sub(r':\s*', ':', re.sub(r'^\s*', '', line)),
|
|
||||||
css.split('\n')
|
|
||||||
)))
|
|
||||||
minified = re.sub(r'/\*[\s\S]*?\*/', "", minified_with_comments)
|
|
||||||
minified_file = open(static_dir + 'styles_min.css', 'w')
|
minified_file = open(static_dir + 'styles_min.css', 'w')
|
||||||
minified_file.write(minified)
|
minified_file.write(minified)
|
||||||
minified_file.close()
|
minified_file.close()
|
||||||
|
|
||||||
|
|
||||||
def create_app(test_config=None):
|
def create_app(test_config=None):
|
||||||
optimize_css()
|
optimize_css_file()
|
||||||
|
|
||||||
app = Flask(__name__, instance_relative_config=True)
|
app = Flask(__name__, instance_relative_config=True)
|
||||||
app.config.from_mapping(
|
app.config.from_mapping(
|
||||||
|
@ -40,10 +41,7 @@ def create_app(test_config=None):
|
||||||
else:
|
else:
|
||||||
app.config.from_mapping(test_config)
|
app.config.from_mapping(test_config)
|
||||||
|
|
||||||
try:
|
os.makedirs(app.instance_path, exist_ok=True)
|
||||||
os.makedirs(app.instance_path)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
app.register_blueprint(
|
app.register_blueprint(
|
||||||
writing.writing_blueprint,
|
writing.writing_blueprint,
|
||||||
|
|
|
@ -24,7 +24,7 @@ body {
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
font-family: sans;
|
font-family: sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h2 {
|
h1, h2 {
|
||||||
|
@ -46,14 +46,11 @@ label {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #eee;
|
color: #eee;
|
||||||
background-color: #757575;
|
background-color: #757575;
|
||||||
padding-top: 0.15em;
|
padding: 0.15em 0.5em;
|
||||||
padding-bottom: 0.15em;
|
|
||||||
padding-left: 0.5em;
|
|
||||||
padding-right: 0.5em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input, textarea {
|
input, textarea {
|
||||||
font-family: sans;
|
font-family: sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Small screens */
|
/* Small screens */
|
||||||
|
|
Loading…
Reference in New Issue