Skip to content

Commit 189668e

Browse files
committed
use links to static files rather than direct inclusion, Fixes #307
1 parent 119874f commit 189668e

25 files changed

+7
-16
lines changed

debug_toolbar/templates/debug_toolbar/base.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{% load i18n %}
22
<style type="text/css">
33
@media print { #djDebug {display:none;}}
4-
{{ css }}
54
</style>
6-
<script type="text/javascript">{{ js }}</script>
5+
<link rel="stylesheet" href="{{ STATIC_URL }}debug_toolbar/css/toolbar.min.css" type="text/css">
6+
<script type="text/javascript" src="{{ STATIC_URL }}debug_toolbar/css/toolbar.min.js"></script>
77
<div id="djDebug" style="display:none;" dir="ltr">
88
<div style="display:none;" id="djDebugToolbar">
99
<ul id="djDebugPanelList">

debug_toolbar/toolbar/loader.py

-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ def render_toolbar(self):
6060
context = self.template_context.copy()
6161
context.update({
6262
'panels': self.panels,
63-
'js': mark_safe(open(os.path.join(media_path, 'js', 'toolbar.min.js'), 'r').read()),
64-
'css': mark_safe(open(os.path.join(media_path, 'css', 'toolbar.min.css'), 'r').read()),
6563
})
6664

6765
return render_to_string('debug_toolbar/base.html', context)

debug_toolbar/urls.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
_PREFIX = '__debug__'
1010

1111
urlpatterns = patterns('',
12-
url(r'^%s/m/(.*)$' % _PREFIX, 'debug_toolbar.views.debug_media'),
1312
url(r'^%s/sql_select/$' % _PREFIX, 'debug_toolbar.views.sql_select', name='sql_select'),
1413
url(r'^%s/sql_explain/$' % _PREFIX, 'debug_toolbar.views.sql_explain', name='sql_explain'),
1514
url(r'^%s/sql_profile/$' % _PREFIX, 'debug_toolbar.views.sql_profile', name='sql_profile'),

debug_toolbar/views.py

-8
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ def __str__(self):
2323
return repr(self.value)
2424

2525

26-
def debug_media(request, path):
27-
root = getattr(settings, 'DEBUG_TOOLBAR_MEDIA_ROOT', None)
28-
if root is None:
29-
parent = os.path.abspath(os.path.dirname(__file__))
30-
root = os.path.join(parent, 'media', 'debug_toolbar')
31-
return django.views.static.serve(request, path, root)
32-
33-
3426
def sql_select(request):
3527
"""
3628
Returns the output of the SQL SELECT statement.

example/settings.py

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
INTERNAL_IPS = ('127.0.0.1',)
1818
MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media')
1919
MEDIA_URL = '/media'
20+
STATIC_ROOT = os.path.join(HOME_ROOT, 'staticfiles')
21+
STATIC_URL = '/static/'
2022
MIDDLEWARE_CLASSES = (
2123
'django.middleware.common.CommonMiddleware',
2224
'django.contrib.sessions.middleware.SessionMiddleware',
File renamed without changes.
File renamed without changes.
File renamed without changes.

example/templates/jquery/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
.hide {display:none;}
77
#v {font-weight:bold;}
88
</style>
9-
<script type="text/javascript" charset="utf-8" src="{{ MEDIA_URL }}/js/jquery.js"></script>
9+
<script type="text/javascript" charset="utf-8" src="{{ STATIC_URL }}/js/jquery.js"></script>
1010
<script type="text/javascript">
1111
$(document).ready(function() {
1212
$('p.hide').show();

example/templates/mootools/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<style>
66
.hide {display:none;}
77
</style>
8-
<script type="text/javascript" charset="utf-8" src="{{ MEDIA_URL }}/js/mootools.js"></script>
8+
<script type="text/javascript" charset="utf-8" src="{{ STATIC_URL }}/js/mootools.js"></script>
99
<script type="text/javascript">
1010
window.addEvent('domready', function() {
1111
$$('p.hide').setStyle('display', 'block');

example/templates/prototype/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<style>
66
.hide {display:none;}
77
</style>
8-
<script type="text/javascript" charset="utf-8" src="{{ MEDIA_URL }}/js/prototype.js"></script>
8+
<script type="text/javascript" charset="utf-8" src="{{ STATIC_URL }}/js/prototype.js"></script>
99
<script type="text/javascript">
1010
document.observe('dom:loaded', function() {
1111
$('showme').removeClassName('hide');

0 commit comments

Comments
 (0)