49
50
<title>%sIVLE</title>
50
51
<meta http-equiv="Content-Type" content="%s; charset=utf-8" />
51
""" % (titlepart, req.content_type))
52
""" % (cgi.escape(titlepart), cgi.escape(req.content_type)))
52
53
# Write inline JavaScript which gives the client code access to certain
53
54
# server-side variables.
63
64
iconurl = get_icon_url(req.app)
65
66
req.write(""" <link rel="shortcut icon" href="%s" />
67
""" % cgi.escape(iconurl))
67
68
req.write(""" <link rel="stylesheet" type="text/css" href="%s" />
68
""" % util.make_path('media/common/ivle.css'))
69
""" % cgi.escape(util.make_path('media/common/ivle.css')))
70
71
# Write any app-specific style and script links
71
72
for style in req.styles:
72
73
req.write(' <link rel="stylesheet" type="text/css" href="%s" />\n'
73
% util.make_path(style))
74
% cgi.escape(util.make_path(style)))
74
75
for script in req.scripts:
75
req.write(' <script type="text/javascript" src="%s" />\n'
76
% util.make_path(script))
76
req.write(' <script type="text/javascript" src="%s"></script>\n'
77
% cgi.escape(util.make_path(script)))
78
79
req.write("</head>\n\n")
80
81
# Open the body element and write a bunch of stuff there (the header)
81
82
req.write("""<body>
83
<div id="ivleheader"></div>
84
<div id="ivleheader_text">
84
86
<h2>Informatics Virtual Learning Environment</h2>
88
req.write(' <p class="userhello">Welcome, <span '
89
'class="username">%s</span> |\n'
90
# Get the user's nickname from the request session
91
nickname = req.get_session()['nick']
92
req.write(' <p class="userhello">%s (<span '
93
'class="username">%s</span>) |\n'
90
94
' <a href="%s">Help</a> |\n'
91
95
' <a href="%s">Logout</a>\n'
93
(req.username, get_help_url(req), util.make_path('logout')))
97
(cgi.escape(nickname), cgi.escape(req.username),
98
cgi.escape(get_help_url(req)),
99
cgi.escape(util.make_path('logout'))))
95
101
req.write(' <p class="userhello">Not logged in.</p>')
103
# ivleheader_tabs is a separate div, so it can be positioned absolutely
104
req.write('</div>\n<div id="ivleheader_tabs">\n')
97
106
# If the "debuginfo" app is installed, display a warning to the admin to
98
107
# make sure it is removed in production.
99
108
if "debuginfo" in conf.apps.app_url:
101
110
"app from conf.apps.app_url when placed into production."
102
111
"</small></p>\n")
113
# If req has a "no_agreement" attribute, then it is because the user has
114
# not signed the agreement; therefore we are displaying the TOS page.
115
# Do not show apps (see dispatch.login).
116
if req.username and not hasattr(req, 'no_agreement'):
105
117
# Only print app tabs if logged in
106
118
print_apps_list(req, req.app)
107
119
req.write('</div>\n<div id="ivlebody">\n')
116
128
def get_help_url(req):
117
129
"""Gets the help URL most relevant to this page, to place as the
118
130
"help" link at the top of the page."""
119
if req.app == 'help':
131
reqapp = req.app if hasattr(req, 'app') else None
120
133
# We're already in help. Link to the exact current page
121
134
# instead of the generic help page.
123
if conf.apps.app_url[req.app].hashelp:
124
help_path = os.path.join('help', req.app)
136
if reqapp is not None and conf.apps.app_url[reqapp].hashelp:
137
help_path = os.path.join('help', reqapp)
126
139
help_path = 'help'
127
140
return util.make_path(help_path)
156
169
file.write(' <li%s>' % li_attr)
158
file.write('<img src="%s" alt="" /> ' % get_icon_url(urlname))
171
file.write('<img src="%s" alt="" /> '
172
% cgi.escape(get_icon_url(urlname)))
159
173
file.write('<a href="%s">%s</a></li>\n'
160
% (util.make_path(urlname), app.name))
174
% (cgi.escape(util.make_path(urlname)), cgi.escape(app.name)))
162
176
file.write(' </ul>\n')