'
class timestamps (div): open = '
'
class mopdetails (div):
open = '
'
sep = "
\n" class sbbutton (div): open = '
\n" class sbbutton (div): open = '
'
def __init__ (self, mobile, path, title = None, qs = ""):
if title is None:
super ().__init__ (path)
else:
super ().__init__ (makelink (mobile, path, title, qs))
class sbbutton_active (sbbutton): open = '
'
class section (div):
open = '
'
hdr = "h3"
def __init__ (self, title, body):
super ().__init__ ("<{0}>{1}{0}>".format (self.hdr, title), body)
class firstsection (section): hdr = "h2"
class tbsection (section):
def __init__ (self, title, header, data):
"""Return an HTML section with the supplied section title,
followed by a table made from the header and data.
"""
super ().__init__ (title, table (header, data))
class detail_section (section):
def __init__ (self, title, header, data):
super ().__init__ (title, detail_table (header, data))
class textsection (section):
def __init__ (self, title, body):
super ().__init__ (title, lines (*body))
class firsttextsection (textsection): hdr = "h2"
class presection (section):
def __init__ (self, title, body):
super ().__init__ (title, pre (*body))
class top (div):
open = '
'
def __init__ (self, title, times):
return super ().__init__ (toptitle (title), timestamps (times))
class footer (div):
open = '
'
class doc (object):
def __init__ (self, mobile, title, top, middle, bottom):
self.mobile = mobile
self.title = title
self.top = top
self.middle = middle
self.bottom = bottom
def __str__ (self, hdradd = ""):
addmeta = ""
if self.mobile:
addmeta = \
'''
'''
return """
{0.title}
{1}{2}
{0.top}
{0.middle}
{0.bottom}
""".format (self, addmeta, hdradd)
#
class mapdoc (doc):
"Similar to doc, but for maps"
def __str__ (self):
return super ().__str__ ('''
''')
def page_title (title, links = ()):
now = time.time ()
ts = time.strftime ("%d-%b-%Y %H:%M:%S %Z", time.localtime (now))
spaces = " " * 4
ll = (("/", "Home"),) + links
links = ''.join (spaces + '{}'.format (*l) for l in ll)
uptime = str (timedelta (int (now - start_time) / 86400.))
return top (title, "Reported {}, up {}{}".format (ts, uptime, links))