Skip to content

Commit

Permalink
Fix static urls with yarl 1.9+ (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
14droplets authored Sep 13, 2023
1 parent f320aff commit e28307a
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion aiohttp_debugtoolbar/panels/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ def populate(self, request):
self.data = {"middlewares": middleware_names}

def render_vars(self, request):
static_path = self._request.app.router[STATIC_ROUTE_NAME].url_for(filename="")
static_path = self._request.app.router[STATIC_ROUTE_NAME].canonical
return {"static_path": static_path}
4 changes: 2 additions & 2 deletions aiohttp_debugtoolbar/panels/templates/traceback.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@
DEBUG_TOOLBAR_STATIC_PATH = "{{ static_path }}",
DEBUG_TOOLBAR_ROOT_PATH = "{{ root_path }}";
</script>
<script data-main="{{ static_path }}js/debugger"
src="{{ static_path }}js/require.js"></script>
<script data-main="{{ static_path }}/js/debugger"
src="{{ static_path }}/js/require.js"></script>
2 changes: 1 addition & 1 deletion aiohttp_debugtoolbar/panels/traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ def render_content(self, request):
return super().render_content(request)

def render_vars(self, request):
static_path = self._request.app.router[STATIC_ROUTE_NAME].url_for(filename="")
static_path = self._request.app.router[STATIC_ROUTE_NAME].canonical
root_path = self.request.app.router[ROOT_ROUTE_NAME].url_for()
return {"static_path": static_path, "root_path": root_path}
2 changes: 1 addition & 1 deletion aiohttp_debugtoolbar/tbtools/tbtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def render_summary(self, app, include_title=True):

def render_full(self, request, lodgeit_url=None):
"""Render the Full HTML page with the traceback info."""
static_path = request.app.router[STATIC_ROUTE_NAME].url_for(filename="")
static_path = request.app.router[STATIC_ROUTE_NAME].canonical
root_path = request.app.router[ROOT_ROUTE_NAME].url_for()
exc = escape(self.exception)
summary = self.render_summary(request.app, include_title=False)
Expand Down
4 changes: 2 additions & 2 deletions aiohttp_debugtoolbar/templates/console.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<html>
<head>
<title>{{ title }} // Werkzeug Debugger</title>
<link rel="stylesheet" href="{{ static_path }}css/debugger.css" type="text/css" />
<link rel="stylesheet" href="{{ static_path }}/css/debugger.css" type="text/css" />
<script type="text/javascript">
var TRACEBACK = {{ str(traceback_id) }},
CONSOLE_MODE = {{ console }},
DEBUGGER_TOKEN = "{{ token }}",
EVALEX = {{ evalex }};
</script>
<script data-main="{{ static_path }}js/debugger" src="{{ static_path }}js/require.js"></script>
<script data-main="{{ static_path }}/js/debugger" src="{{ static_path }}/js/require.js"></script>
</head>
<body>

Expand Down
18 changes: 9 additions & 9 deletions aiohttp_debugtoolbar/templates/exception.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<head>
<title>{{ title }} // Werkzeug Debugger</title>
<!--bootstrap version 2.3.2-->
<link rel="stylesheet" type="text/css" href="{{ static_path }}css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="{{ static_path }}css/toolbar.css">
<link rel="stylesheet" href="{{ static_path }}css/debugger.css"
<link rel="stylesheet" type="text/css" href="{{ static_path }}/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="{{ static_path }}/css/toolbar.css">
<link rel="stylesheet" href="{{ static_path }}/css/debugger.css"
type="text/css">
{# <link rel="stylesheet" type="text/css" href="{{ static_path }}css/highlightjs_default.min.css">#}
<link rel="stylesheet" type="text/css" href="{{ static_path }}css/prism.css">
{# <link rel="stylesheet" type="text/css" href="{{ static_path }}/css/highlightjs_default.min.css">#}
<link rel="stylesheet" type="text/css" href="{{ static_path }}/css/prism.css">
<script type="text/javascript">
var TRACEBACK = {{ traceback_id }},
DEBUGGER_TOKEN = "{{ token }}",
Expand All @@ -19,8 +19,8 @@
DEBUG_TOOLBAR_STATIC_PATH = "{{ static_path }}",
DEBUG_TOOLBAR_ROOT_PATH = "{{ root_path }}";
</script>
<script data-main="{{ static_path }}js/debugger"
src="{{ static_path }}js/require.js"></script>
<script data-main="{{ static_path }}/js/debugger"
src="{{ static_path }}/js/require.js"></script>
</head>
<body>
<div class="debugger">
Expand Down Expand Up @@ -100,8 +100,8 @@
-->

{# <script type="text/javascript" src="{{ static_path }}js/highlight.min.js"></script>#}
<script type="text/javascript" src="{{ static_path }}js/prism.js"></script>
{# <script type="text/javascript" src="{{ static_path }}/js/highlight.min.js"></script>#}
<script type="text/javascript" src="{{ static_path }}/js/prism.js"></script>
</body>

</html>
28 changes: 14 additions & 14 deletions aiohttp_debugtoolbar/templates/toolbar.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<meta charset="UTF-8" />
<title>Aiohttp Debug Toolbar</title>

<link rel="stylesheet" type="text/css" href="{{ static_path }}css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="{{ static_path }}css/toolbar.css">
<link rel="stylesheet" type="text/css" href="{{ static_path }}css/dashboard.css">
<link rel="stylesheet" href="{{ static_path }}css/debugger.css" type="text/css">
{# <link rel="stylesheet" type="text/css" href="{{ static_path }}css/highlightjs_default.min.css">#}
<link rel="stylesheet" type="text/css" href="{{ static_path }}css/prism.css">
<link rel="stylesheet" type="text/css" href="{{ static_path }}/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="{{ static_path }}/css/toolbar.css">
<link rel="stylesheet" type="text/css" href="{{ static_path }}/css/dashboard.css">
<link rel="stylesheet" href="{{ static_path }}/css/debugger.css" type="text/css">
{# <link rel="stylesheet" type="text/css" href="{{ static_path }}/css/highlightjs_default.min.css">#}
<link rel="stylesheet" type="text/css" href="{{ static_path }}/css/prism.css">


{# include scripts here that should be included before pageload #}
Expand All @@ -19,7 +19,7 @@
<script type="text/javascript">
var DEBUG_TOOLBAR_STATIC_PATH = '{{ static_path }}';
</script>
<script src="{{ static_path }}js/jquery-1.10.2.min.js"></script>
<script src="{{ static_path }}/js/jquery-1.10.2.min.js"></script>
</head>
<body>

Expand All @@ -33,7 +33,7 @@
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{ root_path }}">
<img src="{{ static_path }}img/aiohttp.svg"/>
<img src="{{ static_path }}/img/aiohttp.svg"/>
Aiohttp DebugToolbar</a>
</div>
<div class="navbar-collapse collapse">
Expand Down Expand Up @@ -67,10 +67,10 @@
</div>

{# scripts that can be included after pageload #}
<script src="{{ static_path }}js/jquery.cookie.js"></script>
<script src="{{ static_path }}js/jquery.tablesorter.min.js"></script>
<script src="{{ static_path }}js/bootstrap.min.js"></script>
<script src="{{ static_path }}js/toolbar.js"></script>
<script src="{{ static_path }}/js/jquery.cookie.js"></script>
<script src="{{ static_path }}/js/jquery.tablesorter.min.js"></script>
<script src="{{ static_path }}/js/bootstrap.min.js"></script>
<script src="{{ static_path }}/js/toolbar.js"></script>
<script>
$(function () {
$('#myTab a:first').tab('show');
Expand Down Expand Up @@ -128,9 +128,9 @@
});
</script>
{# <script type="text/javascript" src="{{ static_path }}js/highlight.min.js"></script>#}
{# <script type="text/javascript" src="{{ static_path }}/js/highlight.min.js"></script>#}
{# <script>hljs.initHighlightingOnLoad();</script>#}
<script type="text/javascript" src="{{ static_path }}js/prism.js"></script>
<script type="text/javascript" src="{{ static_path }}/js/prism.js"></script>

</body>
</html>
4 changes: 2 additions & 2 deletions aiohttp_debugtoolbar/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def request_view(request):
panels = toolbar.panels if toolbar else []
global_panels = toolbar.global_panels if toolbar else []

static_path = request.app.router[STATIC_ROUTE_NAME].url_for(filename="")
static_path = request.app.router[STATIC_ROUTE_NAME].canonical
root_path = request.app.router[ROOT_ROUTE_NAME].url_for()

button_style = settings.get("button_style", "")
Expand Down Expand Up @@ -132,7 +132,7 @@ async def execute(self, request):
# @aiohttp_jinja2.template('console.jinja2', app_key=TEMPLATE_KEY)
# async def console(self, request):
# self._validate_token(request)
# static_path = request.app.router[STATIC_ROUTE_NAME].url(filename='')
# static_path = request.app.router[STATIC_ROUTE_NAME].canonical
# root_path = request.app.router[ROOT_ROUTE_NAME].url()
# token = request.query.get('token')
# tb = await self._get_tb(request)
Expand Down

0 comments on commit e28307a

Please sign in to comment.