summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Reports/reports/templates/base.html16
-rw-r--r--src/lib/Server/Reports/reports/templatetags/bcfg2_tags.py35
2 files changed, 44 insertions, 7 deletions
diff --git a/src/lib/Server/Reports/reports/templates/base.html b/src/lib/Server/Reports/reports/templates/base.html
index 7a36c9893..9bd9da218 100644
--- a/src/lib/Server/Reports/reports/templates/base.html
+++ b/src/lib/Server/Reports/reports/templates/base.html
@@ -1,3 +1,5 @@
+{% load bcfg2_tags %}
+
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
@@ -10,19 +12,19 @@
<meta name="robots" content="noindex, nofollow" />
<meta http-equiv="cache-control" content="no-cache" />
-<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}/bcfg2_base.css" media="all" />
-<script type="text/javascript" src="{{ MEDIA_URL }}/bcfg2.js"></script>
-<script type="text/javascript" src="{{ MEDIA_URL }}/date.js"></script>
-<script type="text/javascript" src="{{ MEDIA_URL }}/AnchorPosition.js"></script>
-<script type="text/javascript" src="{{ MEDIA_URL }}/CalendarPopup.js"></script>
-<script type="text/javascript" src="{{ MEDIA_URL }}/PopupWindow.js"></script>
+<link rel="stylesheet" type="text/css" href="{% to_media_url bcfg2_base.css %}" media="all" />
+<script type="text/javascript" src="{% to_media_url bcfg2.js %}"></script>
+<script type="text/javascript" src="{% to_media_url date.js %}"></script>
+<script type="text/javascript" src="{% to_media_url AnchorPosition.js %}"></script>
+<script type="text/javascript" src="{% to_media_url CalendarPopup.js %}"></script>
+<script type="text/javascript" src="{% to_media_url PopupWindow.js %}"></script>
{% block extra_header_info %}{% endblock %}
</head>
<body onload="{% block body_onload %}{% endblock %}">
<div id="header">
- <a href="http://bcfg2.org"><img src='{{ MEDIA_URL }}/bcfg2_logo.png'
+ <a href="http://bcfg2.org"><img src='{% to_media_url bcfg2_logo.png %}'
height='115' width='300' alt='Bcfg2' style='float:left; height: 115px' /></a>
</div>
diff --git a/src/lib/Server/Reports/reports/templatetags/bcfg2_tags.py b/src/lib/Server/Reports/reports/templatetags/bcfg2_tags.py
index 8285915bd..7fffe289d 100644
--- a/src/lib/Server/Reports/reports/templatetags/bcfg2_tags.py
+++ b/src/lib/Server/Reports/reports/templatetags/bcfg2_tags.py
@@ -237,3 +237,38 @@ def sortwell(value):
configItems.sort(lambda x,y: cmp(x.entry.kind, y.entry.kind))
return configItems
+class MediaTag(template.Node):
+ def __init__(self, filter_value):
+ self.filter_value = filter_value
+
+ def render(self, context):
+ base = context['MEDIA_URL']
+ try:
+ request = context['request']
+ try:
+ base = request.environ['bcfg2.media_url']
+ except:
+ if request.path != request.META['PATH_INFO']:
+ offset = request.path.find(request.META['PATH_INFO'])
+ if offset > 0:
+ base = "%s/%s" % (request.path[:offset], \
+ context['MEDIA_URL'].strip('/'))
+ except:
+ pass
+ return "%s/%s" % (base, self.filter_value)
+
+@register.tag
+def to_media_url(parser, token):
+ """
+ Return a url relative to the media_url.
+
+ {% to_media_url /bcfg2.css %}
+ """
+ try:
+ tag_name, filter_value = token.split_contents()
+ filter_value = parser.compile_filter(filter_value)
+ except ValueError:
+ raise template.TemplateSyntaxError, "%r tag requires exactly one argument" % token.contents.split()[0]
+
+ return MediaTag(filter_value)
+