summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-02-27 14:12:14 -0600
committerDan McGee <dan@archlinux.org>2010-02-27 14:12:14 -0600
commit680ddeb0894df7d0e6939d9fc6d542ee1c585817 (patch)
treec789d21a9200786957bc1af9a250bf15c55fa809
parenta70a3a04c70f27d2dd95b74c13264909d15a0e2e (diff)
downloadarchweb-680ddeb0894df7d0e6939d9fc6d542ee1c585817.tar.gz
archweb-680ddeb0894df7d0e6939d9fc6d542ee1c585817.zip
Add CDN templatetag package
For now, this contains one new template tag- 'jquery'. This will allow us to use the Google AJAX CDN in non-debug environments, since there is really no need for us to be the source of this common file. In the future this package may gain other static media resource tags as well. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--main/templatetags/__init__.py0
-rw-r--r--main/templatetags/cdn.py19
2 files changed, 19 insertions, 0 deletions
diff --git a/main/templatetags/__init__.py b/main/templatetags/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/main/templatetags/__init__.py
diff --git a/main/templatetags/cdn.py b/main/templatetags/cdn.py
new file mode 100644
index 00000000..090355b7
--- /dev/null
+++ b/main/templatetags/cdn.py
@@ -0,0 +1,19 @@
+from django import template
+from django.conf import settings
+
+register = template.Library()
+
+@register.tag
+def jquery(parser, token):
+ return JQueryNode()
+
+class JQueryNode(template.Node):
+ def render(self, context):
+ version = '1.4.1'
+ if getattr(settings, 'DEBUG', True):
+ jquery = '/media/jquery-%s.min.js' % version
+ else:
+ jquery = 'http://ajax.googleapis.com/ajax/libs/jquery/%s/jquery.min.js' % version
+ return '<script type="text/javascript" src="%s"></script>' % jquery
+
+# vim: set ts=4 sw=4 et: