Add basic CSS minification.
Added correct lang writing.html
This commit is contained in:
parent
0d65f2d6cf
commit
4f8bfe846f
|
@ -16,6 +16,8 @@ temp/
|
||||||
.coverage
|
.coverage
|
||||||
htmlcov/
|
htmlcov/
|
||||||
|
|
||||||
|
*_min*
|
||||||
|
|
||||||
dist/
|
dist/
|
||||||
build/
|
build/
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
|
|
|
@ -1,17 +1,32 @@
|
||||||
# Copyright Sage Vaillancourt 2021
|
# Copyright Sage Vaillancourt 2021
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from flask import (
|
from flask import (
|
||||||
Flask, redirect, url_for, render_template, send_from_directory
|
Flask, redirect, url_for, render_template, send_from_directory
|
||||||
)
|
)
|
||||||
|
|
||||||
import subprocess
|
|
||||||
import time
|
|
||||||
|
|
||||||
import writing
|
import writing
|
||||||
|
|
||||||
|
def optimize_css():
|
||||||
|
import re
|
||||||
|
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: line if 'media' in line else line.replace(' ', ''),
|
||||||
|
css.split('\n')
|
||||||
|
)))
|
||||||
|
minified = re.sub( r'/\*[\s\S]*?\*/', "", minified_with_comments)
|
||||||
|
minified_file = open(static_dir + 'styles_min.css', 'w')
|
||||||
|
minified_file.write(minified)
|
||||||
|
minified_file.close()
|
||||||
|
|
||||||
def create_app(test_config=None):
|
def create_app(test_config=None):
|
||||||
|
optimize_css()
|
||||||
|
|
||||||
app = Flask(__name__, instance_relative_config=True)
|
app = Flask(__name__, instance_relative_config=True)
|
||||||
app.config.from_mapping(
|
app.config.from_mapping(
|
||||||
SECRET_KEY='dev',
|
SECRET_KEY='dev',
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" type="text/css" href="
|
<link rel="stylesheet" type="text/css" href="
|
||||||
{{ url_for('static', filename='styles.css') }}">
|
{{ url_for('static', filename='styles_min.css') }}">
|
||||||
<meta name="viewport" content="user-scalable=no">
|
<meta name="viewport" content="user-scalable=no">
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function getCookie(cname) {
|
function getCookie(cname) {
|
||||||
|
|
Loading…
Reference in New Issue