From: Felix Domke Date: Mon, 17 Jul 2006 13:56:37 +0000 (+0000) Subject: move xml files into web/, support hierarchy X-Git-Tag: 2.6.0~3155 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/954106887a9b77a26753c5613ff368ce4c997044 move xml files into web/, support hierarchy --- diff --git a/configure.ac b/configure.ac index 6320aee0..9cb32b1d 100644 --- a/configure.ac +++ b/configure.ac @@ -75,6 +75,8 @@ lib/python/Plugins/DemoPlugins/TestPlugin/Makefile lib/python/Plugins/Extensions/Makefile lib/python/Plugins/Extensions/TuxboxPlugins/Makefile lib/python/Plugins/Extensions/WebInterface/Makefile +lib/python/Plugins/Extensions/WebInterface/web/Makefile +lib/python/Plugins/Extensions/WebInterface/web-data/Makefile lib/python/Plugins/Extensions/FileManager/Makefile lib/python/Plugins/Extensions/CutListEditor/Makefile lib/python/Plugins/Extensions/ZappingAlternatives/Makefile diff --git a/lib/python/Plugins/Extensions/WebInterface/Makefile.am b/lib/python/Plugins/Extensions/WebInterface/Makefile.am index 7ea6391d..e69de29b 100644 --- a/lib/python/Plugins/Extensions/WebInterface/Makefile.am +++ b/lib/python/Plugins/Extensions/WebInterface/Makefile.am @@ -1,5 +0,0 @@ -installdir = $(LIBDIR)/enigma2/python/Plugins/Extensions/WebInterface - -install_PYTHON = \ - __init__.py \ - plugin.py webif.py *.xml diff --git a/lib/python/Plugins/Extensions/WebInterface/plugin.py b/lib/python/Plugins/Extensions/WebInterface/plugin.py index 84a82331..cc9a546b 100644 --- a/lib/python/Plugins/Extensions/WebInterface/plugin.py +++ b/lib/python/Plugins/Extensions/WebInterface/plugin.py @@ -5,18 +5,30 @@ sessions = [ ] def startWebserver(): from twisted.internet import reactor from twisted.web2 import server, http, static, resource, stream, http_headers, responsecode + from twisted.python import util import webif class ScreenPage(resource.Resource): + def __init__(self, path): + self.path = path + def render(self, req): global sessions if sessions == [ ]: return http.Response(200, stream="please wait until enigma has booted") s = stream.ProducerStream() - webif.renderPage(s, req, sessions[0]) # login? + webif.renderPage(s, self.path, sessions[0]) # login? return http.Response(stream=s) + def locateChild(self, request, segments): + path = '/'.join(["web"] + segments) + if path[-1:] == "/": + path += "index" + + path += ".xml" + return ScreenPage(path), () + class Toplevel(resource.Resource): addSlash = True @@ -24,8 +36,9 @@ def startWebserver(): return http.Response(responsecode.OK, {'Content-type': http_headers.MimeType('text', 'html')}, stream='Hello! you want probably go to the test instead.') - child_test = ScreenPage() # "/test" + child_web = ScreenPage("/") # "/web" child_hdd = static.File("/hdd") + child_webdata = static.File(util.sibpath(__file__, "web-data")) site = server.Site(Toplevel()) diff --git a/lib/python/Plugins/Extensions/WebInterface/web-data/Makefile.am b/lib/python/Plugins/Extensions/WebInterface/web-data/Makefile.am new file mode 100644 index 00000000..7b3caf9b --- /dev/null +++ b/lib/python/Plugins/Extensions/WebInterface/web-data/Makefile.am @@ -0,0 +1,3 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins/Extensions/WebInterface/web-data/ + +install_PYTHON = diff --git a/lib/python/Plugins/Extensions/WebInterface/web/Makefile.am b/lib/python/Plugins/Extensions/WebInterface/web/Makefile.am new file mode 100644 index 00000000..2dd9b809 --- /dev/null +++ b/lib/python/Plugins/Extensions/WebInterface/web/Makefile.am @@ -0,0 +1,4 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins/Extensions/WebInterface/web/ + +install_PYTHON = *.xml + diff --git a/lib/python/Plugins/Extensions/WebInterface/test.xml b/lib/python/Plugins/Extensions/WebInterface/web/index.xml similarity index 100% rename from lib/python/Plugins/Extensions/WebInterface/test.xml rename to lib/python/Plugins/Extensions/WebInterface/web/index.xml diff --git a/lib/python/Plugins/Extensions/WebInterface/webif.py b/lib/python/Plugins/Extensions/WebInterface/webif.py index 6025a2e2..3bbc28dd 100644 --- a/lib/python/Plugins/Extensions/WebInterface/webif.py +++ b/lib/python/Plugins/Extensions/WebInterface/webif.py @@ -174,12 +174,12 @@ def lreduce(list): string = None return res -def renderPage(stream, req, session): +def renderPage(stream, path, session): handler = webifHandler(session) parser = make_parser() parser.setFeature(feature_namespaces, 0) parser.setContentHandler(handler) - parser.parse(open(util.sibpath(__file__, 'test.xml'))) # currently fixed + parser.parse(open(util.sibpath(__file__, path))) for x in lreduce(handler.res): stream.write(str(x)) stream.finish() # must be done, unless we "callLater"