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