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