add barcodes. use html templates for menu.

workspace
Brendan Howell 9 years ago
parent 88bf14f087
commit 020b75a619

@ -1,5 +1,7 @@
import json
import code128
from bureau import Bureau, add_command, add_api
@ -25,7 +27,7 @@ class InhumanResources(Bureau):
Register Bureau with Inhuman Resources
data = { prefix: "IR",
bureauname: "Inhuman Resources",
name: "Inhuman Resources",
desc: "Keep track of public resources provided by bureaus"
}
"""
@ -35,7 +37,7 @@ class InhumanResources(Bureau):
desc = data["desc"]
except KeyError as e:
print("cannot add invalid bureau:", str(e))
return
return str(e)
print("added menu")
self.menu[prefix] = {"name": name,
"desc": desc,
@ -49,6 +51,7 @@ class InhumanResources(Bureau):
cmd = data["cmd"]
cmdname = data["cmdname"]
desc = data["desc"]
barcode = code128.svg(prefix + cmd + ".")
except KeyError as e:
print("cannot add invalid command:", str(e))
return
@ -58,7 +61,8 @@ class InhumanResources(Bureau):
prefix)
else:
self.menu[prefix]["commands"][cmd] = {"name": cmdname,
"desc": desc}
"desc": desc,
"barcode": barcode}
@add_api("addapi", "Register API Method")
def add_api_method(self, data):
@ -83,6 +87,7 @@ class InhumanResources(Bureau):
"""
Prints the menu of commands for all operational bureaus.
"""
self.print_full("menu.html", menu=self.menu)
print(self.menu)

@ -0,0 +1,48 @@
<html>
<head>
<title>The Screenless Office - Main Menu</title>
<style type="text/css">
body {
font-family: Georgia;
font-size: 11pt;
}
.bureau {
clear: both;
width: 100%;
}
.cmd {
width: 33%;
float: left;
}
.barcode {
height: 1cm;
}
svg {
width: 100%;
}
</style>
</head>
<body>
<div "main">
%for prefix, buro in menu.items():
<div class="bureau">
<h1>${buro["name"]}</h1>
<div class="prefix">Prefix: ${prefix}</div>
<p class="description">${buro["desc"]}</p>
<div class="commands">
%for cmdtxt, cmd in buro["commands"].items():
% if cmdtxt != "test":
<div class="cmd">
<h3>${cmd["name"]}</h3>
<div class="cmdtxt">${cmdtxt}</div>
<div class="barcode">${cmd["barcode"]}</div>
<p>${cmd["desc"]}</p>
</div>
% endif
%endfor
</div>
</div>
%endfor
</div>
</body>
</html>
Loading…
Cancel
Save