49
52
<title>%sIVLE</title>
50
53
<meta http-equiv="Content-Type" content="%s; charset=utf-8" />
51
""" % (titlepart, req.content_type))
54
""" % (cgi.escape(titlepart), cgi.escape(req.content_type)))
52
55
# Write inline JavaScript which gives the client code access to certain
53
56
# server-side variables.
55
username = repr(req.username)
58
username = repr(req.user.login)
58
61
req.write(""" <script type="text/javascript">
62
""" % (repr(conf.root_dir), username))
63
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)
65
69
req.write(""" <link rel="shortcut icon" href="%s" />
70
""" % cgi.escape(iconurl))
67
71
req.write(""" <link rel="stylesheet" type="text/css" href="%s" />
68
""" % util.make_path('media/common/ivle.css'))
72
""" % cgi.escape(util.make_path('media/common/ivle.css')))
70
74
# Write any app-specific style and script links
71
75
for style in req.styles:
72
76
req.write(' <link rel="stylesheet" type="text/css" href="%s" />\n'
73
% util.make_path(style))
77
% cgi.escape(util.make_path(style)))
74
78
for script in req.scripts:
75
req.write(' <script type="text/javascript" src="%s" />\n'
76
% util.make_path(script))
79
req.write(' <script type="text/javascript" src="%s"></script>\n'
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')
78
86
req.write("</head>\n\n")
80
88
# Open the body element and write a bunch of stuff there (the header)
81
89
req.write("""<body>
90
<div id="ivleheader"></div>
91
<div id="ivleheader_text">
84
93
<h2>Informatics Virtual Learning Environment</h2>
88
req.write(' <p class="userhello">Welcome, <span '
89
'class="username">%s</span> |\n'
97
req.write(' <p class="userhello">Running in public mode.</p>')
99
# Get the user's nickname from the request session
100
nickname = req.user.nick
101
req.write(' <p class="userhello"><span id="usernick">%s</span> '
102
'(<span class="username">%s</span>) |\n'
103
' <a href="%s">Settings</a> |\n'
90
104
' <a href="%s">Help</a> |\n'
91
' <a href="%s">Logout</a>\n'
105
' <a href="%s">Sign out</a>\n'
93
(req.username, get_help_url(req), util.make_path('logout')))
107
(cgi.escape(nickname), cgi.escape(req.user.login),
108
cgi.escape(util.make_path('settings')),
109
cgi.escape(get_help_url(req)),
110
cgi.escape(util.make_path('logout'))))
95
112
req.write(' <p class="userhello">Not logged in.</p>')
114
# ivleheader_tabs is a separate div, so it can be positioned absolutely
115
req.write('</div>\n<div id="ivleheader_tabs">\n')
97
117
# If the "debuginfo" app is installed, display a warning to the admin to
98
118
# make sure it is removed in production.
99
119
if "debuginfo" in conf.apps.app_url:
100
req.write(" <p><small>Warning: debuginfo is enabled. Remove this "
101
"app from conf.apps.app_url when placed into production."
120
req.write(" <p><small>Warning: debuginfo is enabled. Set "
121
"enable_debuginfo = False in lib/conf/apps.py, when placing IVLE "
122
"into production.</small></p>\n")
124
# If req has a "no_agreement" attribute, then it is because the user has
125
# not signed the agreement; therefore we are displaying the TOS page.
126
# Do not show apps (see dispatch.login).
127
if req.user and not req.user.state == 'no_agreement':
105
128
# Only print app tabs if logged in
106
129
print_apps_list(req, req.app)
107
130
req.write('</div>\n<div id="ivlebody">\n')
116
139
def get_help_url(req):
117
140
"""Gets the help URL most relevant to this page, to place as the
118
141
"help" link at the top of the page."""
119
if req.app == 'help':
142
reqapp = req.app if hasattr(req, 'app') else None
120
144
# We're already in help. Link to the exact current page
121
145
# instead of the generic help page.
123
if conf.apps.app_url[req.app].hashelp:
124
help_path = os.path.join('help', req.app)
147
if reqapp is not None and reqapp in conf.apps.app_url and \
148
conf.apps.app_url[reqapp].hashelp:
149
help_path = os.path.join('help', reqapp)
126
151
help_path = 'help'
127
152
return util.make_path(help_path)