webserver: Improve interface.
- Put the listing on the same page, like in the tui.
This commit is contained in:
parent
b3ac69e0aa
commit
b4a7178ea2
2 changed files with 35 additions and 6 deletions
|
|
@ -652,7 +652,8 @@ class Result:
|
|||
html, styles = termstr.TermStr(
|
||||
STATUS_TO_TERMSTR[self.status]).as_html()
|
||||
return (f'<a title="{self.tool.__name__}" '
|
||||
f'href="{self.path}/{self.tool.__name__}">{html}</a>', styles)
|
||||
f'href="{self.path}/{self.tool.__name__}" '
|
||||
f'target="listing">{html}</a>', styles)
|
||||
|
||||
|
||||
def generic_tools():
|
||||
|
|
|
|||
|
|
@ -21,9 +21,29 @@ Example:
|
|||
|
||||
|
||||
def make_page(body_html, title):
|
||||
return (f"<html><head><title>{title}</title></head><body><style>body "
|
||||
f"{{ background-color: black; }} </style>{body_html}</body></html>"
|
||||
).encode("utf-8")
|
||||
return f"""
|
||||
<html>
|
||||
<head>
|
||||
<title>{title}</title>
|
||||
<style type="text/css">
|
||||
body {{ margin:2; background-color:black; }}
|
||||
iframe {{ height:100%;width:100%;border:1px solid white; }}
|
||||
</style>
|
||||
</head>
|
||||
<body>{body_html}</body>
|
||||
</html>"""
|
||||
|
||||
|
||||
def make_main_body():
|
||||
return f"""
|
||||
<table style="height:100%;width:100%;">
|
||||
<tr>
|
||||
<td style="height:100%;width:38.198%;">
|
||||
<iframe name=summary src="summary"></iframe></td>
|
||||
<td style="height:100%;">
|
||||
<iframe name=listing></iframe></td>
|
||||
</tr>
|
||||
</table>"""
|
||||
|
||||
|
||||
class Webserver(http.server.BaseHTTPRequestHandler):
|
||||
|
|
@ -36,6 +56,8 @@ class Webserver(http.server.BaseHTTPRequestHandler):
|
|||
def do_GET(self):
|
||||
self._set_headers()
|
||||
if self.path == "/":
|
||||
page = main_page
|
||||
elif self.path == "/summary":
|
||||
page = summary_page
|
||||
elif "/" in self.path[1:]:
|
||||
path, tool = os.path.split(self.path[1:])
|
||||
|
|
@ -44,7 +66,7 @@ class Webserver(http.server.BaseHTTPRequestHandler):
|
|||
page = make_page(body, f"{tool} of {path}")
|
||||
else:
|
||||
return
|
||||
self.wfile.write(page)
|
||||
self.wfile.write(page.encode("utf-8"))
|
||||
|
||||
def do_HEAD(self):
|
||||
self._set_headers()
|
||||
|
|
@ -54,6 +76,11 @@ class Webserver(http.server.BaseHTTPRequestHandler):
|
|||
self.wfile.write("posted".encode("utf-8"))
|
||||
|
||||
|
||||
def make_main_page(project_name):
|
||||
body_html = make_main_body()
|
||||
return make_page(body_html, "Summary of " + project_name)
|
||||
|
||||
|
||||
def make_summary_page(project_name, summary):
|
||||
summary_html, summary_styles = summary.as_html()
|
||||
body_html = ("\n".join(style.as_html() for style in summary_styles)
|
||||
|
|
@ -69,7 +96,7 @@ def run(server_class=http.server.HTTPServer, handler_class=Webserver, port=8080)
|
|||
|
||||
|
||||
def main():
|
||||
global summary_page, index
|
||||
global main_page, summary_page, index
|
||||
if len(sys.argv) == 1:
|
||||
print(USAGE)
|
||||
sys.exit(1)
|
||||
|
|
@ -92,6 +119,7 @@ def main():
|
|||
for row in summary._entries:
|
||||
for result in row:
|
||||
index[(result.path[2:], result.tool.__name__)] = result.result
|
||||
main_page = make_main_page(project_name)
|
||||
run()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue