53
52
""" % (cgi.escape(titlepart), cgi.escape(req.content_type)))
54
53
# Write inline JavaScript which gives the client code access to certain
55
54
# server-side variables.
57
username = repr(req.user.login)
56
username = repr(req.username)
60
59
req.write(""" <script type="text/javascript">
65
""" % (repr(conf.root_dir), repr(conf.public_host), username))
66
iconurl = get_icon_url(req.app, small=True)
63
""" % (repr(conf.root_dir), username))
64
iconurl = get_icon_url(req.app)
68
66
req.write(""" <link rel="shortcut icon" href="%s" />
69
67
""" % cgi.escape(iconurl))
75
73
req.write(' <link rel="stylesheet" type="text/css" href="%s" />\n'
76
74
% cgi.escape(util.make_path(style)))
77
75
for script in req.scripts:
78
req.write(' <script type="text/javascript" src="%s"></script>\n'
76
req.write(' <script type="text/javascript" src="%s" />\n'
79
77
% cgi.escape(util.make_path(script)))
81
79
req.write("</head>\n\n")
88
86
<h2>Informatics Virtual Learning Environment</h2>
92
90
# Get the user's nickname from the request session
93
nickname = req.user.nick
94
req.write(' <p class="userhello"><span id="usernick">%s</span> '
95
'(<span class="username">%s</span>) |\n'
96
' <a href="%s">Settings</a> |\n'
91
nickname = req.get_session()['nick']
92
req.write(' <p class="userhello">%s (<span '
93
'class="username">%s</span>) |\n'
97
94
' <a href="%s">Help</a> |\n'
98
' <a href="%s">Sign out</a>\n'
95
' <a href="%s">Logout</a>\n'
100
(cgi.escape(nickname), cgi.escape(req.user.login),
101
cgi.escape(util.make_path('settings')),
97
(cgi.escape(nickname), cgi.escape(req.username),
102
98
cgi.escape(get_help_url(req)),
103
99
cgi.escape(util.make_path('logout'))))
105
101
req.write(' <p class="userhello">Not logged in.</p>')
107
# ivleheader_tabs is a separate div, so it can be positioned absolutely
108
req.write('</div>\n<div id="ivleheader_tabs">\n')
110
103
# If the "debuginfo" app is installed, display a warning to the admin to
111
104
# make sure it is removed in production.
112
105
if "debuginfo" in conf.apps.app_url:
113
req.write(" <p><small>Warning: debuginfo is enabled. Set "
114
"enable_debuginfo = False in lib/conf/apps.py, when placing IVLE "
115
"into production.</small></p>\n")
106
req.write(" <p><small>Warning: debuginfo is enabled. Remove this "
107
"app from conf.apps.app_url when placed into production."
109
# ivleheader_tabs is a separate div, so it can be positioned absolutely
110
req.write('</div>\n<div id="ivleheader_tabs">\n')
117
# If req has a "no_agreement" attribute, then it is because the user has
118
# not signed the agreement; therefore we are displaying the TOS page.
119
# Do not show apps (see dispatch.login).
120
if req.user and not req.user.state == 'no_agreement':
121
113
# Only print app tabs if logged in
122
114
print_apps_list(req, req.app)
123
115
req.write('</div>\n<div id="ivlebody">\n')
132
124
def get_help_url(req):
133
125
"""Gets the help URL most relevant to this page, to place as the
134
126
"help" link at the top of the page."""
135
reqapp = req.app if hasattr(req, 'app') else None
127
if req.app == 'help':
137
128
# We're already in help. Link to the exact current page
138
129
# instead of the generic help page.
140
if reqapp is not None and conf.apps.app_url[reqapp].hashelp:
141
help_path = os.path.join('help', reqapp)
131
if conf.apps.app_url[req.app].hashelp:
132
help_path = os.path.join('help', req.app)
143
134
help_path = 'help'
144
135
return util.make_path(help_path)
147
138
"""Given an app's url name, gets the URL of the icon image for this app,
148
139
relative to the site root. Returns None if the app has no icon."""
149
140
if appurl is None: return None
151
app = conf.apps.app_url[appurl]
153
# Due to navigating to a bad app
141
app = conf.apps.app_url[appurl]
156
143
icon_dir = conf.apps.app_icon_dir_small
177
164
file.write(' <li%s>' % li_attr)
179
166
file.write('<img src="%s" alt="" /> '
180
% urllib.quote(get_icon_url(urlname)))
181
file.write('<a href="%s" title="%s">%s</a></li>\n'
182
% (urllib.quote(util.make_path(urlname)), cgi.escape(app.desc),
183
cgi.escape(app.name)))
167
% cgi.escape(get_icon_url(urlname)))
168
file.write('<a href="%s">%s</a></li>\n'
169
% (cgi.escape(util.make_path(urlname)), cgi.escape(app.name)))
185
171
file.write(' </ul>\n')