diff --git a/direct/src/http/HTMLTree.py b/direct/src/http/HTMLTree.py deleted file mode 100755 index f96b5c9d05..0000000000 --- a/direct/src/http/HTMLTree.py +++ /dev/null @@ -1,19 +0,0 @@ -import xml.etree.ElementTree as ET - -class HTMLTree(ET.ElementTree): - def __init__(self, title): - root = ET.Element('HTML') - ET.ElementTree.__init__(self, root) - - head = ET.SubElement(root, 'HEAD') - titleTag = ET.SubElement(head, 'TITLE') - titleTag.text = title - - body = ET.SubElement(root, 'BODY') - - def getBody(self): - return self.find('BODY') - - def getHead(self): - return self.find('HEAD') - diff --git a/direct/src/http/LandingPage.py b/direct/src/http/LandingPage.py deleted file mode 100755 index 212e3a6e20..0000000000 --- a/direct/src/http/LandingPage.py +++ /dev/null @@ -1,188 +0,0 @@ -import os -from direct.directnotify.DirectNotifyGlobal import directNotify -from pandac.PandaModules import VirtualFileSystem -from pandac.PandaModules import Filename -from pandac.PandaModules import DSearchPath -import xml.etree.ElementTree as ET -import LandingPageHTML -from StringIO import StringIO - -class LandingPage: - notify = directNotify.newCategory("LandingPage") - def __init__(self): - self.headerTemplate = LandingPageHTML.header - self.footerTemplate = LandingPageHTML.footer - - self.menu = {} - - self.uriToTitle = {} - - self.quickStats = [[],{}] - - self.addQuickStat("Pages Served", 0, 0) - - self.favicon = self.readFavIcon() - - - def readFavIcon(self): - vfs = VirtualFileSystem.getGlobalPtr() - filename = Filename('favicon.ico') - - searchPath = DSearchPath() - searchPath.appendDirectory(Filename('.')) - searchPath.appendDirectory(Filename('etc')) - searchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('$DIRECT/src/http'))) - searchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('direct/src/http'))) - searchPath.appendDirectory(Filename.fromOsSpecific(os.path.expandvars('direct/http'))) - found = vfs.resolveFilename(filename,searchPath) - if not found: - raise "Couldn't find direct/http/favicon.ico" - - return vfs.readFile(filename, 1) - - - def addTab(self, title, uri): - self.menu[title] = uri - self.uriToTitle[uri] = title - - def getMenu(self, activeTab): - return LandingPageHTML.getTabs(self.menu,activeTab) - - def getMenuTags(self, activeTab): - return LandingPageHTML.getTabTags(self.menu, activeTab) - - def getHeader(self, activeTab = "Main", headTag=None, bodyTag=None): - if headTag is None: - headTag = ET.Element('head') - if bodyTag is None: - bodyTag = ET.Element('body') - - # make sure each component has elements to make formatting consistent - headTag.append(ET.Comment('')) - bodyTag.append(ET.Comment('')) - - fileStr = StringIO() - ET.ElementTree(headTag).write(fileStr, encoding='utf-8') - headTagStr = unicodeUtf8(fileStr.getvalue()) - # remove the tag closer - # - headTagStr = headTagStr[:headTagStr.rindex('<')] - - # fill in the prefab body tag content - titleStr = LandingPageHTML.title - landing = ET.Element('body') - LandingPageHTML.addBodyHeaderAndContent(landing, titleStr, self.getMenuTags(activeTab)) - - fileStr = StringIO() - ET.ElementTree(landing).write(fileStr, encoding='utf-8') - landingStr = unicodeUtf8(fileStr.getvalue()) - # remove
- landingStr = landingStr[landingStr.index('>')+1:] - # remove tag closers - for i in xrange(3): - # - # contents - # - landingStr = landingStr[:landingStr.rindex('<')] - - fileStr = StringIO() - ET.ElementTree(bodyTag).write(fileStr, encoding='utf-8') - bodyTagStr = unicodeUtf8(fileStr.getvalue()) - # extract - bodyStr = bodyTagStr[bodyTagStr.index('>')+1:] - bodyTagStr = bodyTagStr[:bodyTagStr.index('>')+1] - - bodyStr = bodyTagStr + '\n' + landingStr + '\n' + bodyStr - - s = self.headerTemplate % {'titlestring': titleStr, - 'headTag' : headTagStr, - 'bodyTag': bodyStr, - } - return s - - def getFooter(self): - return self.footerTemplate % {'contact' : LandingPageHTML.contactInfo} - - def getServicesPage(self, uriToHandler): - output = "" - - uriList = uriToHandler.keys() - - uriList.sort() - - autoList = [] - - if "/" in uriList: - uriList.remove("/") - autoList.append("/") - if "/services" in uriList: - uriList.remove("/services") - autoList.append("/services") - if "/default.css" in uriList: - uriList.remove("/default.css") - autoList.append("/default.css") - if "/favicon.ico" in uriList: - uriList.remove("/favicon.ico") - autoList.append("/favicon.ico") - - output += LandingPageHTML.getURITable(title="Application",uriList=uriList,uriToHandler=uriToHandler) - - output += LandingPageHTML.getURITable(title="Admin",uriList=autoList,uriToHandler=uriToHandler) - - return output - - def populateMainPage(self, body): - LandingPageHTML.mainPageBody = body - - def setTitle(self, title): - if LandingPageHTML.title == LandingPageHTML.defaultTitle: - LandingPageHTML.title = title - else: - LandingPageHTML.title = LandingPageHTML.title + " + " + title - - def setDescription(self,desc): - if LandingPageHTML.description == LandingPageHTML.defaultDesc: - LandingPageHTML.description = desc - else: - LandingPageHTML.description = LandingPageHTML.description + "\n" + desc
-
- def setContactInfo(self,info):
- LandingPageHTML.contactInfo = info
-
- def getDescription(self):
- return LandingPageHTML.description
-
- def getQuickStatsTable(self):
- return LandingPageHTML.getQuickStatsTable(self.quickStats)
-
- def getMainPage(self):
- return LandingPageHTML.mainPageBody % {"description" : self.getDescription(),
- "quickstats" : self.getQuickStatsTable()}
-
- def getStyleSheet(self):
- return LandingPageHTML.stylesheet
-
- def getFavIcon(self):
- return self.favicon
-
- def skin(self, body, uri, headTag=None, bodyTag=None):
- title = self.uriToTitle.get(uri,"Services")
- return self.getHeader(title, headTag, bodyTag) + body + self.getFooter()
-
- def addQuickStat(self,item,value,position):
- if item in self.quickStats[1]:
- assert 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
diff --git a/direct/src/http/LandingPageHTML.py b/direct/src/http/LandingPageHTML.py
deleted file mode 100755
index bc04caf80e..0000000000
--- a/direct/src/http/LandingPageHTML.py
+++ /dev/null
@@ -1,476 +0,0 @@
-# -- Text content for the landing page. You should change these for yours! --
-
-import xml.etree.ElementTree as ET
-
-title = "Landing Page"
-defaultTitle = title
-
-description = "To set this description, call WebRequestDispatcher.setDescription!
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"
-
-
-# -- Begin fancy layout stuff, change at your own risk --
-
-stylesheet = '''
- body
- {
- margin: 0;
- padding: 0;
- font-size: 90%;
- font-family: Verdana, sans-serif;
- background-color: #fff;
- color: #333;
- }
-
- p
- {
- margin: 0;
- padding: 10px;
- background-color: #eee;
- }
-
- h2
- {
- font-size: 140%;
- color: #666;
- background-color: #fff;
- width: 22em;
- margin-left: 150px;
- margin-top: 0px;
- }
-
- h3
- {
- padding-top: 10px;
- margin-top: 0px;
- margin-left: 20px;
- }
-
- pre
- {
- margin-left: 20px;
- margin-bottom: 0px;
- padding-bottom: 10px;
- }
-
- a
- {
- text-decoration: none;
- color: #333;
- }
-
- a:hover
- {
- text-decoration: underline;
- }
-
- #header
- {
- margin: 0;
- padding: 0;
- background-color: #fff;
- }
-
- #footer
- {
- margin: 0;
- padding: 3px;
- text-align: right;
- background-color: #fff;
- border-top: 1px solid #778;
- font: 10px Verdana, sans-serif;
- }
-
- #contents
- {
- margin: 0;
- padding: 25;
- background-color: #eee;
- min-height:600px;
- height:auto !important;
- height:600px;
- }
-
-
-
- #navcontainer
- {
- margin:0;
- padding: 0;
- }
-
- #navlist
- {
- padding: 3px 0;
- margin-left: 0;
- margin: 0;
- border-bottom: 1px solid #778;
- font: bold 12px Verdana, sans-serif;
- background-color: transparent;
- }
-
- #navlist li
- {
- list-style: none;
- margin: 0;
- display: inline;
- }
-
- #navlist li a
- {
- padding: 3px 0.5em;
- margin-left: 3px;
- border: 1px solid #778;
- border-bottom: none;
- background: #DDE;
- text-decoration: none;
- }
-
- #navlist li a:link { color: #448; }
- #navlist li a:visited { color: #667; }
-
- #navlist li a:hover
- {
- color: #000;
- background: #AAE;
- border-color: #227;
- }
-
- #navlist li a#current
- {
- background: #eee;
- border-bottom: 1px solid #eee;
- }
-
- #navlist li.first
- {
- margin-left: 150px;
- }
-
-
-
- table
- {
- border-spacing:1px;
- background:#E7E7E7;
- color:#333;
- }
-
- caption
- {
- border: #666666;
- border-bottom: 2px solid #666666;
- margin-left: 2px;
- margin-right: 2px;
- padding: 10px;
- background: #cfcfdf;
- font: 15px 'Verdana', Arial, Helvetica, sans-serif;
- font-weight: bold;
- }
-
- td, th
- {
- font:13px 'Courier New',monospace;
- padding: 4px;
- }
-
- thead th
- {
- text-align: center;
- background: #dde;
- color: #666666;
- border: 1px solid #ffffff;
- text-transform: uppercase;
- }
-
- tbody th
- {
- font-weight: bold;
- }
-
- tbody tr
- {
- background: #efeffc;
- text-align: left;
- }
-
- tbody tr.odd
- {
- background: #ffffff;
- border-top: 1px solid #ffffff;
- }
-
- tbody th a:hover
- {
- color: #009900;
- }
-
- tbody tr td
- {
- text-align: left
- height: 30px;
- background: #ffffff;
- border: 1px solid #ffffff;
- color: #333;
- }
-
- tbody tr.odd td
- {
- background: #efeffc;
- border-top: 1px solid #ffffff;
- }
-
- tbody tr[altColoring="1"] td
- {
- background: LightCyan;
- border-top: 1px solid #ffffff;
- }
-
- tbody tr[altColoring="1"].odd td
- {
- background: PaleTurquoise;
- border-top: 1px solid #ffffff;
- }
-
- tbody tr[altColoring="2"] td
- {
- background: LightSalmon;
- border-top: 1px solid #ffffff;
- }
-
- tbody tr[altColoring="2"].odd td
- {
- background: SandyBrown;
- border-top: 1px solid #ffffff;
- }
-
- tbody tr.dead td
- {
- background:#ff0000;
- border-top: 1px solid #ffffff;
- }
-
- table td a:link, table td a:visited
- {
- display: block;
- padding: 0px;
- margin: 0px;
- width: 100%;
- text-decoration: none;
- color: #333;
- }
-
- html>body #navcontainer li a { width: auto; }
-
- table td a:hover
- {
- color: #000000;
- background: #aae;
- }
-
- tfoot th, tfoot td
- {
- background: #dfdfdf;
- padding: 3px;
- text-align: center;
- font: 14px 'Verdana', Arial, Helvetica, sans-serif;
- font-weight: bold;
- border-bottom: 1px solid #cccccc;
- border-top: 1px solid #DFDFDF;
- }
-\r\n'''
-
-header = '''
-
-
-%(headTag)s
-
-
%(description)s
- -%(quickstats)s
-''' - -footer = ''' - - - - - - - -