-
Notifications
You must be signed in to change notification settings - Fork 9
/
Page.py
108 lines (83 loc) · 2.95 KB
/
Page.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# -*- coding: utf-8 -*-
import os
import CTK
#
# Widgets
#
class MenuBar (CTK.Box):
def __init__ (self):
CTK.Box.__init__ (self, {'id': 'bar'})
bar = CTK.Box ({'id': 'bar-inner'})
link = CTK.Link ("/", CTK.Image({'src': "/static/images/logo.png"}))
bar += CTK.Box ({'id': 'logo'}, link)
nav = CTK.Box ({'id': 'nav'})
l = CTK.List()
l += CTK.Link ("/downloads.html", CTK.RawHTML("Download"))
l += CTK.Link ("/doc/", CTK.RawHTML("Documentation"))
l += CTK.Link ("/community.html", CTK.RawHTML("Community"))
l += CTK.Link ("/contribute.html", CTK.RawHTML("Contribute"))
nav += l
bar += nav
self += bar
class Footer (CTK.Box):
ALVARO_URL = "http://www.linkedin.com/profile/view?id=19919180"
def __init__ (self):
CTK.Box.__init__ (self, {'id': 'footer'})
box = CTK.Box ({'id': 'footer-inner'})
box += CTK.RawHTML ('Obviously powered by Cherokee!<br/>')
box += CTK.RawHTML ('© 2001-2011 ')
box += CTK.LinkWindow (self.ALVARO_URL, CTK.RawHTML('Alvaro Lopez Ortega'))
self += box
#
# Base classes
#
class Page_Base (CTK.Page):
def __init__ (self, title=None, body_id='body-cherokee', **kwargs):
# Load the theme
srcdir = os.path.dirname (os.path.realpath (__file__))
theme_file = os.path.join (srcdir, 'theme.html')
template = CTK.Template (filename=theme_file)
# Build the page title
if title:
full_title = '%s: %s' %(_("Cherokee Project"), title)
else:
full_title = _("Cherokee Web Server")
template['title'] = full_title
if body_id:
template['body_props'] = ' id="%s"'%(body_id)
# Constructor
CTK.Page.__init__ (self, template, None, None, **kwargs)
#
# Pages
#
class Page_Menu (Page_Base):
def __init__ (self, *args, **kwargs):
Page_Base.__init__ (self, *args, **kwargs)
# Add MenuBar
Page_Base.__iadd__ (self, MenuBar())
# Add banner area
self.banner = CTK.Box({'id': 'banner'})
Page_Base.__iadd__ (self, self.banner)
# Main Container (tricky)
self.container = CTK.Box ({'id': 'container'})
Page_Base.__iadd__ (self, self.container)
def __iadd__ (self, widget):
self.container += widget
return self
def Render (self):
Page_Base.__iadd__ (self, CTK.Box ({'class': 'clr'}))
Page_Base.__iadd__ (self, Footer())
return Page_Base.Render (self)
#
# Pages Sidebar
#
class Page_Menu_Side (Page_Menu):
def __init__ (self, *args, **kwargs):
Page_Menu.__init__ (self, *args, **kwargs)
self.main = CTK.Box({'id': 'main_area'})
self.sidebar = CTK.Box({'id': 'sidebar'})
Page_Menu.__iadd__ (self, self.sidebar)
Page_Menu.__iadd__ (self, self.main)
def __iadd__ (self, widget):
self.main += widget
return self