Enable DEBUGGING mode, which loads the individual script files rather than the minimized bundles created by grunt
This commit is contained in:
parent
9e4a8097af
commit
ede8ed21f4
4 changed files with 28 additions and 9 deletions
|
@ -115,15 +115,35 @@ def random_string():
|
||||||
random = SystemRandom()
|
random = SystemRandom()
|
||||||
return ''.join([random.choice(string.ascii_uppercase + string.digits) for _ in range(8)])
|
return ''.join([random.choice(string.ascii_uppercase + string.digits) for _ in range(8)])
|
||||||
|
|
||||||
|
def list_files(path, extension):
|
||||||
|
import os
|
||||||
|
def matches(f):
|
||||||
|
return os.path.splitext(f)[1] == '.' + extension
|
||||||
|
|
||||||
|
def join_path(dp, f):
|
||||||
|
# Remove the static/ prefix. It is added in the template.
|
||||||
|
return os.path.join(dp, f)[len('static/'):]
|
||||||
|
|
||||||
|
filepath = 'static/' + path
|
||||||
|
return [join_path(dp, f) for dp, dn, files in os.walk(filepath) for f in files if matches(f)]
|
||||||
|
|
||||||
def render_page_template(name, **kwargs):
|
def render_page_template(name, **kwargs):
|
||||||
|
if app.config.get('DEBUGGING', False):
|
||||||
|
# If DEBUGGING is enabled, then we load the full set of individual JS and CSS files
|
||||||
|
# from the file system.
|
||||||
|
library_styles = list_files('lib', 'css')
|
||||||
|
main_styles = list_files('css', 'css')
|
||||||
|
library_scripts = list_files('lib', 'js')
|
||||||
|
main_scripts = list_files('js', 'js')
|
||||||
|
cache_buster = 'debugging'
|
||||||
|
else:
|
||||||
library_styles = []
|
library_styles = []
|
||||||
main_styles = ['dist/quay-frontend.css']
|
main_styles = ['dist/quay-frontend.css']
|
||||||
|
|
||||||
library_scripts = []
|
library_scripts = []
|
||||||
main_scripts = ['dist/quay-frontend.min.js']
|
main_scripts = ['dist/quay-frontend.min.js']
|
||||||
|
|
||||||
cache_buster = random_string()
|
cache_buster = random_string()
|
||||||
|
|
||||||
|
|
||||||
resp = make_response(render_template(name, route_data=json.dumps(get_route_data()),
|
resp = make_response(render_template(name, route_data=json.dumps(get_route_data()),
|
||||||
main_styles=main_styles,
|
main_styles=main_styles,
|
||||||
library_styles=library_styles,
|
library_styles=library_styles,
|
||||||
|
|
|
@ -25,8 +25,7 @@ module.exports = function(grunt) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
src: ['../static/lib/**/*.js', '../static/js/*.js', '!../static/lib/jquery.overscroll.min.js',
|
src: ['../static/lib/**/*.js', '../static/js/*.js', '../static/dist/template-cache.js'],
|
||||||
'../static/dist/template-cache.js'],
|
|
||||||
dest: '../static/dist/<%= pkg.name %>.js'
|
dest: '../static/dist/<%= pkg.name %>.js'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
{% block body_content %}
|
{% block body_content %}
|
||||||
<!-- Note: Must be in the <body> tag -->
|
<!-- Note: Must be in the <body> tag -->
|
||||||
<script src="static/lib/jquery.overscroll.min.js"></script>
|
<script src="static/standalonelib/jquery.overscroll.min.js"></script>
|
||||||
|
|
||||||
<div ng-view></div>
|
<div ng-view></div>
|
||||||
|
|
||||||
|
|
Reference in a new issue