Page Source

from utils.static_strings import StaticStringControl, StaticStringDisplay, StaticString
from utils.web_exc import WebError, SendLiteral
from utils import perms
import debugging
import string, os

class RootDisplay(StaticStringDisplay, StaticString):
  title = "Department of Computer Science"
  tab = "info"
  single_controls = [ StaticStringControl(key="website_index")]
                      
  def make_page(self, page):
    if self.req.url.arguments == ['favicon.ico']:
        raise SendLiteral('application/icon', open("/stage/w3serv/www.cs.uchicago.edu/docs/favicon.ico").read())
    if self.req.url.arguments == ['robots.txt']: # Do we want robots.txt
      if self.req.server.server_hostname == "www.cs.uchicago.edu": # Is it www or a vhost
        raise SendLiteral('text/plain',self.GetString("www_robots.txt"))
      else:
        raise SendLiteral('text/plain',self.GetString("www_robots.txt"))
    # Send appropriate robots.txt
    self.add_page_links(page)
    StaticStringDisplay.make_page(self,page)

  def add_page_links(self, page):
    if perms.may(self.req.login,'display','admin'):
      page.add_navigation('%(/admin)s' % self.req.urls, 'Admin')

def new(req):
  return RootDisplay(req)