50
49
<title>%sIVLE</title>
51
50
<meta http-equiv="Content-Type" content="%s; charset=utf-8" />
52
""" % (cgi.escape(titlepart), cgi.escape(req.content_type)))
51
""" % (titlepart, req.content_type))
53
52
# Write inline JavaScript which gives the client code access to certain
54
53
# server-side variables.
56
username = repr(req.user.login)
55
username = repr(req.username)
59
58
req.write(""" <script type="text/javascript">
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">%s (<span '
93
'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:
112
101
"app from conf.apps.app_url when placed into production."
113
102
"</small></p>\n")
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)
145
130
"""Given an app's url name, gets the URL of the icon image for this app,
146
131
relative to the site root. Returns None if the app has no icon."""
147
132
if appurl is None: return None
149
app = conf.apps.app_url[appurl]
151
# Due to navigating to a bad app
133
app = conf.apps.app_url[appurl]
154
135
icon_dir = conf.apps.app_icon_dir_small
175
156
file.write(' <li%s>' % li_attr)
177
file.write('<img src="%s" alt="" /> '
178
% cgi.escape(get_icon_url(urlname)))
158
file.write('<img src="%s" alt="" /> ' % get_icon_url(urlname))
179
159
file.write('<a href="%s">%s</a></li>\n'
180
% (cgi.escape(util.make_path(urlname)), cgi.escape(app.name)))
160
% (util.make_path(urlname), app.name))
182
162
file.write(' </ul>\n')