63
62
""" % (repr(conf.root_dir), username))
64
iconurl = get_icon_url(req.app, small=True)
63
iconurl = get_icon_url(req.app)
66
65
req.write(""" <link rel="shortcut icon" href="%s" />
67
""" % cgi.escape(iconurl))
68
67
req.write(""" <link rel="stylesheet" type="text/css" href="%s" />
69
""" % cgi.escape(util.make_path('media/common/ivle.css')))
68
""" % util.make_path('media/common/ivle.css'))
71
70
# Write any app-specific style and script links
72
71
for style in req.styles:
73
72
req.write(' <link rel="stylesheet" type="text/css" href="%s" />\n'
74
% cgi.escape(util.make_path(style)))
73
% util.make_path(style))
75
74
for script in req.scripts:
76
req.write(' <script type="text/javascript" src="%s"></script>\n'
77
% cgi.escape(util.make_path(script)))
75
req.write(' <script type="text/javascript" src="%s" />\n'
76
% util.make_path(script))
79
78
req.write("</head>\n\n")
81
80
# Open the body element and write a bunch of stuff there (the header)
82
81
req.write("""<body>
83
<div id="ivleheader"></div>
84
<div id="ivleheader_text">
86
84
<h2>Informatics Virtual Learning Environment</h2>
90
# Get the user's nickname from the request session
91
nickname = req.user.nick
92
req.write(' <p class="userhello"><span id="usernick">%s</span> '
93
'(<span class="username">%s</span>) |\n'
94
' <a href="%s">Settings</a> |\n'
88
req.write(' <p class="userhello">Welcome, <span '
89
'class="username">%s</span> |\n'
95
90
' <a href="%s">Help</a> |\n'
96
' <a href="%s">Sign out</a>\n'
91
' <a href="%s">Logout</a>\n'
98
(cgi.escape(nickname), cgi.escape(req.user.login),
99
cgi.escape(util.make_path('settings')),
100
cgi.escape(get_help_url(req)),
101
cgi.escape(util.make_path('logout'))))
93
(req.username, get_help_url(req), util.make_path('logout')))
103
95
req.write(' <p class="userhello">Not logged in.</p>')
105
# ivleheader_tabs is a separate div, so it can be positioned absolutely
106
req.write('</div>\n<div id="ivleheader_tabs">\n')
108
97
# If the "debuginfo" app is installed, display a warning to the admin to
109
98
# make sure it is removed in production.
110
99
if "debuginfo" in conf.apps.app_url:
111
req.write(" <p><small>Warning: debuginfo is enabled. Set "
112
"enable_debuginfo = False in lib/conf/apps.py, when placing IVLE "
113
"into production.</small></p>\n")
100
req.write(" <p><small>Warning: debuginfo is enabled. Remove this "
101
"app from conf.apps.app_url when placed into production."
115
# If req has a "no_agreement" attribute, then it is because the user has
116
# not signed the agreement; therefore we are displaying the TOS page.
117
# Do not show apps (see dispatch.login).
118
if req.user and not req.user.state == 'no_agreement':
119
105
# Only print app tabs if logged in
120
106
print_apps_list(req, req.app)
121
107
req.write('</div>\n<div id="ivlebody">\n')
130
116
def get_help_url(req):
131
117
"""Gets the help URL most relevant to this page, to place as the
132
118
"help" link at the top of the page."""
133
reqapp = req.app if hasattr(req, 'app') else None
119
if req.app == 'help':
135
120
# We're already in help. Link to the exact current page
136
121
# instead of the generic help page.
138
if reqapp is not None and conf.apps.app_url[reqapp].hashelp:
139
help_path = os.path.join('help', reqapp)
123
if conf.apps.app_url[req.app].hashelp:
124
help_path = os.path.join('help', req.app)
141
126
help_path = 'help'
142
127
return util.make_path(help_path)