|
@@ -17,23 +17,28 @@
|
|
|
#
|
|
#
|
|
|
# Adapted from http://code.google.com/p/django-mako/source/browse/trunk/djangomako/shortcuts.py
|
|
# Adapted from http://code.google.com/p/django-mako/source/browse/trunk/djangomako/shortcuts.py
|
|
|
|
|
|
|
|
-from django.http import HttpResponse
|
|
|
|
|
-from desktop.lib import apputil, i18n
|
|
|
|
|
import os
|
|
import os
|
|
|
import tempfile
|
|
import tempfile
|
|
|
-from mako.lookup import TemplateLookup, TemplateCollection
|
|
|
|
|
|
|
+
|
|
|
import django.template
|
|
import django.template
|
|
|
-from django import template
|
|
|
|
|
|
|
+from django.conf import settings
|
|
|
|
|
+from django.contrib.staticfiles.storage import staticfiles_storage
|
|
|
|
|
+from django.http import HttpResponse
|
|
|
|
|
+
|
|
|
|
|
+from mako.lookup import TemplateLookup, TemplateCollection
|
|
|
|
|
|
|
|
-register = template.Library()
|
|
|
|
|
|
|
+from desktop.lib import apputil, i18n
|
|
|
|
|
+
|
|
|
|
|
+register = django.template.Library()
|
|
|
|
|
|
|
|
ENCODING_ERRORS = 'replace'
|
|
ENCODING_ERRORS = 'replace'
|
|
|
|
|
|
|
|
# Things to automatically import into all template namespaces
|
|
# Things to automatically import into all template namespaces
|
|
|
IMPORTS=[
|
|
IMPORTS=[
|
|
|
- "from desktop.lib.django_mako import url",
|
|
|
|
|
"from django.utils.html import escape",
|
|
"from django.utils.html import escape",
|
|
|
- "from desktop.lib.django_mako import csrf_token"
|
|
|
|
|
|
|
+ "from desktop.lib.django_mako import url",
|
|
|
|
|
+ "from desktop.lib.django_mako import csrf_token",
|
|
|
|
|
+ "from desktop.lib.django_mako import static",
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
class DesktopLookup(TemplateCollection):
|
|
class DesktopLookup(TemplateCollection):
|
|
@@ -134,3 +139,9 @@ def csrf_token(request):
|
|
|
"""
|
|
"""
|
|
|
csrf_token = unicode(csrf(request)["csrf_token"])
|
|
csrf_token = unicode(csrf(request)["csrf_token"])
|
|
|
return str.format("<input type='hidden' name='csrfmiddlewaretoken' value='{0}' />", csrf_token)
|
|
return str.format("<input type='hidden' name='csrfmiddlewaretoken' value='{0}' />", csrf_token)
|
|
|
|
|
+
|
|
|
|
|
+def static(path):
|
|
|
|
|
+ """
|
|
|
|
|
+ Returns the URL to a file using the staticfiles's storage engine
|
|
|
|
|
+ """
|
|
|
|
|
+ return staticfiles_storage.url(path)
|