From 240b6c5e63d3f3b7064048a3b8a03c0e88d7cf3a Mon Sep 17 00:00:00 2001 From: Brendan Howell Date: Fri, 18 Nov 2016 13:12:59 +0100 Subject: [PATCH] some hacks for barcode layout wierdness --- screenless/bureau/ihr/ihr.py | 18 +++++++++++++++++- screenless/bureau/ihr/menu.html | 9 +++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/screenless/bureau/ihr/ihr.py b/screenless/bureau/ihr/ihr.py index f1fcd82..fbc388a 100644 --- a/screenless/bureau/ihr/ihr.py +++ b/screenless/bureau/ihr/ihr.py @@ -2,10 +2,26 @@ import json import subprocess import code128 +from lxml import etree from bureau import Bureau, add_command, add_api +def clean_svg(svg): + """ + This is a little hack that removes the height and width attributes from + SVG strings as they confuse Firefox. Sigh... hopefully this can go away + some day. + """ + utf8_parser = etree.XMLParser(encoding='utf-8') + svg = svg.encode("utf-8") + otree = etree.fromstring(svg, utf8_parser) + del otree.attrib["height"] + del otree.attrib["width"] + clean_svg = etree.tostring(otree) + return clean_svg.decode("utf-8") + + class InhumanResources(Bureau): """ This is a core functional bureau of the Screenless office it keeps track @@ -52,7 +68,7 @@ class InhumanResources(Bureau): cmd = data["cmd"] cmdname = data["cmdname"] desc = data["desc"] - barcode = code128.svg(prefix + cmd + ".") + barcode = clean_svg(code128.svg(prefix + cmd + ".")) except KeyError as e: print("cannot add invalid command:", str(e)) return diff --git a/screenless/bureau/ihr/menu.html b/screenless/bureau/ihr/menu.html index 724ffbd..4923c45 100644 --- a/screenless/bureau/ihr/menu.html +++ b/screenless/bureau/ihr/menu.html @@ -17,6 +17,9 @@ .bureau h3 { border-bottom: 1px solid black; } + .bureau .description { + line-height: 1.2; + } .cmd { clear: both; width: 100%; @@ -29,13 +32,19 @@ } .cmdcol svg { width: 100%; + height: 41px; } .cmddesc { margin-top: 0; + line-height: 1.1; } .cmdname { font-weight: bold; font-family: "TeX Gyre Adventor"; + line-height: 1.1; + } + .cmdtxt { + margin-top: 1em; }