move xml files into web/, support hierarchy
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 17 Jul 2006 13:56:37 +0000 (13:56 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 17 Jul 2006 13:56:37 +0000 (13:56 +0000)
configure.ac
lib/python/Plugins/Extensions/WebInterface/Makefile.am
lib/python/Plugins/Extensions/WebInterface/plugin.py
lib/python/Plugins/Extensions/WebInterface/web-data/Makefile.am [new file with mode: 0644]
lib/python/Plugins/Extensions/WebInterface/web/Makefile.am [new file with mode: 0644]
lib/python/Plugins/Extensions/WebInterface/web/index.xml [moved from lib/python/Plugins/Extensions/WebInterface/test.xml with 100% similarity]
lib/python/Plugins/Extensions/WebInterface/webif.py

index 6320aee..9cb32b1 100644 (file)
@@ -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
index 7ea6391..e69de29 100644 (file)
@@ -1,5 +0,0 @@
-installdir = $(LIBDIR)/enigma2/python/Plugins/Extensions/WebInterface
-
-install_PYTHON =       \
-       __init__.py \
-       plugin.py webif.py *.xml
index 84a8233..cc9a546 100644 (file)
@@ -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 <a href="/test">the test</a> 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 (file)
index 0000000..7b3caf9
--- /dev/null
@@ -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 (file)
index 0000000..2dd9b80
--- /dev/null
@@ -0,0 +1,4 @@
+installdir = $(LIBDIR)/enigma2/python/Plugins/Extensions/WebInterface/web/
+
+install_PYTHON = *.xml
+
index 6025a2e..3bbc28d 100644 (file)
@@ -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"