mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -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.headerTemplate = LandingPageHTML.header
|
||||||
self.footerTemplate = LandingPageHTML.footer
|
self.footerTemplate = LandingPageHTML.footer
|
||||||
|
|
||||||
#self.title = LandingPageHTML.title
|
|
||||||
#self.contactInfo = LandingPageHTML.contactInfo
|
|
||||||
|
|
||||||
self.menu = {}
|
self.menu = {}
|
||||||
|
|
||||||
self.uriToTitle = {}
|
self.uriToTitle = {}
|
||||||
|
|
||||||
|
self.quickStats = [[],{}]
|
||||||
|
|
||||||
|
self.addQuickStat("Pages Served", 0, 0)
|
||||||
|
|
||||||
def addTab(self, title, uri):
|
def addTab(self, title, uri):
|
||||||
self.menu[title] = uri
|
self.menu[title] = uri
|
||||||
self.uriToTitle[uri] = title
|
self.uriToTitle[uri] = title
|
||||||
@ -54,10 +55,16 @@ class LandingPage:
|
|||||||
LandingPageHTML.mainPageBody = body
|
LandingPageHTML.mainPageBody = body
|
||||||
|
|
||||||
def setTitle(self, title):
|
def setTitle(self, title):
|
||||||
|
if LandingPageHTML.title == LandingPageHTML.defaultTitle:
|
||||||
LandingPageHTML.title = title
|
LandingPageHTML.title = title
|
||||||
|
else:
|
||||||
|
LandingPageHTML.title = LandingPageHTML.title + " + " + title
|
||||||
|
|
||||||
def setDescription(self,desc):
|
def setDescription(self,desc):
|
||||||
|
if LandingPageHTML.description == LandingPageHTML.defaultDesc:
|
||||||
LandingPageHTML.description = desc
|
LandingPageHTML.description = desc
|
||||||
|
else:
|
||||||
|
LandingPageHTML.description = LandingPageHTML.description + "</P>\n<P>" + desc
|
||||||
|
|
||||||
def setContactInfo(self,info):
|
def setContactInfo(self,info):
|
||||||
LandingPageHTML.contactInfo = info
|
LandingPageHTML.contactInfo = info
|
||||||
@ -65,12 +72,31 @@ class LandingPage:
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return LandingPageHTML.description
|
return LandingPageHTML.description
|
||||||
|
|
||||||
def getMainPage(self):
|
def getQuickStatsTable(self):
|
||||||
return LandingPageHTML.mainPageBody
|
return LandingPageHTML.getQuickStatsTable(self.quickStats)
|
||||||
|
|
||||||
def getQuickStatsTable(self, quickStats):
|
def getMainPage(self):
|
||||||
return LandingPageHTML.getQuickStatsTable(quickStats)
|
return LandingPageHTML.mainPageBody % {"description" : self.getDescription(),
|
||||||
|
"quickstats" : self.getQuickStatsTable()}
|
||||||
|
|
||||||
def skin(self, body, uri):
|
def skin(self, body, uri):
|
||||||
title = self.uriToTitle.get(uri,"Services")
|
title = self.uriToTitle.get(uri,"Services")
|
||||||
return self.getHeader(title) + body + self.getFooter()
|
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! --
|
# -- Text content for the landing page. You should change these for yours! --
|
||||||
|
|
||||||
title = "Landing Page"
|
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)."
|
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"
|
contactInfo = "M. Ian Graham - ian.graham@dig.com - 818-623-3219"
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,9 +86,6 @@ class WebRequestDispatcher(object):
|
|||||||
|
|
||||||
notify = notify
|
notify = notify
|
||||||
|
|
||||||
quickStats = [["Pages Served"],
|
|
||||||
{"Pages Served" : 0}]
|
|
||||||
|
|
||||||
def __new__(self, *a, **kw):
|
def __new__(self, *a, **kw):
|
||||||
obj = object.__new__(self, *a, **kw)
|
obj = object.__new__(self, *a, **kw)
|
||||||
obj.__dict__ = self._shared_state
|
obj.__dict__ = self._shared_state
|
||||||
@ -121,7 +118,7 @@ class WebRequestDispatcher(object):
|
|||||||
"""
|
"""
|
||||||
assert req.getRequestType() == "GET"
|
assert req.getRequestType() == "GET"
|
||||||
|
|
||||||
self.incrementQuickStat("Pages Served")
|
self.landingPage.incrementQuickStat("Pages Served")
|
||||||
|
|
||||||
uri = req.getURI()
|
uri = req.getURI()
|
||||||
args = req.dictFromGET()
|
args = req.dictFromGET()
|
||||||
@ -216,13 +213,10 @@ class WebRequestDispatcher(object):
|
|||||||
if enable:
|
if enable:
|
||||||
if not self.__dict__.has_key("landingPage"):
|
if not self.__dict__.has_key("landingPage"):
|
||||||
self.landingPage = LandingPage()
|
self.landingPage = LandingPage()
|
||||||
self.setTitle(self.__class__.__name__)
|
|
||||||
self.registerGETHandler("/", self._main, returnsResponse = True, autoSkin = True)
|
self.registerGETHandler("/", self._main, returnsResponse = True, autoSkin = True)
|
||||||
self.registerGETHandler("/services", self._services, returnsResponse = True, autoSkin = True)
|
self.registerGETHandler("/services", self._services, returnsResponse = True, autoSkin = True)
|
||||||
self.landingPage.addTab("Main", "/")
|
self.landingPage.addTab("Main", "/")
|
||||||
self.landingPage.addTab("Services", "/services")
|
self.landingPage.addTab("Services", "/services")
|
||||||
else:
|
|
||||||
self.setTitle(self.__class__.__name__)
|
|
||||||
else:
|
else:
|
||||||
self.landingPage = None
|
self.landingPage = None
|
||||||
self.unregisterGETHandler("/")
|
self.unregisterGETHandler("/")
|
||||||
@ -230,35 +224,7 @@ class WebRequestDispatcher(object):
|
|||||||
|
|
||||||
|
|
||||||
def _main(self):
|
def _main(self):
|
||||||
return self.landingPage.getMainPage() % {"description" : self.landingPage.getDescription(),
|
return self.landingPage.getMainPage()
|
||||||
"quickstats" : self.landingPage.getQuickStatsTable(self.quickStats)}
|
|
||||||
|
|
||||||
def _services(self):
|
def _services(self):
|
||||||
return self.landingPage.getServicesPage(self.uriToHandler)
|
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