added ability to add tags within landing page HEAD tag

This commit is contained in:
Darren Ranalli 2009-10-19 21:35:07 +00:00
parent 4abfcb2122
commit 98aee03ca0
2 changed files with 16 additions and 2 deletions

View File

@ -3,13 +3,18 @@ from direct.directnotify.DirectNotifyGlobal import directNotify
from pandac.PandaModules import VirtualFileSystem from pandac.PandaModules import VirtualFileSystem
from pandac.PandaModules import Filename from pandac.PandaModules import Filename
from pandac.PandaModules import DSearchPath from pandac.PandaModules import DSearchPath
from direct.showbase import ElementTree as ET
import LandingPageHTML import LandingPageHTML
from StringIO import StringIO
class LandingPage: class LandingPage:
notify = directNotify.newCategory("LandingPage") notify = directNotify.newCategory("LandingPage")
def __init__(self): def __init__(self):
self.headerTemplate = LandingPageHTML.header self.headerTemplate = LandingPageHTML.header
self.footerTemplate = LandingPageHTML.footer self.footerTemplate = LandingPageHTML.footer
# allow modifications to the page head tag
self._headET = ET.Element('head')
self.menu = {} self.menu = {}
@ -47,10 +52,18 @@ class LandingPage:
return LandingPageHTML.getTabs(self.menu,activeTab) return LandingPageHTML.getTabs(self.menu,activeTab)
def getHeader(self, activeTab = "Main"): def getHeader(self, activeTab = "Main"):
headContent = ''
for child in self._headET.getchildren():
fileStr = StringIO()
ET.ElementTree(child).write(fileStr)
headContent += fileStr.getvalue()
s = self.headerTemplate % {'titlestring' : LandingPageHTML.title, s = self.headerTemplate % {'titlestring' : LandingPageHTML.title,
'menustring' : self.getMenu(activeTab)} 'menustring' : self.getMenu(activeTab),
'headContent' : headContent,}
return s return s
def getHead(self):
return self._headET
def getFooter(self): def getFooter(self):
return self.footerTemplate % {'contact' : LandingPageHTML.contactInfo} return self.footerTemplate % {'contact' : LandingPageHTML.contactInfo}

View File

@ -261,6 +261,7 @@ header = '''
<head> <head>
<title>%(titlestring)s</title> <title>%(titlestring)s</title>
<link rel="stylesheet" type="text/css" href="/default.css"> <link rel="stylesheet" type="text/css" href="/default.css">
%(headContent)s
</head> </head>
<body> <body>