Blame template/common.py

Ivan Mahonin 48408a
Ivan Mahonin 48408a
from template.template import Template
Ivan Mahonin 05525d
from template.login import LoginTemplate
Ivan Mahonin 05525d
from template.usermenu import UsermenuTemplate
Ivan Mahonin b838e2
from template.errors import ErrorsTemplate
Ivan Mahonin 48408a
Ivan Mahonin 48408a
Ivan Mahonin 05525d
class CommonTemplate(Template):
Ivan Mahonin 05525d
  def __init__(self):
Ivan Mahonin b838e2
    super().__init__()
Ivan Mahonin 05525d
    self.login = LoginTemplate()
Ivan Mahonin 05525d
    self.usermenu = UsermenuTemplate()
Ivan Mahonin b838e2
    self.errors = ErrorsTemplate()
Ivan Mahonin 05525d
  
Ivan Mahonin 05525d
  def wrap(self, answer):
Ivan Mahonin 572081
    titles = list()
Ivan Mahonin 572081
    uipath = list()
Ivan Mahonin 572081
    for i in answer.uipath:
Ivan Mahonin 572081
      title = answer.e(i[0])
Ivan Mahonin 572081
      link = answer.request.get_urlpath_escaped(i[1])
Ivan Mahonin 572081
      titles.insert(0, title)
Ivan Mahonin 572081
      uipath.append('%s' % (link, title))
Ivan Mahonin 572081
    
Ivan Mahonin 572081
    title = titles[0] if titles else ''
Ivan Mahonin 572081
    
Ivan Mahonin 48408a
    return '''
Ivan Mahonin b838e2
      <html>
Ivan Mahonin b838e2
        <head>
Ivan Mahonin 572081
          <title>%(titlechain)s</title>
Ivan Mahonin b838e2
          <link rel="stylesheet" href="%(dataprefix)s/common.css" />
Ivan Mahonin b838e2
        </head>
Ivan Mahonin b838e2
        <body>
Ivan Mahonin b838e2
          
Ivan Mahonin b838e2
            
Ivan Mahonin b838e2
            %(usermenu)s
Ivan Mahonin b838e2
          
Ivan Mahonin 572081
          
Ivan Mahonin 572081
            %(errors)s
Ivan Mahonin 572081
          
Ivan Mahonin 572081
          
Ivan Mahonin 572081
            %(uipath)s
Ivan Mahonin 572081
          
Ivan Mahonin b838e2
          
Ivan Mahonin 572081
            

%(title)s

Ivan Mahonin b838e2
            %(content)s
Ivan Mahonin b838e2
          
Ivan Mahonin b838e2
          
Ivan Mahonin b838e2
            powered by magic
Ivan Mahonin b838e2
          
Ivan Mahonin b838e2
        </body>
Ivan Mahonin b838e2
      </html>
Ivan Mahonin b838e2
      ''' % {
Ivan Mahonin 572081
        'titlechain' : ' | '.join(titles),
Ivan Mahonin 572081
        'uipath'     : ' : '.join(uipath),
Ivan Mahonin 572081
        'title'      : title,
Ivan Mahonin b838e2
        'prefix'     : answer.urlprefix,
Ivan Mahonin b838e2
        'dataprefix' : answer.urldataprefix,
Ivan Mahonin b838e2
        'usermenu'   : (self.usermenu if answer.request.session else self.login).wrap(answer),
Ivan Mahonin b838e2
        'errors'     : self.errors.wrap(answer),
Ivan Mahonin b838e2
        'content'    : answer.content,
Ivan Mahonin b838e2
      }