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
# 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'
90
req.write(' <p class="userhello">Welcome, <span '
91
'class="username">%s</span> |\n'
97
92
' <a href="%s">Help</a> |\n'
98
' <a href="%s">Sign out</a>\n'
93
' <a href="%s">Logout</a>\n'
100
(cgi.escape(nickname), cgi.escape(req.user.login),
101
cgi.escape(util.make_path('settings')),
95
(cgi.escape(req.username),
102
96
cgi.escape(get_help_url(req)),
103
97
cgi.escape(util.make_path('logout'))))
105
99
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
101
# If the "debuginfo" app is installed, display a warning to the admin to
111
102
# make sure it is removed in production.
112
103
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")
104
req.write(" <p><small>Warning: debuginfo is enabled. Remove this "
105
"app from conf.apps.app_url when placed into production."
107
# ivleheader_tabs is a separate div, so it can be positioned absolutely
108
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
111
# Only print app tabs if logged in
122
112
print_apps_list(req, req.app)
123
113
req.write('</div>\n<div id="ivlebody">\n')
132
122
def get_help_url(req):
133
123
"""Gets the help URL most relevant to this page, to place as the
134
124
"help" link at the top of the page."""
135
reqapp = req.app if hasattr(req, 'app') else None
125
if req.app == 'help':
137
126
# We're already in help. Link to the exact current page
138
127
# 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)
129
if conf.apps.app_url[req.app].hashelp:
130
help_path = os.path.join('help', req.app)
143
132
help_path = 'help'
144
133
return util.make_path(help_path)
147
136
"""Given an app's url name, gets the URL of the icon image for this app,
148
137
relative to the site root. Returns None if the app has no icon."""
149
138
if appurl is None: return None
151
app = conf.apps.app_url[appurl]
153
# Due to navigating to a bad app
139
app = conf.apps.app_url[appurl]
156
141
icon_dir = conf.apps.app_icon_dir_small
177
162
file.write(' <li%s>' % li_attr)
179
164
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)))
165
% cgi.escape(get_icon_url(urlname)))
166
file.write('<a href="%s">%s</a></li>\n'
167
% (cgi.escape(util.make_path(urlname)), cgi.escape(app.name)))
185
169
file.write(' </ul>\n')