Permalink
Browse files

Updating rendering to use Django templates and could possibly be over…

…ridden.
  • Loading branch information...
1 parent ef40163 commit abc3351bcfd3b2d1aa9c317bc592f96092226ceb @robhudson robhudson committed Sep 6, 2008
View
@@ -34,6 +34,9 @@ Installation
'debug_toolbar.panels.sql.SQLDebugPanel',
)
+#. Add `debug_toolbar` to your `INSTALLED_APPS` setting so Django can find the
+ the template files association with the Debug Toolbar.
+
TODO
====
- Add more panels
View
No changes.
@@ -0,0 +1,37 @@
+<script type="text/javascript">
+$(document).ready(function() {
+ $('.panelContent').hide();
+ // Actions
+ $('#djDebugButton').click(function() {
+ $('.panelContent').hide();
+ });
+ $('#djDebugPanelList a').click(function() {
+ var panel_id = $(this).attr('class');
+ $('.panelContent').hide();
+ $('#' + panel_id).show();
+ return false;
+ });
+});
+</script>
+<div id="djDebugBlock" style="background:orange; position:absolute; top:0; right:0; height:2em;">
+ <div id="djDebugToolbar">
+ <ul id="djDebugPanelList" style="list-style:none;">
+ <li id="djDebugButton" style="color:red; font-weight:bold; display:inline;">DEBUG</li>
+ {% for panel in panels %}
+ <li style="display:inline;">
+ {% if panel.content %}
+ <a href="{{ panel.url|default:"#" }}" title="{{ panel.title }}" class="{{ panel.dom_id }}">{{ panel.title }}</a>
+ {% else %}
+ {{ panel.title }}
+ {% endif %}
+ </li>
+ {% endfor %}
+ </ul>
+ {% for panel in panels %}
+ <div id="{{ panel.dom_id }}" class="panelContent" style="background-color:orange; width:50%; float:right;">
+ <h1>{{ panel.title }}</h1>
+ {{ panel.content|safe }}
+ </div>
+ {% endfor %}
+ </div>
+</div>
@@ -1,6 +1,8 @@
"""
The main DebugToolbar class that loads and renders the Toolbar.
"""
+from django.template.loader import render_to_string
+
class DebugToolbar(object):
def __init__(self):
@@ -37,37 +39,8 @@ def load_panels(self):
self.panels.append(panel_instance)
- def render_panels(self):
- """
- Renders each panel.
- """
- for panel in self.panels:
- div_id = 'djDebug%sPanel' % (panel.title().replace(' ', ''))
- self.panel_list.append('<li><a title="%(title)s" href="%(url)s">%(title)s</a></li>' % ({
- 'title': panel.title(),
- 'url': panel.url() or '#',
- }))
- self.content_list.append('<div id="%(div_id)s" class="panelContent"><h1>%(title)s</h1>%(content)s</div>' % ({
- 'div_id': div_id,
- 'title': panel.title(),
- 'content': panel.content(),
- }))
-
def render_toolbar(self):
"""
Renders the overall Toolbar with panels inside.
"""
- self.render_panels()
- template = """
- <div id="djDebugToolbar">
- <ul id="djDebugPanelList">
- %(panels)s
- </ul>
- %(contents)s
- </div>
- """
- context = {
- 'panels': ''.join(self.panel_list),
- 'contents': ''.join(self.content_list),
- }
- return template % context
+ return render_to_string('debug_toolbar/base.html', {'panels': self.panels})

0 comments on commit abc3351

Please sign in to comment.