summaryrefslogtreecommitdiffstatshomepage
path: root/scripts/minimaws/lib/htmltmpl.py
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2017-08-02 00:41:09 +1000
committer Vas Crabb <vas@vastheman.com>2017-08-02 00:41:09 +1000
commit14642adc5aff91f10f74f997ed2edf22ba58f29a (patch)
treea7cf242c8354b82c25ffb5ca14a4eef06cffeedb /scripts/minimaws/lib/htmltmpl.py
parent46a221b95e22aa8fa0c9aa9a7774f72c5c3aebad (diff)
minimaws web mode enhancements:
* Support serving static assets, use for stylesheet, script and images * Better error pages, reject unsupported HTTP methods * Replace lists with sortable tables with more detail (click headings to sort) * Add pages for exploring source files, link from machine pages - Can start from full source file list at http://localhost:8080/sourcefile/ (nw) JavaScript performance can drop when sorting really big tables, e.g. the list of all source files, or the list of machines in some of the fruit machine drivers. This update doesn't expose machine/device information, just consolidating what's there. The wsgiref server is adding headers to prevent caching, I'll look for a workaround.
Diffstat (limited to 'scripts/minimaws/lib/htmltmpl.py')
-rw-r--r--scripts/minimaws/lib/htmltmpl.py110
1 files changed, 104 insertions, 6 deletions
diff --git a/scripts/minimaws/lib/htmltmpl.py b/scripts/minimaws/lib/htmltmpl.py
index 2c71fea9fb9..106f9615e9d 100644
--- a/scripts/minimaws/lib/htmltmpl.py
+++ b/scripts/minimaws/lib/htmltmpl.py
@@ -6,17 +6,115 @@
import string
+ERROR_PAGE = string.Template(
+ '<!DOCTYPE html>\n' \
+ '<html>\n' \
+ '<head>\n' \
+ ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n' \
+ ' <title>${code} ${message}</title>\n' \
+ '</head>\n' \
+ '<body>\n' \
+ '<h1>${message}</h1>\n' \
+ '</body>\n' \
+ '</html>\n')
+
+
MACHINE_PROLOGUE = string.Template(
'<!DOCTYPE html>\n' \
'<html>\n' \
'<head>\n' \
' <meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n' \
- ' <title>${description} (${shortname})</title>\n' \
+ ' <meta http-equiv="Content-Style-Type" content="text/css">\n' \
+ ' <meta http-equiv="Content-Script-Type" content="text/javascript">\n' \
+ ' <link rel="stylesheet" type="text/css" href="${assets}/style.css">\n' \
+ ' <script type="text/javascript">var assetsurl="${assets}"</script>\n' \
+ ' <script type="text/javascript" src="${assets}/common.js"></script>\n' \
+ ' <title>Machine: ${description} (${shortname})</title>\n' \
'</head>\n' \
'<body>\n' \
'<h1>${description}</h1>\n' \
- '<table>\n' \
- ' <tr><th style="text-align: right">Short name:</th><td>${shortname}</td></tr>\n' \
- ' <tr><th style="text-align: right">Is device:</th><td>${isdevice}</td></tr>\n' \
- ' <tr><th style="text-align: right">Runnable:</th><td>${runnable}</td></tr>\n' \
- ' <tr><th style="text-align: right">Source file:</th><td>${sourcefile}</td></tr>\n')
+ '<table class="sysinfo">\n' \
+ ' <tr><th>Short name:</th><td>${shortname}</td></tr>\n' \
+ ' <tr><th>Is device:</th><td>${isdevice}</td></tr>\n' \
+ ' <tr><th>Runnable:</th><td>${runnable}</td></tr>\n' \
+ ' <tr><th>Source file:</th><td><a href="${sourcehref}">${sourcefile}</a></td></tr>\n')
+
+MACHINE_ROW = string.Template(
+ ' <tr>\n' \
+ ' <td><a href="${machinehref}">${shortname}</a></td>\n' \
+ ' <td><a href="${machinehref}">${description}</a></td>\n' \
+ ' <td><a href="${sourcehref}">${sourcefile}</a></td>\n' \
+ ' </tr>\n')
+
+EXCL_MACHINE_ROW = string.Template(
+ ' <tr>\n' \
+ ' <td><a href="${machinehref}">${shortname}</a></td>\n' \
+ ' <td></td>\n' \
+ ' <td></td>\n' \
+ ' </tr>\n')
+
+
+SOURCEFILE_PROLOGUE = string.Template(
+ '<!DOCTYPE html>\n' \
+ '<html>\n' \
+ '<head>\n' \
+ ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n' \
+ ' <meta http-equiv="Content-Style-Type" content="text/css">\n' \
+ ' <meta http-equiv="Content-Script-Type" content="text/javascript">\n' \
+ ' <link rel="stylesheet" type="text/css" href="${assets}/style.css">\n' \
+ ' <script type="text/javascript">var assetsurl="${assets}"</script>\n' \
+ ' <script type="text/javascript" src="${assets}/common.js"></script>\n' \
+ ' <title>Source File: ${filename}</title>\n' \
+ '</head>\n' \
+ '<body>\n' \
+ '<h1>${title}</h1>\n')
+
+SOURCEFILE_ROW_PARENT = string.Template(
+ ' <tr>\n' \
+ ' <td><a href="${machinehref}">${shortname}</a></td>\n' \
+ ' <td><a href="${machinehref}">${description}</a></td>\n' \
+ ' <td>${year}</td>\n' \
+ ' <td>${manufacturer}</td>\n' \
+ ' <td>${runnable}</td>\n' \
+ ' <td></td>\n' \
+ ' </tr>\n')
+
+SOURCEFILE_ROW_CLONE = string.Template(
+ ' <tr>\n' \
+ ' <td><a href="${machinehref}">${shortname}</a></td>\n' \
+ ' <td><a href="${machinehref}">${description}</a></td>\n' \
+ ' <td>${year}</td>\n' \
+ ' <td>${manufacturer}</td>\n' \
+ ' <td>${runnable}</td>\n' \
+ ' <td><a href="${parenthref}">${parent}</a></td>\n' \
+ ' </tr>\n')
+
+
+SOURCEFILE_LIST_PROLOGUE = string.Template(
+ '<!DOCTYPE html>\n' \
+ '<html>\n' \
+ '<head>\n' \
+ ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n' \
+ ' <meta http-equiv="Content-Style-Type" content="text/css">\n' \
+ ' <meta http-equiv="Content-Script-Type" content="text/javascript">\n' \
+ ' <link rel="stylesheet" type="text/css" href="${assets}/style.css">\n' \
+ ' <script type="text/javascript">var assetsurl="${assets}"</script>\n' \
+ ' <script type="text/javascript" src="${assets}/common.js"></script>\n' \
+ ' <title>${title}</title>\n' \
+ '</head>\n' \
+ '<body>\n' \
+ '<h1>${heading}</h1>\n' \
+ '<table id="tbl-sourcefiles">\n' \
+ ' <thead>\n' \
+ ' <tr>\n' \
+ ' <th>Source file</th>\n' \
+ ' <th class="numeric">Machines</th>\n' \
+ ' </tr>\n' \
+ ' </thead>\n' \
+ ' <tbody>\n')
+
+SOURCEFILE_LIST_ROW = string.Template(
+ ' <tr>\n' \
+ ' <td>${sourcefile}</td>\n' \
+ ' <td style="text-align: right">${machines}</td>\n' \
+ ' </tr>\n')