Use minified output when not in debug mode, and non-minified when debugging.
Update jQuery while we're at it.pull/3/head
parent
afb029e284
commit
bb6a3f9b5b
|
|
@ -11,8 +11,13 @@ MarkupSafe==0.23
|
|||
SQLAlchemy==0.9.8
|
||||
WTForms==2.0.2
|
||||
Werkzeug==0.9.6
|
||||
argparse==1.3.0
|
||||
beautifulsoup4==4.3.2
|
||||
blinker==1.3
|
||||
django-htmlmin==0.7.0
|
||||
html5lib==1.0b3
|
||||
itsdangerous==0.24
|
||||
passlib==1.6.2
|
||||
psycopg2==2.5.2
|
||||
six==1.9.0
|
||||
wsgiref==0.1.2
|
||||
|
|
|
|||
|
|
@ -101,6 +101,9 @@ SECURITY_PASSWORD_SALT = 'SuperSecret3'
|
|||
# Hashing algorithm used for password storage
|
||||
SECURITY_PASSWORD_HASH = 'pbkdf2_sha512'
|
||||
|
||||
# Should HTML be minified on the fly when not in debug mode?
|
||||
MINIFY_HTML = True;
|
||||
|
||||
##########################################################################
|
||||
# User account and settings storage
|
||||
##########################################################################
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ else:
|
|||
server_port = config.DEFAULT_SERVER_PORT
|
||||
|
||||
try:
|
||||
app.run(port=server_port, debug=False)
|
||||
app.run(port=server_port)
|
||||
except IOError:
|
||||
app.logger.error("Error starting the app server: %s", sys.exc_info())
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ from flask.ext.sqlalchemy import SQLAlchemy
|
|||
from flask.ext.security import Security, SQLAlchemyUserDatastore, login_required
|
||||
from flask_security.utils import login_user
|
||||
from flask_mail import Mail
|
||||
from htmlmin.minify import html_minify
|
||||
from settings.settings_model import db, Role, User
|
||||
|
||||
import inspect, imp, logging, os
|
||||
|
|
@ -136,7 +137,21 @@ def create_app(app_name=config.APP_NAME):
|
|||
abort(401)
|
||||
|
||||
login_user(user)
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Minify output
|
||||
##########################################################################
|
||||
@app.after_request
|
||||
def response_minify(response):
|
||||
"""Minify html response to decrease traffic"""
|
||||
if config.MINIFY_HTML and not config.DEBUG:
|
||||
if response.content_type == u'text/html; charset=utf-8':
|
||||
response.set_data(
|
||||
html_minify(response.get_data(as_text=True))
|
||||
)
|
||||
|
||||
return response
|
||||
|
||||
##########################################################################
|
||||
# All done!
|
||||
##########################################################################
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ from settings_model import db, Setting
|
|||
|
||||
def store_setting(setting, value):
|
||||
"""Set a configuration setting for the current user."""
|
||||
db.init_app(current_app)
|
||||
|
||||
data = Setting(user_id=current_user.id, setting=setting, value=value)
|
||||
|
||||
db.session.merge(data)
|
||||
|
|
@ -27,8 +25,6 @@ def store_setting(setting, value):
|
|||
def get_setting(setting, default=None):
|
||||
"""Retrieve a configuration setting for the current user, or return the
|
||||
default value specified by the caller."""
|
||||
db.init_app(current_app)
|
||||
|
||||
data = Setting.query.filter_by(user_id=current_user.id, setting=setting).first()
|
||||
|
||||
if not data or data.value is None:
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
MODULE_NAME = 'settings'
|
||||
|
||||
import config
|
||||
from flask import Blueprint, abort, request
|
||||
from flask import Blueprint, Response, abort, request
|
||||
from flask.ext.security import login_required
|
||||
|
||||
from . import get_setting, store_setting
|
||||
|
|
@ -51,4 +51,8 @@ def get(setting=None, default=None):
|
|||
except:
|
||||
return ''
|
||||
|
||||
return value
|
||||
resp = Response(response=value,
|
||||
status=200,
|
||||
mimetype="text/plain")
|
||||
|
||||
return resp
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
|
@ -15,10 +15,10 @@
|
|||
<meta name="dcterms.dateCopyrighted" content="2014 - 2015">
|
||||
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/jquery-layout/layout-default.css') }}" />
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}" />
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/alertifyjs/alertify.min.css') }}" />
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/alertifyjs/themes/bootstrap.min.css') }}" />
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/jquery-ui/jquery-ui.min.css') }}" />
|
||||
{% if config.DEBUG %}<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.css') }}" />{% else %}<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}" />{% endif %}
|
||||
{% if config.DEBUG %}<link rel="stylesheet" href="{{ url_for('static', filename='css/alertifyjs/alertify.css') }}" />{% else %}<link rel="stylesheet" href="{{ url_for('static', filename='css/alertifyjs/alertify.min.css') }}" />{% endif %}
|
||||
{% if config.DEBUG %}<link rel="stylesheet" href="{{ url_for('static', filename='css/alertifyjs/themes/bootstrap.css') }}" />{% else %}<link rel="stylesheet" href="{{ url_for('static', filename='css/alertifyjs/themes/bootstrap.min.css') }}" />{% endif %}
|
||||
{% if config.DEBUG %}<link rel="stylesheet" href="{{ url_for('static', filename='css/jquery-ui/jquery-ui.css') }}" />{% else %}<link rel="stylesheet" href="{{ url_for('static', filename='css/jquery-ui/jquery-ui.min.css') }}" />{% endif %}
|
||||
|
||||
<style>
|
||||
body {
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
padding-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-theme.min.css') }}">
|
||||
{% if config.DEBUG %}<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-theme.min.css') }}">{% else %}<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-theme.min.css') }}">{% endif %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/overrides.css') }}">
|
||||
|
||||
<script src="{{ url_for('static', filename='js/vendor/modernizr-2.6.2-respond-1.1.0.min.js') }}"></script>
|
||||
|
|
@ -36,11 +36,11 @@
|
|||
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
|
||||
<![endif]-->
|
||||
|
||||
<script src="{{ url_for('static', filename='js/vendor/jquery-1.11.1.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/vendor/bootstrap.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/vendor/alertifyjs/alertify.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/vendor/jquery-ui/jquery-ui.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/vendor/jquery-layout/jquery.layout.min.js') }}"></script>
|
||||
{% if config.DEBUG %}<script src="{{ url_for('static', filename='js/vendor/jquery-1.11.2.js') }}">{% else %}<script src="{{ url_for('static', filename='js/vendor/jquery-1.11.2.min.js') }}">{% endif %}</script>
|
||||
{% if config.DEBUG %}<script src="{{ url_for('static', filename='js/vendor/bootstrap.js') }}">{% else %}<script src="{{ url_for('static', filename='js/vendor/bootstrap.min.js') }}">{% endif %}</script>
|
||||
{% if config.DEBUG %}<script src="{{ url_for('static', filename='js/vendor/alertifyjs/alertify.js') }}">{% else %}<script src="{{ url_for('static', filename='js/vendor/alertifyjs/alertify.min.js') }}">{% endif %}</script>
|
||||
{% if config.DEBUG %}<script src="{{ url_for('static', filename='js/vendor/jquery-ui/jquery-ui.js') }}">{% else %}<script src="{{ url_for('static', filename='js/vendor/jquery-ui/jquery-ui.min.js') }}">{% endif %}</script>
|
||||
{% if config.DEBUG %}<script src="{{ url_for('static', filename='js/vendor/jquery-layout/jquery.layout.js') }}">{% else %}<script src="{{ url_for('static', filename='js/vendor/jquery-layout/jquery.layout.min.js') }}">{% endif %}</script>
|
||||
<script src="{{ url_for('static', filename='js/vendor/jquery-layout/plugins/jquery.layout.state.js') }}"></script>
|
||||
<script>
|
||||
{% include "js/settings.js" %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue