Skip to content

Alternative lightweight HTML injection #999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
merwok opened this issue Oct 5, 2017 · 4 comments
Open

Alternative lightweight HTML injection #999

merwok opened this issue Oct 5, 2017 · 4 comments

Comments

@merwok
Copy link

merwok commented Oct 5, 2017

Hello! I mostly develop APIs in Python, trying things out with a command-line HTTP client. When things go bad, it is quite unfriendly to get a huge dump of HTML in the terminal and have to scroll up to find the error message.

In contrast, pyramid-debug-toolbar only injects a few lines in responses, with a link that you can open in your browser to see debug info, which works when testing in a browser or from any other HTTP client:

When you include the toolbar in your application, a floating Pyramid logo will appear on the upper
right over your application's HTML. If you click on the Pyramid logo, a new target window will open
with your current request highlighted and all of your configured panels loaded.
https://docs.pylonsproject.org/projects/pyramid_debugtoolbar/en/latest/#the-toolbar

This is the code injected, which lets the whole page for a 404 or 500 error fit in my terminal:

<link rel="stylesheet" type="text/css" href="http://localhost:1440/_debug_toolbar/static/toolbar/toolbar_button.css">

<div id="pDebug">
    <div  id="pDebugToolbarHandle">
        <a title="Show Toolbar" id="pShowToolBarButton"
           href="http://localhost:1440/_debug_toolbar/313430303532373735303634393132" target="pDebugToolbar">&#171; FIXME: Debug Toolbar</a>
    </div>
</div>

In the abstract, is this a feature that djdt developers would accept?

For the implementation. A new middleware would be needed to inject just the link, with a new view that does the same job as the current middleware (query panels to get the toolbar info, send requests to display more info for a panel). It doesn’t seem to require many changes, and the standard mode would be unchanged.

@matthiask
Copy link
Member

Sounds good. I can't promise much, but I'll certainly review/provide feedback.

I'm not sure I understand whether you're proposing to add another middleware besides the current one, or if you'd want to modify the existing middleware. I suspect that the later would be less work down the road because there's only one code path to maintain.

@merwok
Copy link
Author

merwok commented Nov 1, 2017

I suggested a new middleware to make sure that the current behaviour is left untouched, but if it makes sense to have conditions inside one same middleware, that could be done.

@merwok
Copy link
Author

merwok commented Sep 11, 2018

FTR, I am testing https://github.com/recamshak/django-debug-panel which works with JSON responses and lets me see history.

@merwok
Copy link
Author

merwok commented Dec 19, 2018

django-debug-panel is only compatible with chrome/chromium.

Related tickets: #981 #985

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants