summaryrefslogtreecommitdiffstats
path: root/main/templatetags/cdn.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-09-22 23:16:13 -0500
committerDan McGee <dan@archlinux.org>2010-09-22 23:16:13 -0500
commit47c95a2821d1fb926446d2379d4b2273af5482dc (patch)
treebb55f48b4078c7a0097f5db231e12883addf9ec4 /main/templatetags/cdn.py
parent66d6d33c9b421b14036166e5db311b6d4f0e906c (diff)
downloadarchweb-47c95a2821d1fb926446d2379d4b2273af5482dc.tar.gz
archweb-47c95a2821d1fb926446d2379d4b2273af5482dc.zip
Get secure/unsecure checking actually working
We need a bit more, like actually having something relevant in the RequestContext object, in order for this to all work. Instead of putting the full request in just populate a 'secure' key with a boolean value indicating whether the request is secure. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main/templatetags/cdn.py')
-rw-r--r--main/templatetags/cdn.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/main/templatetags/cdn.py b/main/templatetags/cdn.py
index ef6bb144..ff45e524 100644
--- a/main/templatetags/cdn.py
+++ b/main/templatetags/cdn.py
@@ -11,13 +11,13 @@ class JQueryNode(template.Node):
def render(self, context):
# if we have the request in context, we can check if it is secure and
# serve content from HTTPS instead.
- secure = 'request' in context and context['request'].is_secure()
+ secure = 'secure' in context and context['secure']
+ prefixes = { False: 'http', True: 'https' }
version = '1.4.2'
oncdn = getattr(settings, 'CDN_ENABLED', True)
- if oncdn and secure:
- jquery = 'https://ajax.googleapis.com/ajax/libs/jquery/%s/jquery.min.js' % version
- elif oncdn:
- jquery = 'http://ajax.googleapis.com/ajax/libs/jquery/%s/jquery.min.js' % version
+ if oncdn:
+ jquery = '%s://ajax.googleapis.com/ajax/libs/jquery/' \
+ '%s/jquery.min.js' % (prefixes[secure], version)
else:
jquery = '/media/jquery-%s.min.js' % version
return '<script type="text/javascript" src="%s"></script>' % jquery