Skip to content

Commit

Permalink
Merge pull request #1 from edx/db/harvardx
Browse files Browse the repository at this point in the history
avoid URL rewriting
  • Loading branch information
lduarte1991 committed May 20, 2014
2 parents 0c1b045 + 75ff35e commit 4f981d9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
14 changes: 8 additions & 6 deletions common/djangoapps/pipeline_mako/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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, {})
if package:
package = {package_name: package}
Expand All @@ -15,26 +15,28 @@ def compressed_css(package_name):
package = packager.package_for('css', package_name)

if settings.PIPELINE:
return render_css(package, package.output_filename)
return render_css(package, package.output_filename, raw=raw)
else:
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"
context = package.extra_context

url = try_staticfiles_lookup(path)
if raw:
url += "?raw"
context.update({
'type': guess_type(path, 'text/css'),
'url': url,
})
return render_to_string(template_name, context)


def render_individual_css(package, paths):
tags = [render_css(package, path) for path in paths]
def render_individual_css(package, paths, raw=False):
tags = [render_css(package, path, raw) for path in paths]
return '\n'.join(tags)


Expand Down
10 changes: 5 additions & 5 deletions common/djangoapps/pipeline_mako/templates/static_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
from pipeline_mako import compressed_css, compressed_js
%>

<%def name='url(file)'><%
<%def name='url(file, raw=False)'><%
try:
url = staticfiles_storage.url(file)
except:
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']:
${compressed_css(group)}
${compressed_css(group, raw=raw)}
% else:
% 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
%endif
</%def>
Expand Down
24 changes: 12 additions & 12 deletions lms/templates/textannotation.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<%! from django.utils.translation import ugettext as _ %>
<%namespace name='static' file='/static_content.html'/>
<%static:css group='style-vendor-tinymce-content'/>
<%static:css group='style-vendor-tinymce-skin'/>
<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/jquery.tinymce.min.js')}" />
${static.css(group='style-vendor-tinymce-content', raw=True)}
${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', raw=True)}" />
<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-header">
Expand Down Expand Up @@ -48,9 +48,9 @@
$(this).parents('.annotatable-section:first').find('.annotatable-instructions')[slideMethod]();
}
$('.annotatable-toggle-instructions').on('click', onClickHideInstructions);

//Grab uri of the course
var parts = window.location.href.split("/"),
var parts = window.location.href.split("/"),
uri = '';
for (var index = 0; index <= 9; index += 1) uri += parts[index]+"/"; //Get the unit url
//Change uri in cms
Expand All @@ -67,16 +67,16 @@
optionsAnnotator: {
permissions:{
user: {
id:"${user.email}",
id:"${user.email}",
name:"${user.username}"
},
userString: function (user) {
if (user && user.name)
if (user && user.name)
return user.name;
return user;
},
userId: function (user) {
if (user && user.id)
if (user && user.id)
return user.id;
return user;
},
Expand All @@ -100,7 +100,7 @@
}
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
token = tokens[_i];

if (this.userId(user) === token) {

return true;
Expand Down Expand Up @@ -168,15 +168,15 @@

var imgURLRoot = "${settings.STATIC_URL}" + "js/vendor/ova/catch/img/";
tinymce.baseURL = "${settings.STATIC_URL}" + "js/vendor/tinymce/js/tinymce";

//remove old instances
if (Annotator._instances.length !== 0) {
$('#textHolder').annotator("destroy");
}
delete ova;
//Load the plugin Video/Text Annotation
var ova = new OpenVideoAnnotation.Annotator($('#textHolder'),options);

//Catch
var annotator = ova.annotator,
catchOptions = {
Expand Down

0 comments on commit 4f981d9

Please sign in to comment.