diff options
Diffstat (limited to 'debug_toolbar')
| -rw-r--r-- | debug_toolbar/models.py | 0 | ||||
| -rw-r--r-- | debug_toolbar/templates/debug_toolbar/base.html | 37 | ||||
| -rw-r--r-- | debug_toolbar/toolbar/loader.py | 33 |
3 files changed, 40 insertions, 30 deletions
diff --git a/debug_toolbar/models.py b/debug_toolbar/models.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/debug_toolbar/models.py diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html new file mode 100644 index 0000000..c6469d4 --- /dev/null +++ b/debug_toolbar/templates/debug_toolbar/base.html @@ -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> diff --git a/debug_toolbar/toolbar/loader.py b/debug_toolbar/toolbar/loader.py index 4c3efa2..f4cc068 100644 --- a/debug_toolbar/toolbar/loader.py +++ b/debug_toolbar/toolbar/loader.py @@ -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 @@ class DebugToolbar(object): 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}) |
