Mercurial > piecrust2
diff piecrust/data/debug.py @ 219:d7a548ebcd58
serve: Add server sent events for showing pipeline errors in the debug window.
The server can now run an endpoint that streams pipeline status, including
errors or "fixed" statuses.
As a result, I had to investigate using event-loop based server alternatives,
before I figured out the correct flag to set in Werkzeug. Support for Gunicorn
is therefore now possible, although disabled by default. I will come in handy
though when proper support for CMS-mode is enabled.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 02 Feb 2015 08:34:44 -0800 |
parents | 0445a2232de7 |
children | bd56d9acd6ef |
line wrap: on
line diff
--- a/piecrust/data/debug.py Sat Jan 31 17:36:01 2015 -0800 +++ b/piecrust/data/debug.py Mon Feb 02 08:34:44 2015 -0800 @@ -14,12 +14,11 @@ # CSS for the debug window. -CSS_DEBUGINFO = """ +CSS_DEBUGWINDOW = """ text-align: left; +font-family: serif; font-style: normal; -padding: 1em; -background: #a42; -color: #fff; +font-weight: normal; position: fixed; width: 50%; bottom: 0; @@ -29,6 +28,17 @@ box-shadow: 0 0 10px #633; """ +CSS_PIPELINESTATUS = """ +background: #fff; +color: #a22; +""" + +CSS_DEBUGINFO = """ +padding: 1em; +background: #a42; +color: #fff; +""" + # HTML elements. CSS_P = 'margin: 0; padding: 0;' CSS_A = 'color: #fff; text-decoration: none;' @@ -62,10 +72,16 @@ def _do_build_debug_info(page, data, output): app = page.app - print('<div id="piecrust-debug-info" style="%s">' % CSS_DEBUGINFO, file=output) + print('<div id="piecrust-debug-info" style="%s">' % CSS_DEBUGWINDOW, + file=output) - print('<div>', file=output) - print('<p style="%s"><strong>PieCrust %s</strong> — ' % (CSS_P, APP_VERSION), file=output) + print('<div id="piecrust-debug-info-pipeline-status" style="%s">' % + CSS_PIPELINESTATUS, file=output) + print('</div>', file=output) + + print('<div style="%s">' % CSS_DEBUGINFO, file=output) + print('<p style="%s"><strong>PieCrust %s</strong> — ' % + (CSS_P, APP_VERSION), file=output) # If we have some execution info in the environment, # add more information. @@ -92,7 +108,7 @@ print('</div>', file=output) if data: - print('<div>', file=output) + print('<div style="%s padding-top: 0;">' % CSS_DEBUGINFO, file=output) print(('<p style="%s cursor: pointer;" onclick="var l = ' 'document.getElementById(\'piecrust-debug-details\'); ' 'if (l.style.display == \'none\') l.style.display = ' @@ -122,6 +138,9 @@ print('</div>', file=output) + print('<script src="/__piecrust_static/piecrust-debug-info.js"></script>', + file=output) + class DebugDataRenderer(object): MAX_VALUE_LENGTH = 150