Personal wiki notebook (not under development)

Page.py 1.5KB

123456789101112131415161718192021222324252627282930313233343536
  1. from Tags import Html, Head, Link, Script, Meta, Title, Body, Div, A, H1
  2. from config.Version import VERSION
  3. class Page( Html ):
  4. def __init__( self, title, *children, **attrs ):
  5. head_types = ( Link, Script, Meta ) # node types to move to the Head section
  6. app_name = u"Luminotes"
  7. if not title: title = u"personal wiki notebook"
  8. if "id" not in attrs:
  9. attrs[ "id" ] = u"content"
  10. # move certain types of children from the body to the head
  11. Html.__init__(
  12. self,
  13. Head(
  14. Link( rel = u"stylesheet", type = u"text/css", href = u"/static/css/style.css?%s" % VERSION ),
  15. Meta( content = u"text/html; charset=UTF-8", http_equiv = u"content-type" ),
  16. [ child for child in children if isinstance( child, head_types ) ],
  17. Title( title and u"%s: %s" % ( app_name, title ) or app_name ),
  18. """<!--[if IE 6]><link href="/static/css/ie6.css?%s" type="text/css" rel="stylesheet"></link><![endif]-->""" % VERSION,
  19. """<!--[if IE 7]><link href="/static/css/ie7.css?%s" type="text/css" rel="stylesheet"></link><![endif]-->""" % VERSION,
  20. """<!--[if IE 8]><link href="/static/css/ie8.css?%s" type="text/css" rel="stylesheet"></link><![endif]-->""" % VERSION,
  21. ),
  22. Body(
  23. Div(
  24. *[ child for child in children if not isinstance( child, head_types ) ],
  25. **attrs
  26. ),
  27. ),
  28. id = "html",
  29. xmlns = u"http://www.w3.org/1999/xhtml",
  30. prefix = u'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\n'
  31. )