39
39
# Note the inline JavaScript, which provides the client with constants
40
40
# derived from the server configuration.
41
41
if req.title != None:
42
titlepart = ' - ' + req.title
42
titlepart = req.title + ' - '
45
45
req.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
46
46
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
47
47
<html xmlns="http://www.w3.org/1999/xhtml">
50
50
<meta http-equiv="Content-Type" content="%s; charset=utf-8" />
51
<script type="text/javascript">
51
""" % (titlepart, req.content_type))
52
# Write inline JavaScript which gives the client code access to certain
53
# server-side variables.
55
username = repr(req.username)
58
req.write(""" <script type="text/javascript">
54
<link rel="stylesheet" type="text/css" href="%s" />
55
""" % (titlepart, req.content_type,
56
repr(conf.root_dir)[1:-1],
57
util.make_path('media/common/ivle.css')))
62
""" % (repr(conf.root_dir), username))
63
iconurl = get_icon_url(req.app)
65
req.write(""" <link rel="shortcut icon" href="%s" />
67
req.write(""" <link rel="stylesheet" type="text/css" href="%s" />
68
""" % util.make_path('media/common/ivle.css'))
59
70
# Write any app-specific style and script links
60
71
for style in req.styles:
114
126
help_path = 'help'
115
127
return util.make_path(help_path)
129
def get_icon_url(appurl, small=False):
130
"""Given an app's url name, gets the URL of the icon image for this app,
131
relative to the site root. Returns None if the app has no icon."""
132
if appurl is None: return None
133
app = conf.apps.app_url[appurl]
135
icon_dir = conf.apps.app_icon_dir_small
137
icon_dir = conf.apps.app_icon_dir
138
if app.icon is None: return None
139
return util.make_path(os.path.join(icon_dir, app.icon))
117
141
def print_apps_list(file, thisapp):
118
142
"""Prints all app tabs, as a UL. Prints a list item for each app that has
129
153
li_attr = ' class="thisapp"'
132
file.write(' <li%s><a href="%s">%s</a></li>\n'
133
% (li_attr, util.make_path(urlname), app.name))
156
file.write(' <li%s>' % li_attr)
158
file.write('<img src="%s" alt="" /> ' % get_icon_url(urlname))
159
file.write('<a href="%s">%s</a></li>\n'
160
% (util.make_path(urlname), app.name))
135
162
file.write(' </ul>\n')