1
# IVLE - Informatics Virtual Learning Environment
2
# Copyright (C) 2007-2008 The University of Melbourne
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
# Module: dispatch.html
22
# Provides functions for writing the dispatch-generated HTML header and footer
23
# content (the common parts of the HTML pages shared across the entire site).
24
# Does not include the login page. See login.py.
31
def write_html_head(req):
32
"""Writes the HTML header, given a request object.
34
req: An IVLE request object. Reads attributes such as title. Also used to
37
# Write the XHTML opening and head element
38
# Note the inline JavaScript, which provides the client with constants
39
# derived from the server configuration.
41
titlepart = req.title + ' - '
44
req.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
45
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
46
<html xmlns="http://www.w3.org/1999/xhtml">
49
<meta http-equiv="Content-Type" content="%s; charset=utf-8" />
50
""" % (cgi.escape(titlepart), cgi.escape(req.content_type)))
52
req.write(""" <link rel="stylesheet" type="text/css" href="%s" />
53
""" % cgi.escape(util.make_path('+media/ivle.webapp.core/ivle.css')))
55
req.write("</head>\n\n")
57
# Open the body element and write a bunch of stuff there (the header)
59
<div id="ivleheader"></div>
60
<div id="ivleheader_text">
62
<h2>Informatics Virtual Learning Environment</h2>
66
req.write(' <p class="userhello">Running in public mode.</p>')
68
# Get the user's nickname from the request session
69
nickname = req.user.nick
70
req.write(' <p class="userhello"><span id="usernick">%s</span> '
71
'(<span class="username">%s</span>) |\n'
72
' <a href="%s">Settings</a> |\n'
73
' <a href="%s">Help</a> |\n'
74
' <a href="%s">Sign out</a>\n'
76
(cgi.escape(nickname), cgi.escape(req.user.login),
77
cgi.escape(util.make_path(
78
os.path.join('~' + req.user.login, '+settings'))),
79
cgi.escape(util.make_path('+help')),
80
cgi.escape(util.make_path('+logout'))))
82
req.write(' <p class="userhello">Not logged in.</p>')
84
req.write('</div>\n<div id="ivleheader_tabs">\n')
85
req.write('</div>\n<div id="ivlebody">\n')
87
def write_html_foot(req):
88
"""Writes the HTML footer, given a request object.
90
req: An IVLE request object. Written to.
92
req.write("</div>\n</body>\n</html>\n")