Commit f7daa22c by E. Kolpakov Committed by Jonathan Piacenti

Fixed production deployment issue caused by staticfiles url replacements (see…

Fixed production deployment issue caused by staticfiles url replacements (see replace_static_urls/__init__.py -> replace_static_urls)
parent a1e63c55
...@@ -40,7 +40,7 @@ def render_individual_css(package, paths, raw=False): ...@@ -40,7 +40,7 @@ def render_individual_css(package, paths, raw=False):
return '\n'.join(tags) return '\n'.join(tags)
def compressed_js(package_name): def compressed_js(package_name, raw=False):
package = settings.PIPELINE_JS.get(package_name, {}) package = settings.PIPELINE_JS.get(package_name, {})
if package: if package:
package = {package_name: package} package = {package_name: package}
...@@ -49,19 +49,23 @@ def compressed_js(package_name): ...@@ -49,19 +49,23 @@ def compressed_js(package_name):
package = packager.package_for('js', package_name) package = packager.package_for('js', package_name)
if settings.PIPELINE: if settings.PIPELINE:
return render_js(package, package.output_filename) return render_js(package, package.output_filename, raw=raw)
else: else:
paths = packager.compile(package.paths) paths = packager.compile(package.paths)
templates = packager.pack_templates(package) templates = packager.pack_templates(package)
return render_individual_js(package, paths, templates) return render_individual_js(package, paths, templates, raw=raw)
def render_js(package, path): def render_js(package, path, raw=False):
template_name = package.template_name or "mako/js.html" template_name = package.template_name or "mako/js.html"
context = package.extra_context context = package.extra_context
url = try_staticfiles_lookup(path)
if raw:
url += "?raw"
context.update({ context.update({
'type': guess_type(path, 'text/javascript'), 'type': guess_type(path, 'text/javascript'),
'url': try_staticfiles_lookup(path) 'url': url
}) })
return render_to_string(template_name, context) return render_to_string(template_name, context)
...@@ -74,8 +78,8 @@ def render_inline_js(package, js): ...@@ -74,8 +78,8 @@ def render_inline_js(package, js):
return render_to_string("mako/inline_js.html", context) return render_to_string("mako/inline_js.html", context)
def render_individual_js(package, paths, templates=None): def render_individual_js(package, paths, templates=None, raw=False):
tags = [render_js(package, js) for js in paths] tags = [render_js(package, js, raw) for js in paths]
if templates: if templates:
tags.append(render_inline_js(package, templates)) tags.append(render_inline_js(package, templates))
return '\n'.join(tags) return '\n'.join(tags)
...@@ -28,12 +28,12 @@ except: ...@@ -28,12 +28,12 @@ except:
%endif %endif
</%def> </%def>
<%def name='js(group)'> <%def name='js(group, raw=False)'>
% if settings.FEATURES['USE_DJANGO_PIPELINE']: % if settings.FEATURES['USE_DJANGO_PIPELINE']:
${compressed_js(group)} ${compressed_js(group, raw=raw)}
% else: % else:
% for filename in settings.PIPELINE_JS[group]['source_filenames']: % for filename in settings.PIPELINE_JS[group]['source_filenames']:
<script type="text/javascript" src="${staticfiles_storage.url(filename.replace('.coffee', '.js'))}"></script> <script type="text/javascript" src="${staticfiles_storage.url(filename.replace('.coffee', '.js'))}${"?raw" if raw else ""}"></script>
% endfor % endfor
%endif %endif
</%def> </%def>
......
...@@ -7,11 +7,11 @@ from django_comment_client.permissions import has_permission ...@@ -7,11 +7,11 @@ from django_comment_client.permissions import has_permission
<%namespace name='static' file='../static_content.html'/> <%namespace name='static' file='../static_content.html'/>
<%block name="js_extra"> <%block name="js_extra">
<%static:js group='discussion'/> <%static:js group='discussion' raw='true'/>
</%block> </%block>
<%block name="css_extra"> <%block name="css_extra">
<%static:css group='discussion'/> <%static:css group='discussion' raw='true'/>
</%block> </%block>
<div class="discussion-module" data-discussion-id="${discussion_id | h}"> <div class="discussion-module" data-discussion-id="${discussion_id | h}">
......
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