mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
Landing page cleanup
This commit is contained in:
parent
69e0b18738
commit
54adb46e48
@ -5,13 +5,14 @@ class LandingPage:
|
||||
self.headerTemplate = LandingPageHTML.header
|
||||
self.footerTemplate = LandingPageHTML.footer
|
||||
|
||||
#self.title = LandingPageHTML.title
|
||||
#self.contactInfo = LandingPageHTML.contactInfo
|
||||
|
||||
self.menu = {}
|
||||
|
||||
self.uriToTitle = {}
|
||||
|
||||
self.quickStats = [[],{}]
|
||||
|
||||
self.addQuickStat("Pages Served", 0, 0)
|
||||
|
||||
def addTab(self, title, uri):
|
||||
self.menu[title] = uri
|
||||
self.uriToTitle[uri] = title
|
||||
@ -54,10 +55,16 @@ class LandingPage:
|
||||
LandingPageHTML.mainPageBody = body
|
||||
|
||||
def setTitle(self, title):
|
||||
LandingPageHTML.title = title
|
||||
if LandingPageHTML.title == LandingPageHTML.defaultTitle:
|
||||
LandingPageHTML.title = title
|
||||
else:
|
||||
LandingPageHTML.title = LandingPageHTML.title + " + " + title
|
||||
|
||||
def setDescription(self,desc):
|
||||
LandingPageHTML.description = desc
|
||||
if LandingPageHTML.description == LandingPageHTML.defaultDesc:
|
||||
LandingPageHTML.description = desc
|
||||
else:
|
||||
LandingPageHTML.description = LandingPageHTML.description + "</P>\n<P>" + desc
|
||||
|
||||
def setContactInfo(self,info):
|
||||
LandingPageHTML.contactInfo = info
|
||||
@ -65,12 +72,31 @@ class LandingPage:
|
||||
def getDescription(self):
|
||||
return LandingPageHTML.description
|
||||
|
||||
def getQuickStatsTable(self):
|
||||
return LandingPageHTML.getQuickStatsTable(self.quickStats)
|
||||
|
||||
def getMainPage(self):
|
||||
return LandingPageHTML.mainPageBody
|
||||
|
||||
def getQuickStatsTable(self, quickStats):
|
||||
return LandingPageHTML.getQuickStatsTable(quickStats)
|
||||
|
||||
return LandingPageHTML.mainPageBody % {"description" : self.getDescription(),
|
||||
"quickstats" : self.getQuickStatsTable()}
|
||||
|
||||
def skin(self, body, uri):
|
||||
title = self.uriToTitle.get(uri,"Services")
|
||||
return self.getHeader(title) + body + self.getFooter()
|
||||
|
||||
def addQuickStat(self,item,value,position):
|
||||
if item in self.quickStats[1]:
|
||||
self.notify.warning("Ignoring duplicate addition of quickstat %s." % item)
|
||||
return
|
||||
|
||||
self.quickStats[0].insert(position,item)
|
||||
self.quickStats[1][item] = value
|
||||
|
||||
def updateQuickStat(self,item,value):
|
||||
assert item in self.quickStats[1]
|
||||
|
||||
self.quickStats[1][item] = value
|
||||
|
||||
def incrementQuickStat(self,item):
|
||||
assert item in self.quickStats[1]
|
||||
|
||||
self.quickStats[1][item] += 1
|
||||
|
@ -1,7 +1,11 @@
|
||||
# -- Text content for the landing page. You should change these for yours! --
|
||||
|
||||
title = "Landing Page"
|
||||
defaultTitle = title
|
||||
|
||||
description = "To set this description, call WebRequestDispatcher.setDescription!<BR><BR>You can also add stats to the table below by calling WebRequestDispatcher.addQuickStat(Name,Value,PositionInTable)."
|
||||
defaultDesc = description
|
||||
|
||||
contactInfo = "M. Ian Graham - ian.graham@dig.com - 818-623-3219"
|
||||
|
||||
|
||||
|
@ -86,9 +86,6 @@ class WebRequestDispatcher(object):
|
||||
|
||||
notify = notify
|
||||
|
||||
quickStats = [["Pages Served"],
|
||||
{"Pages Served" : 0}]
|
||||
|
||||
def __new__(self, *a, **kw):
|
||||
obj = object.__new__(self, *a, **kw)
|
||||
obj.__dict__ = self._shared_state
|
||||
@ -121,7 +118,7 @@ class WebRequestDispatcher(object):
|
||||
"""
|
||||
assert req.getRequestType() == "GET"
|
||||
|
||||
self.incrementQuickStat("Pages Served")
|
||||
self.landingPage.incrementQuickStat("Pages Served")
|
||||
|
||||
uri = req.getURI()
|
||||
args = req.dictFromGET()
|
||||
@ -216,13 +213,10 @@ class WebRequestDispatcher(object):
|
||||
if enable:
|
||||
if not self.__dict__.has_key("landingPage"):
|
||||
self.landingPage = LandingPage()
|
||||
self.setTitle(self.__class__.__name__)
|
||||
self.registerGETHandler("/", self._main, returnsResponse = True, autoSkin = True)
|
||||
self.registerGETHandler("/services", self._services, returnsResponse = True, autoSkin = True)
|
||||
self.landingPage.addTab("Main", "/")
|
||||
self.landingPage.addTab("Services", "/services")
|
||||
else:
|
||||
self.setTitle(self.__class__.__name__)
|
||||
else:
|
||||
self.landingPage = None
|
||||
self.unregisterGETHandler("/")
|
||||
@ -230,35 +224,7 @@ class WebRequestDispatcher(object):
|
||||
|
||||
|
||||
def _main(self):
|
||||
return self.landingPage.getMainPage() % {"description" : self.landingPage.getDescription(),
|
||||
"quickstats" : self.landingPage.getQuickStatsTable(self.quickStats)}
|
||||
return self.landingPage.getMainPage()
|
||||
|
||||
def _services(self):
|
||||
return self.landingPage.getServicesPage(self.uriToHandler)
|
||||
|
||||
def setTitle(self,title):
|
||||
self.landingPage.setTitle(title)
|
||||
|
||||
def setDescription(self,desc):
|
||||
self.landingPage.setDescription(desc)
|
||||
|
||||
def setContactInfo(self,info):
|
||||
self.landingPage.setContactInfo(info)
|
||||
|
||||
def addQuickStat(self,item,value,position):
|
||||
if item in self.quickStats[1]:
|
||||
self.notify.warning("Ignoring duplicate addition of quickstat %s." % item)
|
||||
return
|
||||
|
||||
self.quickStats[0].insert(position,item)
|
||||
self.quickStats[1][item] = value
|
||||
|
||||
def updateQuickStat(self,item,value):
|
||||
assert item in self.quickStats[1]
|
||||
|
||||
self.quickStats[1][item] = value
|
||||
|
||||
def incrementQuickStat(self,item):
|
||||
assert item in self.quickStats[1]
|
||||
|
||||
self.quickStats[1][item] += 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user