~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/dispatch/html.py

Drop serve, download from ivle.conf.apps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# IVLE - Informatics Virtual Learning Environment
 
2
# Copyright (C) 2007-2008 The University of Melbourne
 
3
#
 
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.
 
8
#
 
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.
 
13
#
 
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
 
17
 
 
18
# Module: dispatch.html
 
19
# Author: Matt Giuca
 
20
# Date: 12/12/2007
 
21
 
 
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.
 
25
 
 
26
import cgi
 
27
import os.path
 
28
 
 
29
from ivle import util
 
30
 
 
31
def write_html_head(req):
 
32
    """Writes the HTML header, given a request object.
 
33
 
 
34
    req: An IVLE request object. Reads attributes such as title. Also used to
 
35
    write to."""
 
36
 
 
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.
 
40
    if req.title != None:
 
41
        titlepart = req.title + ' - '
 
42
    else:
 
43
        titlepart = ''
 
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">
 
47
<head>
 
48
  <title>%sIVLE</title>
 
49
  <meta http-equiv="Content-Type" content="%s; charset=utf-8" />
 
50
""" % (cgi.escape(titlepart), cgi.escape(req.content_type)))
 
51
 
 
52
    req.write("""  <link rel="stylesheet" type="text/css" href="%s" />
 
53
""" % cgi.escape(util.make_path('media/common/ivle.css')))
 
54
 
 
55
    req.write("</head>\n\n")
 
56
 
 
57
    # Open the body element and write a bunch of stuff there (the header)
 
58
    req.write("""<body>
 
59
<div id="ivleheader"></div>
 
60
<div id="ivleheader_text">
 
61
  <h1>IVLE</h1>
 
62
  <h2>Informatics Virtual Learning Environment</h2>
 
63
""")
 
64
 
 
65
    if req.publicmode:
 
66
        req.write('   <p class="userhello">Running in public mode.</p>')
 
67
    elif req.user:
 
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'
 
75
            '  </p>\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'))))
 
81
    else:
 
82
        req.write('  <p class="userhello">Not logged in.</p>')
 
83
 
 
84
    req.write('</div>\n<div id="ivleheader_tabs">\n')
 
85
    req.write('</div>\n<div id="ivlebody">\n')
 
86
 
 
87
def write_html_foot(req):
 
88
    """Writes the HTML footer, given a request object.
 
89
 
 
90
    req: An IVLE request object. Written to.
 
91
    """
 
92
    req.write("</div>\n</body>\n</html>\n")