diff options
| -rw-r--r-- | debug_toolbar/locale/es/LC_MESSAGES/django.po | 9 | ||||
| -rw-r--r-- | debug_toolbar/media/debug_toolbar/toolbar.js | 69 | ||||
| -rw-r--r-- | debug_toolbar/panels/sql.py | 11 | ||||
| -rw-r--r-- | debug_toolbar/templates/debug_toolbar/base.html | 2 | ||||
| -rw-r--r-- | debug_toolbar/templates/debug_toolbar/panels/sql.html | 6 | ||||
| -rw-r--r-- | debug_toolbar/templates/debug_toolbar/panels/template_source.html | 8 | ||||
| -rw-r--r-- | debug_toolbar/templates/debug_toolbar/redirect.html | 6 | ||||
| -rw-r--r-- | debug_toolbar/views.py | 1 | 
8 files changed, 66 insertions, 46 deletions
| diff --git a/debug_toolbar/locale/es/LC_MESSAGES/django.po b/debug_toolbar/locale/es/LC_MESSAGES/django.po index d15b2c1..fe7e60b 100644 --- a/debug_toolbar/locale/es/LC_MESSAGES/django.po +++ b/debug_toolbar/locale/es/LC_MESSAGES/django.po @@ -62,15 +62,6 @@ msgstr "Total Llamadas"  msgid "Total Time"  msgstr "Tiempo Total" -#: templates/debug_toolbar/panels/cache.html:39 -#: templates/debug_toolbar/panels/logger.html:8 -#: templates/debug_toolbar/panels/sql.html:6 -#: templates/debug_toolbar/panels/sql_explain.html:7 -#: templates/debug_toolbar/panels/sql_profile.html:7 -#: templates/debug_toolbar/panels/sql_select.html:7 -msgid "Time" -msgstr "Tiempo" -  #: templates/debug_toolbar/panels/cache.html:40  msgid "Type"  msgstr "Tipo" diff --git a/debug_toolbar/media/debug_toolbar/toolbar.js b/debug_toolbar/media/debug_toolbar/toolbar.js index 7b6d534..8155e2f 100644 --- a/debug_toolbar/media/debug_toolbar/toolbar.js +++ b/debug_toolbar/media/debug_toolbar/toolbar.js @@ -14,14 +14,13 @@ jQuery(function($j) {  				current = $j('#djDebug #' + this.className);  				if (current.is(':visible')) {  				    $j(document).trigger('close.djDebug'); -					$j(this).parent().removeClass("active"); +					$j(this).parent().removeClass('active');  				} else { -					//$j('.panelContent').hide(); -					$j(document).trigger('close.djDebug'); +					$j('.panelContent').hide(); // Hide any that are already open  					current.show();  					$j.djDebug.open(); -					$j('#djDebugToolbar li').removeClass("active"); -					$j(this).parent().addClass("active"); +					$j('#djDebugToolbar li').removeClass('active'); +					$j(this).parent().addClass('active');  				}  				return false;  			}); @@ -59,15 +58,11 @@ jQuery(function($j) {  			if ($j.cookie(COOKIE_NAME)) {  				$j.djDebug.hide_toolbar(false);  			} else { -				$j('#djDebugToolbar').show(); +				$j.djDebug.show_toolbar(false);  			}  		},  		open: function() { -			$j(document).bind('keydown.djDebug', function(e) { -				if (e.keyCode == 27) { -					$j.djDebug.close(); -				} -			}); +			// TODO: Decide if we should remove this  		},  		toggle_content: function(elem) {  			if (elem.is(':visible')) { @@ -81,10 +76,16 @@ jQuery(function($j) {  			return false;  		},  		hide_toolbar: function(setCookie) { -		    $j(document).trigger('close.djDebug'); -			$j('#djDebugToolbar').hide("fast"); -			$j('#djDebugToolbar li').removeClass("active"); +			// close any sub panels +			$j('#djDebugWindow').hide(); +			// close all panels +			$j('.panelContent').hide(); +			$j('#djDebugToolbar li').removeClass('active'); +			// finally close toolbar +			$j('#djDebugToolbar').hide('fast');  			$j('#djDebugToolbarHandle').show(); +			// Unbind keydown +			$j(document).unbind('keydown.djDebug');  			if (setCookie) {  				$j.cookie(COOKIE_NAME, 'hide', {  					path: '/', @@ -92,24 +93,46 @@ jQuery(function($j) {  				});  			}  		}, -		show_toolbar: function() { +		show_toolbar: function(animate) { +			// Set up keybindings +			$j(document).bind('keydown.djDebug', function(e) { +				if (e.keyCode == 27) { +					$j.djDebug.close(); +				} +			});  			$j('#djDebugToolbarHandle').hide(); -			$j('#djDebugToolbar').show("fast"); +			if (animate) { +				$j('#djDebugToolbar').show('fast'); +			} else { +				$j('#djDebugToolbar').show(); +			}  			$j.cookie(COOKIE_NAME, null, {  				path: '/',  				expires: -1  			});  		},  		toggle_arrow: function(elem) { -            var uarr = String.fromCharCode(0x25b6); -            var darr = String.fromCharCode(0x25bc); -            elem.html(elem.html() == uarr ? darr : uarr); -        } +			var uarr = String.fromCharCode(0x25b6); +			var darr = String.fromCharCode(0x25bc); +			elem.html(elem.html() == uarr ? darr : uarr); +		}  	});  	$j(document).bind('close.djDebug', function() { -		$j(document).unbind('keydown.djDebug'); -		$j('.panelContent').hide() -		$j('#djDebugToolbar li').removeClass("active"); +		// If a sub-panel is open, close that +		if ($j('#djDebugWindow').is(':visible')) { +			$j('#djDebugWindow').hide(); +			return; +		} +		// If a panel is open, close that +		if ($j('.panelContent').is(':visible')) { +			$j('.panelContent').hide(); +			return; +		} +		// Otherwise, just minimize the toolbar +		if ($j('#djDebugToolbar').is(':visible')) { +			$j.djDebug.hide_toolbar(true); +			return; +		}  	});  });  jQuery(function() { diff --git a/debug_toolbar/panels/sql.py b/debug_toolbar/panels/sql.py index a53a8d4..244905b 100644 --- a/debug_toolbar/panels/sql.py +++ b/debug_toolbar/panels/sql.py @@ -91,13 +91,15 @@ class SQLDebugPanel(DebugPanel):      def __init__(self):          self._offset = len(connection.queries)          self._sql_time = 0 +        self._queries = []      def nav_title(self):          return 'SQL'      def nav_subtitle(self): -        self._sql_time = sum([q['duration'] for q in connection.queries[self._offset:]]) -        num_queries = len(connection.queries) - self._offset +        self._queries = connection.queries[self._offset:] +        self._sql_time = sum([q['duration'] for q in self._queries]) +        num_queries = len(self._queries)          return "%d %s in %.2fms" % (              num_queries,              (num_queries == 1) and 'query' or 'queries', @@ -111,9 +113,8 @@ class SQLDebugPanel(DebugPanel):          return ''      def content(self): -        sql_queries = connection.queries[self._offset:]          width_ratio_tally = 0 -        for query in sql_queries: +        for query in self._queries:              query['sql'] = reformat_sql(query['sql'])              try:                  query['width_ratio'] = (query['duration'] / self._sql_time) * 100 @@ -123,7 +124,7 @@ class SQLDebugPanel(DebugPanel):              width_ratio_tally += query['width_ratio']          context = { -            'queries': sql_queries, +            'queries': self._queries,              'sql_time': self._sql_time,              'is_mysql': settings.DATABASE_ENGINE == 'mysql',          } diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html index dc8ccf9..d1ee273 100644 --- a/debug_toolbar/templates/debug_toolbar/base.html +++ b/debug_toolbar/templates/debug_toolbar/base.html @@ -1,4 +1,5 @@  {% load i18n %} +{% spaceless %}  <script type="text/javascript" charset="utf-8">  	// When jQuery is sourced, it's going to overwrite whatever might be in the  	// '$' variable, so store a reference of it in a temporary variable... @@ -65,3 +66,4 @@  	{% endfor %}  	<div id="djDebugWindow" class="panelContent"></div>  </div> +{% endspaceless %} diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql.html b/debug_toolbar/templates/debug_toolbar/panels/sql.html index 9c8bfa6..81188a9 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/sql.html +++ b/debug_toolbar/templates/debug_toolbar/panels/sql.html @@ -14,10 +14,10 @@  				<td>{{ query.duration|floatformat:"2" }}</td>  				<td>  				{% if query.params %} -					<a class="remoteCall" href="/__debug__/sql_select/?sql={{ query.raw_sql|urlencode }}¶ms={{ query.params|urlencode }}&duration={{ query.duration|floatformat:"2"|urlencode }}&hash={{ query.hash }}">SELECT</a> -					<a class="remoteCall" href="/__debug__/sql_explain/?sql={{ query.raw_sql|urlencode }}¶ms={{ query.params|urlencode }}&duration={{ query.duration|floatformat:"2"|urlencode }}&hash={{ query.hash }}">EXPLAIN</a> +					<a class="remoteCall" href="/__debug__/sql_select/?sql={{ query.raw_sql|urlencode }}¶ms={{ query.params|urlencode }}&duration={{ query.duration|floatformat:"2"|urlencode }}&hash={{ query.hash }}">SELECT</a><br> +					<a class="remoteCall" href="/__debug__/sql_explain/?sql={{ query.raw_sql|urlencode }}¶ms={{ query.params|urlencode }}&duration={{ query.duration|floatformat:"2"|urlencode }}&hash={{ query.hash }}">EXPLAIN</a><br>  					{% if is_mysql %} -						<a class="remoteCall" href="/__debug__/sql_profile/?sql={{ query.raw_sql|urlencode }}¶ms={{ query.params|urlencode }}&duration={{ query.duration|floatformat:"2"|urlencode }}&hash={{ query.hash }}">PROFILE</a> +						<a class="remoteCall" href="/__debug__/sql_profile/?sql={{ query.raw_sql|urlencode }}¶ms={{ query.params|urlencode }}&duration={{ query.duration|floatformat:"2"|urlencode }}&hash={{ query.hash }}">PROFILE</a><br>  					{% endif %}  				{% endif %}  				</td> diff --git a/debug_toolbar/templates/debug_toolbar/panels/template_source.html b/debug_toolbar/templates/debug_toolbar/panels/template_source.html index 192d1af..7074f4f 100644 --- a/debug_toolbar/templates/debug_toolbar/panels/template_source.html +++ b/debug_toolbar/templates/debug_toolbar/panels/template_source.html @@ -4,5 +4,11 @@  	<h3>Template Source: <code>{{ template_name }}</code></h3>  </div>  <div class="djDebugPanelContent"> -	{{ source }} +	<div class="scroll"> +		{% if not source.pygmentized %} +			<pre>{{ source }}</pre> +		{% else %} +			{{ source }} +		{% endif %} +	</div>  </div> diff --git a/debug_toolbar/templates/debug_toolbar/redirect.html b/debug_toolbar/templates/debug_toolbar/redirect.html index d0d9b35..068fe8c 100644 --- a/debug_toolbar/templates/debug_toolbar/redirect.html +++ b/debug_toolbar/templates/debug_toolbar/redirect.html @@ -6,11 +6,7 @@  <h1>HttpResponseRedirect</h1>  <p>Location: <a href="{{ redirect_to|urlencode }}">{{ redirect_to }}</a></p>  <p class="notice"> -	{% trans "The Django Debug Toolbar has intercepted a redirect to the above URL for -	debug viewing purposes.  You can click the above link to continue with the -	redirect as normal.  If you'd like to disable this feature, set the" %} -	<code>DEBUG_TOOLBAR_CONFIG</code> dictionary's key -	<code>INTERCEPT_REDIRECTS</code> to <code>False</code>." %} +	{% trans "The Django Debug Toolbar has intercepted a redirect to the above URL for debug viewing purposes.  You can click the above link to continue with the redirect as normal.  If you'd like to disable this feature, set the <code>DEBUG_TOOLBAR_CONFIG</code> dictionary's key <code>INTERCEPT_REDIRECTS</code> to <code>False</code>." %}  </p>  </body>  </html> diff --git a/debug_toolbar/views.py b/debug_toolbar/views.py index 3a8cb79..5a412af 100644 --- a/debug_toolbar/views.py +++ b/debug_toolbar/views.py @@ -154,6 +154,7 @@ def template_source(request):          source = highlight(source, HtmlDjangoLexer(), HtmlFormatter())          source = mark_safe(source) +        source.pygmentized = True      except ImportError:          pass | 
