From 680ddeb0894df7d0e6939d9fc6d542ee1c585817 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 27 Feb 2010 14:12:14 -0600 Subject: 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 --- main/templatetags/__init__.py | 0 main/templatetags/cdn.py | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 main/templatetags/__init__.py create mode 100644 main/templatetags/cdn.py diff --git a/main/templatetags/__init__.py b/main/templatetags/__init__.py new file mode 100644 index 00000000..e69de29b 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 '' % jquery + +# vim: set ts=4 sw=4 et: -- cgit v1.2.3-55-g3dc8 From 696c97b7f86730e36c94a05234bb9627a575281b Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 27 Feb 2010 14:13:44 -0600 Subject: Convert templates to use jquery cdn tag Signed-off-by: Dan McGee --- templates/devel/index.html | 2 +- templates/todolists/view.html | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/templates/devel/index.html b/templates/devel/index.html index e341a8bb..1203d8a6 100644 --- a/templates/devel/index.html +++ b/templates/devel/index.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% block head %} - +{% load cdn %}{% jquery %} {% endblock %} {% block content %} diff --git a/templates/todolists/view.html b/templates/todolists/view.html index b85a4266..6f85c231 100644 --- a/templates/todolists/view.html +++ b/templates/todolists/view.html @@ -46,10 +46,9 @@ - + {% load cdn %}{% jquery %} +{% load cdn %}{% jquery %}