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