From 5dd4e19c0bd3790b7808c89a1a1681ffe41218e4 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 23 Jul 2012 10:24:50 -0400 Subject: [PATCH 1/4] Move vendor js into a single file --- lms/envs/common.py | 31 +++++++++++++++++++++++++++---- lms/templates/main.html | 10 ++++------ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index db156ef3f2..b07baaec2c 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -301,19 +301,42 @@ PIPELINE_CSS = { PIPELINE_ALWAYS_RECOMPILE = ['sass/application.scss', 'sass/ie.scss'] -courseware_only_js = [PROJECT_ROOT / 'static/coffee/src/' + pth + '.coffee' for pth in ['courseware', 'histogram', 'navigation', 'time', ] ] -courseware_only_js += [pth for pth in glob2.glob(PROJECT_ROOT / 'static/coffee/src/modules/**/*.coffee') ] +courseware_only_js = [ + PROJECT_ROOT / 'static/coffee/src/' + pth + '.coffee' + for pth + in ['courseware', 'histogram', 'navigation', 'time', ] +] +courseware_only_js += [ + pth for pth + in glob2.glob(PROJECT_ROOT / 'static/coffee/src/modules/**/*.coffee') +] + +main_vendor_js = [ + 'js/vendor/jquery.min.js', + 'js/vendor/jquery-ui.min.js', + 'js/vendor/swfobject/swfobject.js', + 'js/vendor/jquery.cookie.js', + 'js/vendor/jquery.qtip.min.js', +] PIPELINE_JS = { 'application': { # Application will contain all paths not in courseware_only_js - 'source_filenames': [pth.replace(PROJECT_ROOT / 'static/', '') for pth in glob2.glob(PROJECT_ROOT / 'static/coffee/src/**/*.coffee') if pth not in courseware_only_js], + 'source_filenames': [ + pth.replace(PROJECT_ROOT / 'static/', '') + for pth in glob2.glob(PROJECT_ROOT / 'static/coffee/src/**/*.coffee')\ + if pth not in courseware_only_js + ] + ['js/form.ext.js'], 'output_filename': 'js/application.js' }, - 'courseware' : { + 'courseware': { 'source_filenames': [pth.replace(PROJECT_ROOT / 'static/', '') for pth in courseware_only_js], 'output_filename': 'js/courseware.js' }, + 'main_vendor': { + 'source_filenames': main_vendor_js, + 'output_filename': 'js/main_vendor.js', + }, 'spec': { 'source_filenames': [pth.replace(PROJECT_ROOT / 'static/', '') for pth in glob2.glob(PROJECT_ROOT / 'static/coffee/spec/**/*.coffee')], 'output_filename': 'js/spec.js' diff --git a/lms/templates/main.html b/lms/templates/main.html index 6182ecf1b2..7c9d291bf1 100644 --- a/lms/templates/main.html +++ b/lms/templates/main.html @@ -22,18 +22,16 @@ % endif - - - - - - % if settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: + <%static:js group='main_vendor'/> <%static:js group='application'/> % endif % if not settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: + % for jsfn in [ '/static/%s' % x.replace('.coffee','.js') for x in settings.PIPELINE_JS['main_vendor']['source_filenames'] ]: + + % endfor % for jsfn in [ '/static/%s' % x.replace('.coffee','.js') for x in settings.PIPELINE_JS['application']['source_filenames'] ]: % endfor From 5915532a5784e8cfd97f1f0c43e11d2d95227d65 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Mon, 23 Jul 2012 10:40:13 -0400 Subject: [PATCH 2/4] Consolidate code used for disabling USE_DJANGO_PIPELINE feature --- cms/templates/base.html | 9 -------- .../templates/static_content.html | 22 +++++++++++++++++-- lms/templates/courseware.html | 9 -------- lms/templates/main.html | 21 ------------------ 4 files changed, 20 insertions(+), 41 deletions(-) diff --git a/cms/templates/base.html b/cms/templates/base.html index 935917b11a..92f37c0a51 100644 --- a/cms/templates/base.html +++ b/cms/templates/base.html @@ -6,11 +6,7 @@ - % if settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: <%static:css group='base-style'/> - % else: - - % endif <%block name="title"></%block> @@ -27,12 +23,7 @@ - % if settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: <%static:js group='main'/> - % else: - - % endif - <%static:js group='module-js'/> diff --git a/common/djangoapps/pipeline_mako/templates/static_content.html b/common/djangoapps/pipeline_mako/templates/static_content.html index 00c2c4dff4..225e3e0542 100644 --- a/common/djangoapps/pipeline_mako/templates/static_content.html +++ b/common/djangoapps/pipeline_mako/templates/static_content.html @@ -5,6 +5,24 @@ from static_replace import replace_urls %> <%def name='url(file)'>${staticfiles_storage.url(file)} -<%def name='css(group)'>${compressed_css(group)} -<%def name='js(group)'>${compressed_js(group)} + +<%def name='css(group)'> + % if settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: + ${compressed_css(group)} + % else: + % for filename in settings.PIPELINE_CSS[group]['source_filenames']: + + % endfor + %endif + +<%def name='js(group)'> + % if settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: + ${compressed_js(group)} + % else: + % for filename in settings.PIPELINE_JS[group]['source_filenames']: + + % endfor + %endif + + <%def name='replace_urls(text)'>${replace_urls(text)} diff --git a/lms/templates/courseware.html b/lms/templates/courseware.html index 1a72a6eab7..29178374fe 100644 --- a/lms/templates/courseware.html +++ b/lms/templates/courseware.html @@ -24,16 +24,7 @@ - % if settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: <%static:js group='courseware'/> - % endif - - % if not settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: - % for jsfn in [ '/static/%s' % x.replace('.coffee','.js') for x in settings.PIPELINE_JS['courseware']['source_filenames'] ]: - - % endfor - % endif - <%include file="mathjax_include.html" /> diff --git a/lms/templates/main.html b/lms/templates/main.html index 7c9d291bf1..b8bac37dd2 100644 --- a/lms/templates/main.html +++ b/lms/templates/main.html @@ -8,34 +8,13 @@ -% if settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: <%static:css group='application'/> -% endif -% if not settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: - - -% endif - - -% if settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: <%static:js group='main_vendor'/> <%static:js group='application'/> -% endif - -% if not settings.MITX_FEATURES['USE_DJANGO_PIPELINE']: - % for jsfn in [ '/static/%s' % x.replace('.coffee','.js') for x in settings.PIPELINE_JS['main_vendor']['source_filenames'] ]: - - % endfor - % for jsfn in [ '/static/%s' % x.replace('.coffee','.js') for x in settings.PIPELINE_JS['application']['source_filenames'] ]: - - % endfor -% endif + +
@@ -110,25 +134,3 @@
- - diff --git a/lms/templates/gradebook.html b/lms/templates/gradebook.html index 12f820c8c9..7c2908dc77 100644 --- a/lms/templates/gradebook.html +++ b/lms/templates/gradebook.html @@ -1,10 +1,13 @@ <%inherit file="main.html" /> <%namespace name='static' file='static_content.html'/> -<%block name="headextra"> +<%block name="js_extra"> + + +<%block name="headextra">