trying out web view for internet radio station management

workspace
Brendan Howell 4 years ago
parent 041758983c
commit e6c109dd36

@ -17,6 +17,7 @@ class IhrApp(Bottle):
self.route("/log/<bureau>", callback=self.bureau_log) self.route("/log/<bureau>", callback=self.bureau_log)
self.route('/static/<path:path>', callback=self.static) self.route('/static/<path:path>', callback=self.static)
self.bureaus = [] self.bureaus = []
self.views = {}
mpath = inspect.getfile(self.__class__) mpath = inspect.getfile(self.__class__)
self.tdir = os.path.dirname(mpath) self.tdir = os.path.dirname(mpath)
@ -29,10 +30,16 @@ class IhrApp(Bottle):
<h4><em>Web Manager</em></h4> <h4><em>Web Manager</em></h4>
<ul> <ul>
""" """
print("webviews", self.views)
for bureau in self.bureaus: for bureau in self.bureaus:
out += '<li>{0}:<ul>\n'.format(bureau) out += '<li>{0}:<ul>\n'.format(bureau)
out += '<li><a href="/config/{0}">{0} config</a></li>\n'.format(bureau) out += '<li><a href="/config/{0}">{0} config</a></li>\n'.format(bureau)
out += '<li><a href="/log/{0}">{0} logs</a></li>\n'.format(bureau) out += '<li><a href="/log/{0}">{0} logs</a></li>\n'.format(bureau)
if bureau in self.views:
for view in self.views[bureau]:
out += '<li><a href="/{0}/{1}">{1}</a></li>\n'.format(bureau, view)
out += '</ul></li>' out += '</ul></li>'
out += '<li><a href="/config/printers">Printers</a></li>\n' out += '<li><a href="/config/printers">Printers</a></li>\n'
@ -91,6 +98,11 @@ class IhrApp(Bottle):
self.bureaus.append(bureau) self.bureaus.append(bureau)
def register_webview(self, prefix, view, callback): def register_webview(self, prefix, view, callback):
#TODO: add description
if prefix in self.views:
self.views[prefix].append(view)
else:
self.views[prefix] = [view]
def wrapped_cb(): def wrapped_cb():
callback(request.forms) callback(request.forms)
self.route("/" + prefix + "/" + view, callback=wrapped_cb) self.route("/" + prefix + "/" + view, callback=wrapped_cb)

Loading…
Cancel
Save