Skip to content

Instantly share code, notes, and snippets.

@crodjer
Created March 31, 2011 14:45
Show Gist options
  • Save crodjer/896480 to your computer and use it in GitHub Desktop.
Save crodjer/896480 to your computer and use it in GitHub Desktop.
Patch to remove `site` context variable
diff --git a/apps/widget/__init__.py b/apps/widget/__init__.py
index 00c4ea7..2aaad03 100644
--- a/apps/widget/__init__.py
+++ b/apps/widget/__init__.py
@@ -51,8 +51,7 @@ def add_config_based_js_files(context, files, compiled_file_name):
in files])
context['js_use_compiled'] = settings.JS_USE_COMPILED
- context['js_dependencies'] = js_files
- context['site'] = Site.objects.get_current()
+ context['js_dependencies'] = js_files
return context
@@ -63,8 +62,7 @@ def add_js_files(context, use_compiled, js_files, compiled_file_name=None, full_
# might change in future when using cdn to serve static js
context["js_dependencies"] = [full_path(compiled_file_name)]
else:
- context["js_dependencies"] = [full_path(js_file) for js_file in js_files] + full_path_js_files
- context["site"] = Site.objects.get_current()
+ context["js_dependencies"] = [full_path(js_file) for js_file in js_files] + full_path_js_files
return context;
def language_to_map(code, name, percent_done=None):
diff --git a/apps/widget/management/commands/compile_embed.py b/apps/widget/management/commands/compile_embed.py
index a4d2c10..4c4c97c 100644
--- a/apps/widget/management/commands/compile_embed.py
+++ b/apps/widget/management/commands/compile_embed.py
@@ -16,7 +16,7 @@ class Command(BaseCommand):
def _output_embed_to_dir(self, output_dir, version=''):
file_name = 'embed{0}.js'.format(version)
context = widget.add_offsite_js_files(
- {'site': Site.objects.get_current(),
+ {'current_site': Site.objects.get_current(),
'MEDIA_URL': settings.MEDIA_URL})
rendered = render_to_string(
'widget/{0}'.format(file_name), context)
diff --git a/templates/widget/embed.js b/templates/widget/embed.js
index 0e45879..fa140ad 100644
--- a/templates/widget/embed.js
+++ b/templates/widget/embed.js
@@ -58,7 +58,7 @@
{% endfor %}];
var siteConfig = {
- siteURL: 'http://{{site.domain}}',
+ siteURL: 'http://{{current_site.domain}}',
mediaURL: '{{MEDIA_URL}}'
};
@@ -167,4 +167,4 @@
insert();
})();
}
-})();
\ No newline at end of file
+})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment