Commit 4f981d99 by lduarte1991

Merge pull request #1 from edx/db/harvardx

avoid URL rewriting
parents 0c1b045f 75ff35e2
...@@ -6,7 +6,7 @@ from pipeline.utils import guess_type ...@@ -6,7 +6,7 @@ from pipeline.utils import guess_type
from static_replace import try_staticfiles_lookup from static_replace import try_staticfiles_lookup
def compressed_css(package_name): def compressed_css(package_name, raw=False):
package = settings.PIPELINE_CSS.get(package_name, {}) package = settings.PIPELINE_CSS.get(package_name, {})
if package: if package:
package = {package_name: package} package = {package_name: package}
...@@ -15,17 +15,19 @@ def compressed_css(package_name): ...@@ -15,17 +15,19 @@ def compressed_css(package_name):
package = packager.package_for('css', package_name) package = packager.package_for('css', package_name)
if settings.PIPELINE: if settings.PIPELINE:
return render_css(package, package.output_filename) return render_css(package, package.output_filename, raw=raw)
else: else:
paths = packager.compile(package.paths) paths = packager.compile(package.paths)
return render_individual_css(package, paths) return render_individual_css(package, paths, raw=raw)
def render_css(package, path): def render_css(package, path, raw=False):
template_name = package.template_name or "mako/css.html" template_name = package.template_name or "mako/css.html"
context = package.extra_context context = package.extra_context
url = try_staticfiles_lookup(path) url = try_staticfiles_lookup(path)
if raw:
url += "?raw"
context.update({ context.update({
'type': guess_type(path, 'text/css'), 'type': guess_type(path, 'text/css'),
'url': url, 'url': url,
...@@ -33,8 +35,8 @@ def render_css(package, path): ...@@ -33,8 +35,8 @@ def render_css(package, path):
return render_to_string(template_name, context) return render_to_string(template_name, context)
def render_individual_css(package, paths): def render_individual_css(package, paths, raw=False):
tags = [render_css(package, path) for path in paths] tags = [render_css(package, path, raw) for path in paths]
return '\n'.join(tags) return '\n'.join(tags)
......
...@@ -3,19 +3,19 @@ from staticfiles.storage import staticfiles_storage ...@@ -3,19 +3,19 @@ from staticfiles.storage import staticfiles_storage
from pipeline_mako import compressed_css, compressed_js from pipeline_mako import compressed_css, compressed_js
%> %>
<%def name='url(file)'><% <%def name='url(file, raw=False)'><%
try: try:
url = staticfiles_storage.url(file) url = staticfiles_storage.url(file)
except: except:
url = file url = file
%>${url}</%def> %>${url}${"?raw" if raw else ""}</%def>
<%def name='css(group)'> <%def name='css(group, raw=False)'>
% if settings.FEATURES['USE_DJANGO_PIPELINE']: % if settings.FEATURES['USE_DJANGO_PIPELINE']:
${compressed_css(group)} ${compressed_css(group, raw=raw)}
% else: % else:
% for filename in settings.PIPELINE_CSS[group]['source_filenames']: % for filename in settings.PIPELINE_CSS[group]['source_filenames']:
<link rel="stylesheet" href="${staticfiles_storage.url(filename.replace('.scss', '.css'))}" type="text/css" media="all" / > <link rel="stylesheet" href="${staticfiles_storage.url(filename.replace('.scss', '.css'))}${"?raw" if raw else ""}" type="text/css" media="all" / >
% endfor % endfor
%endif %endif
</%def> </%def>
......
<%! from django.utils.translation import ugettext as _ %> <%! from django.utils.translation import ugettext as _ %>
<%namespace name='static' file='/static_content.html'/> <%namespace name='static' file='/static_content.html'/>
<%static:css group='style-vendor-tinymce-content'/> ${static.css(group='style-vendor-tinymce-content', raw=True)}
<%static:css group='style-vendor-tinymce-skin'/> ${static.css(group='style-vendor-tinymce-skin', raw=True)}
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/tinymce.full.min.js')}" /> <script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/tinymce.full.min.js', raw=True)}" />
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js')}" /> <script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js', raw=True)}" />
<div class="annotatable-wrapper"> <div class="annotatable-wrapper">
<div class="annotatable-header"> <div class="annotatable-header">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment