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

« back to all changes in this revision

Viewing changes to www/dispatch/html.py

  • Committer: mattgiuca
  • Date: 2008-01-12 11:27:34 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:191
dispatch.html, ivle.css, browser.css: Major restyling of the IVLE website.
    The header section is condensed, tabs display properly, introduced colour,
    everything goes all the way to the edge.

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 conf
 
27
import conf.apps
 
28
from common import util
 
29
 
 
30
def write_html_head(req):
 
31
    """Writes the HTML header, given a request object.
 
32
 
 
33
    req: An IVLE request object. Reads attributes such as title. Also used to
 
34
    write to."""
 
35
 
 
36
    # Write the XHTML opening and head element
 
37
    # Note the inline JavaScript, which provides the client with constants
 
38
    # derived from the server configuration.
 
39
    if req.title != None:
 
40
        titlepart = ' - ' + req.title
 
41
    else:
 
42
        titlepart = ''
 
43
    req.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 
44
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
45
<html xmlns="http://www.w3.org/1999/xhtml">
 
46
<head>
 
47
  <title>IVLE%s</title>
 
48
  <meta http-equiv="Content-Type" content="%s; charset=utf-8" />
 
49
  <script type="text/javascript">
 
50
    root_dir = "%s";
 
51
  </script>
 
52
  <link rel="stylesheet" type="text/css" href="%s" />
 
53
""" % (titlepart, req.content_type,
 
54
        repr(conf.root_dir)[1:-1],
 
55
        util.make_path('media/common/ivle.css')))
 
56
 
 
57
    # Write any app-specific style and script links
 
58
    for style in req.styles:
 
59
        req.write('  <link rel="stylesheet" type="text/css" href="%s" />\n'
 
60
            % util.make_path(style))
 
61
    for script in req.scripts:
 
62
        req.write('  <script type="text/javascript" src="%s" />\n'
 
63
            % util.make_path(script))
 
64
 
 
65
    req.write("</head>\n\n")
 
66
 
 
67
    # Open the body element and write a bunch of stuff there (the header)
 
68
    req.write("""<body>
 
69
<div id="ivleheader">
 
70
  <h1>IVLE - Informatics Virtual Learning Environment</h1>
 
71
""")
 
72
 
 
73
    if req.username:
 
74
        req.write('  <p class="userhello">Welcome, <span '
 
75
            'class="username">%s</span>. '
 
76
            '<a href="%s">Logout</a>.</p>\n' %
 
77
            (req.username, util.make_path('logout')))
 
78
    else:
 
79
        req.write('  <p class="userhello">Not logged in.</p>')
 
80
 
 
81
    # If the "debuginfo" app is installed, display a warning to the admin to
 
82
    # make sure it is removed in production.
 
83
    if "debuginfo" in conf.apps.app_url:
 
84
        req.write("  <p><small>Warning: debuginfo is enabled. Remove this "
 
85
            "app from conf.apps.app_url when placed into production."
 
86
            "</small></p>\n")
 
87
 
 
88
    print_apps_list(req, req.app)
 
89
    req.write('</div>\n<div id="ivlebody">\n')
 
90
 
 
91
def write_html_foot(req):
 
92
    """Writes the HTML footer, given a request object.
 
93
 
 
94
    req: An IVLE request object. Written to.
 
95
    """
 
96
    req.write("</div>\n</body>\n</html>\n")
 
97
 
 
98
def print_apps_list(file, thisapp):
 
99
    """Prints all app tabs, as a UL. Prints a list item for each app that has
 
100
    a tab.
 
101
 
 
102
    file: Object with a "write" method - ie. the request object.
 
103
    Reads from: conf
 
104
    """
 
105
    file.write('  <ul class="apptabs">\n')
 
106
 
 
107
    for urlname in conf.apps.apps_in_tabs:
 
108
        app = conf.apps.app_url[urlname]
 
109
        if urlname == thisapp:
 
110
            li_attr = ' class="thisapp"'
 
111
        else:
 
112
            li_attr = ''
 
113
        file.write('    <li%s><a href="%s">%s</a></li>\n'
 
114
            % (li_attr, util.make_path(urlname), app.name))
 
115
 
 
116
    file.write('  </ul>\n')