74
73
req.write(' <link rel="stylesheet" type="text/css" href="%s" />\n'
75
74
% cgi.escape(util.make_path(style)))
76
75
for script in req.scripts:
77
req.write(' <script type="text/javascript" src="%s"></script>\n'
76
req.write(' <script type="text/javascript" src="%s" />\n'
78
77
% cgi.escape(util.make_path(script)))
80
79
req.write("</head>\n\n")
82
81
# Open the body element and write a bunch of stuff there (the header)
83
82
req.write("""<body>
84
<div id="ivleheader"></div>
85
<div id="ivleheader_text">
87
85
<h2>Informatics Virtual Learning Environment</h2>
91
# Get the user's nickname from the request session
92
nickname = req.user.nick
93
req.write(' <p class="userhello"><span id="usernick">%s</span> '
94
'(<span class="username">%s</span>) |\n'
95
' <a href="%s">Settings</a> |\n'
89
req.write(' <p class="userhello">Welcome, <span '
90
'class="username">%s</span> |\n'
96
91
' <a href="%s">Help</a> |\n'
97
' <a href="%s">Sign out</a>\n'
92
' <a href="%s">Logout</a>\n'
99
(cgi.escape(nickname), cgi.escape(req.user.login),
100
cgi.escape(util.make_path('settings')),
94
(cgi.escape(req.username),
101
95
cgi.escape(get_help_url(req)),
102
96
cgi.escape(util.make_path('logout'))))
104
98
req.write(' <p class="userhello">Not logged in.</p>')
106
# ivleheader_tabs is a separate div, so it can be positioned absolutely
107
req.write('</div>\n<div id="ivleheader_tabs">\n')
109
100
# If the "debuginfo" app is installed, display a warning to the admin to
110
101
# make sure it is removed in production.
111
102
if "debuginfo" in conf.apps.app_url:
112
req.write(" <p><small>Warning: debuginfo is enabled. Set "
113
"enable_debuginfo = False in lib/conf/apps.py, when placing IVLE "
114
"into production.</small></p>\n")
103
req.write(" <p><small>Warning: debuginfo is enabled. Remove this "
104
"app from conf.apps.app_url when placed into production."
106
# ivleheader_tabs is a separate div, so it can be positioned absolutely
107
req.write('</div>\n<div id="ivleheader_tabs">\n')
116
# If req has a "no_agreement" attribute, then it is because the user has
117
# not signed the agreement; therefore we are displaying the TOS page.
118
# Do not show apps (see dispatch.login).
119
if req.user and not req.user.state == 'no_agreement':
120
110
# Only print app tabs if logged in
121
111
print_apps_list(req, req.app)
122
112
req.write('</div>\n<div id="ivlebody">\n')
131
121
def get_help_url(req):
132
122
"""Gets the help URL most relevant to this page, to place as the
133
123
"help" link at the top of the page."""
134
reqapp = req.app if hasattr(req, 'app') else None
124
if req.app == 'help':
136
125
# We're already in help. Link to the exact current page
137
126
# instead of the generic help page.
139
if reqapp is not None and conf.apps.app_url[reqapp].hashelp:
140
help_path = os.path.join('help', reqapp)
128
if conf.apps.app_url[req.app].hashelp:
129
help_path = os.path.join('help', req.app)
142
131
help_path = 'help'
143
132
return util.make_path(help_path)
146
135
"""Given an app's url name, gets the URL of the icon image for this app,
147
136
relative to the site root. Returns None if the app has no icon."""
148
137
if appurl is None: return None
150
app = conf.apps.app_url[appurl]
152
# Due to navigating to a bad app
138
app = conf.apps.app_url[appurl]
155
140
icon_dir = conf.apps.app_icon_dir_small
176
161
file.write(' <li%s>' % li_attr)
178
163
file.write('<img src="%s" alt="" /> '
179
% urllib.quote(get_icon_url(urlname)))
180
file.write('<a href="%s" title="%s">%s</a></li>\n'
181
% (urllib.quote(util.make_path(urlname)), cgi.escape(app.desc),
182
cgi.escape(app.name)))
164
% cgi.escape(get_icon_url(urlname)))
165
file.write('<a href="%s">%s</a></li>\n'
166
% (cgi.escape(util.make_path(urlname)), cgi.escape(app.name)))
184
168
file.write(' </ul>\n')