73
73
req.write(' <link rel="stylesheet" type="text/css" href="%s" />\n'
74
74
% cgi.escape(util.make_path(style)))
75
75
for script in req.scripts:
76
req.write(' <script type="text/javascript" src="%s"></script>\n'
76
req.write(' <script type="text/javascript" src="%s" />\n'
77
77
% cgi.escape(util.make_path(script)))
79
79
req.write("</head>\n\n")
81
81
# Open the body element and write a bunch of stuff there (the header)
82
82
req.write("""<body>
83
<div id="ivleheader"></div>
84
<div id="ivleheader_text">
86
85
<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'
89
req.write(' <p class="userhello">Welcome, <span '
90
'class="username">%s</span> |\n'
94
91
' <a href="%s">Help</a> |\n'
95
92
' <a href="%s">Logout</a>\n'
97
(cgi.escape(nickname), cgi.escape(req.username),
94
(cgi.escape(req.username),
98
95
cgi.escape(get_help_url(req)),
99
96
cgi.escape(util.make_path('logout'))))
101
98
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
100
# If the "debuginfo" app is installed, display a warning to the admin to
107
101
# make sure it is removed in production.
108
102
if "debuginfo" in conf.apps.app_url:
110
104
"app from conf.apps.app_url when placed into production."
111
105
"</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
108
# Only print app tabs if logged in
118
109
print_apps_list(req, req.app)
119
110
req.write('</div>\n<div id="ivlebody">\n')
128
119
def get_help_url(req):
129
120
"""Gets the help URL most relevant to this page, to place as the
130
121
"help" link at the top of the page."""
131
reqapp = req.app if hasattr(req, 'app') else None
122
if req.app == 'help':
133
123
# We're already in help. Link to the exact current page
134
124
# 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)
126
if conf.apps.app_url[req.app].hashelp:
127
help_path = os.path.join('help', req.app)
139
129
help_path = 'help'
140
130
return util.make_path(help_path)