Author: dmeyer
Date: Thu Feb 23 13:17:53 2006
New Revision: 7930

Added:
   trunk/WIP/webserver/src/index.tmpl
   trunk/WIP/webserver/src/pages.py
Removed:
   trunk/WIP/webserver/src/foo.tmpl
Modified:
   trunk/WIP/webserver/bin/freevo-webserver2
   trunk/WIP/webserver/src/browse/__init__.py
   trunk/WIP/webserver/src/root.py
   trunk/WIP/webserver/src/tv/__init__.py
   trunk/WIP/webserver/src/tv/recordings.tmpl

Log:
auto header generation

Modified: trunk/WIP/webserver/bin/freevo-webserver2
==============================================================================
--- trunk/WIP/webserver/bin/freevo-webserver2   (original)
+++ trunk/WIP/webserver/bin/freevo-webserver2   Thu Feb 23 13:17:53 2006
@@ -15,13 +15,13 @@
 # freevo core imports
 import freevo.ipc
 
-# freevo webserver imports
-from freevo.webserver2 import Root
-
 # attach ipc.tvserver to the mbus
 mbus = freevo.ipc.Instance('webserver')
 mbus.connect('freevo.ipc.tvserver')
 
+# freevo webserver imports
+from freevo.webserver2 import Root
+
 # start server
 #kaa.cherrypy.config.debug = True
 kaa.cherrypy.start(Root)

Modified: trunk/WIP/webserver/src/browse/__init__.py
==============================================================================
--- trunk/WIP/webserver/src/browse/__init__.py  (original)
+++ trunk/WIP/webserver/src/browse/__init__.py  Thu Feb 23 13:17:53 2006
@@ -17,7 +17,7 @@
     # notice: pass the _imported_module_ to this function here
     @kaa.cherrypy.expose(template=listing)
     def index(self):
-        print 'running on port %s' % self.config.port
+#         print 'running on port %s' % self.config.port
         print 'basename is %s' % self.basename
         return dict(title = '/', items = os.listdir('/'))
 

Added: trunk/WIP/webserver/src/index.tmpl
==============================================================================
--- (empty file)
+++ trunk/WIP/webserver/src/index.tmpl  Thu Feb 23 13:17:53 2006
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
+
+<html>
+  <head>
+    <title>Freevo | Welcome</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
+    <link rel="stylesheet" href="styles/main.css" type="text/css"></link>
+  </head>
+  
+  <body>
+    #import time
+    
+    $header
+    
+    <div id="contentmain">
+      <h2>Freevo Web Status as of $time.strftime('%B %d %H:%M', 
time.localtime())</h2>
+      
+      #if $tvserver.recordings.server:
+      <p class="normal">The recording server is up and running</p>
+      #else
+      <p class="alert">The tvserver is down</p>
+      #end if
+      
+  </body>
+</html>    

Added: trunk/WIP/webserver/src/pages.py
==============================================================================
--- (empty file)
+++ trunk/WIP/webserver/src/pages.py    Thu Feb 23 13:17:53 2006
@@ -0,0 +1,39 @@
+# list of pages in the tab menu
+_pages = []
+
+
+def register(pos, module, name, description=''):
+    """
+    Register a page to the tab list.
+    """
+    if not description:
+        description = name
+    for p in _pages:
+        if p[3] == module:
+            return
+    _pages.append((pos, name, description, module))
+    _pages.sort(lambda x,y: cmp(x[0], y[0]))
+
+
+def header(selected):
+    """
+    Print page header with menu tabs.
+    """
+    res = [ '<!-- Header Logo and Status Line -->\n',
+            '<div id="titlebar">\n',
+            '  <span class="name">\n',
+            '    <a href="http://freevo.sourceforge.net/"; 
target="_blank">Freevo</a>\n',
+            '  </span>\n',
+            '</div>\n',
+            '<div id="header">\n',
+            '  <ul>\n    ' ]
+
+    for i in _pages:
+        if selected == i[3]:
+            res.append('<li id="current">')
+        else:
+            res.append('<li>')
+        res.append("<a href=\"%s\" title=\"%s\">%s</a></li>\n" % (i[3], 
i[2],i[1]))
+    res.append('  </ul>\n</div>\n<br clear="all"/>\n')
+    res.append('<!-- Main Content -->\n')
+    return ''.join(res)

Modified: trunk/WIP/webserver/src/root.py
==============================================================================
--- trunk/WIP/webserver/src/root.py     (original)
+++ trunk/WIP/webserver/src/root.py     Thu Feb 23 13:17:53 2006
@@ -1,14 +1,21 @@
-# Define root functions here. No objects (subdirs). Use a real subdir
-# with a new Root dir instead
-
+# python imports
 import os
 
+# kaa imports
 import kaa.cherrypy
 
+# freevo core imports
+import freevo.ipc
+
+# basic page style
 import config
+from freevo.webserver2.pages import header, register
 
-# cheetah template!
-import foo
+# templates
+import index
+
+# get tvserver interface
+tvserver = freevo.ipc.Instance().tvserver
 
 class Root:
 
@@ -45,11 +52,10 @@
 
     # add other functions here
     
-    @kaa.cherrypy.expose()
+    @kaa.cherrypy.expose(template=index)
     def index(self):
-        return 'running on port %s' % self.config.port
+        return dict(tvserver=tvserver, header=header('/'))
+
 
-    # notice: pass the _imported_module_ to this function here
-    @kaa.cherrypy.expose(template=foo)
-    def test(self):
-        return dict(lines=['a', 'b'])
+# register pages
+register(0, '/', _('Home'), _('Home'))

Modified: trunk/WIP/webserver/src/tv/__init__.py
==============================================================================
--- trunk/WIP/webserver/src/tv/__init__.py      (original)
+++ trunk/WIP/webserver/src/tv/__init__.py      Thu Feb 23 13:17:53 2006
@@ -1,30 +1,34 @@
+# python imports
 import kaa.cherrypy
 
-import recordings
-import rec2
-
 # freevo core imports
 import freevo.ipc
 
+# basic page style
+from freevo.webserver2.pages import header, register
+
+# templates
+import recordings
+import rec2
+
 # get tvserver interface
 tvserver = freevo.ipc.Instance().tvserver
 
-# root for browse
 class Root:
-
-    @kaa.cherrypy.expose()
-    def index(self):
-        print 'running on port %s' % self.config.port
-        print 'basename is %s' % self.basename
-        return ""
-
-    # notice: pass the _imported_module_ to this function here
+    """
+    Root node for /tv
+    """
+    
     @kaa.cherrypy.expose(template=recordings)
     def recordings(self):
         x = tvserver.recordings.list()[:]
         x.sort(lambda a,b: cmp(a.start, b.start))
-        return dict(recordings=x)
+        return dict(recordings=x, header=header('/tv/recordings'))
 
     # A kid template as function without extra attributes. The template
     # loads tvserver by itself.
     rec2 = kaa.cherrypy.template(rec2)
+
+
+# register pages
+register(20, '/tv/recordings', _('Scheduled Recordings'), _('View Scheduled 
Recordings'))

Modified: trunk/WIP/webserver/src/tv/recordings.tmpl
==============================================================================
--- trunk/WIP/webserver/src/tv/recordings.tmpl  (original)
+++ trunk/WIP/webserver/src/tv/recordings.tmpl  Thu Feb 23 13:17:53 2006
@@ -1,13 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
-
-#import time
-
-#def strtime(t)
-$time.strftime('%b %d %H:%M', time.localtime(t))
-#end def
-
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
 <html>
+
+  #import time
+  
+  #def strtime(t)
+  $time.strftime('%b %d %H:%M', time.localtime(t))
+  #end def
+  
   <head>
     <title>Freevo | Scheduled Recordings</title>
     <meta http-equiv="Content-Type" content= "text/html; charset=utf-8" />
@@ -15,18 +16,8 @@
   </head>
 
   <body>
-    <!-- Header Logo and Status Line -->
-    <div id="titlebar"><span class="name"><a 
href="http://freevo.sourceforge.net/"; target="_blank">Freevo</a></span></div>
-    <div id="header">
-      <ul><li><a href="index" title="Home">Home</a></li>
-       <li><a href="guide" title="View TV Listings">TV Guide</a></li>
-       <li id="current"><a href="recordings" title="View Scheduled 
Recordings">Scheduled Recordings</a></li>
-       <li><a href="search" title="Advanced Search Page">Search</a></li>
-       <li><a href="doc" title="View Online Help and 
Documentation">Doc</a></li>
-      </ul>
-    </div><br clear="all" />
+    $header
     
-    <!-- Main Content -->
     &nbsp;
     <table>
       <tr class="chanrow">


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to