~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-31 01:44:30 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:345
Global CSS change: ivlebody no longer has 1em of padding (it has none).
This is because most apps were disabling it (and it had to change anyway for
other reasons -- see below).

Hence, all apps which WERE disabling the padding have had that removed, and
just work by default. (console, browser, tutorial)
All apps which WEREN'T disabling the padding (very few) now have to manually
include an extra div. This has been done on all such apps, and has been
heavily documented (both in the CSS file and doc/app_howto). (help, dummy,
debuginfo).

media/common/ivle.css: 
    The real change here (which isn't yet being used) is that ivlebody is now
    positioned absolutely and takes up all the space on the canvas. This is
    to be used for full-page layouts in console and browser.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
# Does not include the login page. See login.py.
25
25
 
26
26
import cgi
27
 
import urllib
28
27
import os.path
29
28
 
30
29
import conf
53
52
""" % (cgi.escape(titlepart), cgi.escape(req.content_type)))
54
53
    # Write inline JavaScript which gives the client code access to certain
55
54
    # server-side variables.
56
 
    if req.user:
57
 
        username = repr(req.user.login)
 
55
    if req.username:
 
56
        username = repr(req.username)
58
57
    else:
59
58
        username = "null"
60
59
    req.write("""  <script type="text/javascript">
62
61
    username = %s;
63
62
  </script>
64
63
""" % (repr(conf.root_dir), username))
65
 
    iconurl = get_icon_url(req.app, small=True)
 
64
    iconurl = get_icon_url(req.app)
66
65
    if iconurl:
67
66
        req.write("""  <link rel="shortcut icon" href="%s" />
68
67
""" % cgi.escape(iconurl))
74
73
        req.write('  <link rel="stylesheet" type="text/css" href="%s" />\n'
75
74
            % cgi.escape(util.make_path(style)))
76
75
    for script in req.scripts:
77
 
        req.write('  <script type="text/javascript" src="%s"></script>\n'
 
76
        req.write('  <script type="text/javascript" src="%s" />\n'
78
77
            % cgi.escape(util.make_path(script)))
79
78
 
80
79
    req.write("</head>\n\n")
81
80
 
82
81
    # Open the body element and write a bunch of stuff there (the header)
83
82
    req.write("""<body>
84
 
<div id="ivleheader"></div>
85
 
<div id="ivleheader_text">
 
83
<div id="ivleheader">
86
84
  <h1>IVLE</h1>
87
85
  <h2>Informatics Virtual Learning Environment</h2>
88
86
""")
89
87
 
90
 
    if req.user:
91
 
        # Get the user's nickname from the request session
92
 
        nickname = req.user.nick
93
 
        req.write('  <p class="userhello"><span id="usernick">%s</span> '
94
 
            '(<span class="username">%s</span>) |\n'
95
 
            '    <a href="%s">Settings</a> |\n'
 
88
    if req.username:
 
89
        req.write('  <p class="userhello">Welcome, <span '
 
90
            'class="username">%s</span> |\n'
96
91
            '    <a href="%s">Help</a> |\n'
97
 
            '    <a href="%s">Sign out</a>\n'
 
92
            '    <a href="%s">Logout</a>\n'
98
93
            '  </p>\n' %
99
 
            (cgi.escape(nickname), cgi.escape(req.user.login),
100
 
             cgi.escape(util.make_path('settings')),
 
94
            (cgi.escape(req.username),
101
95
             cgi.escape(get_help_url(req)),
102
96
             cgi.escape(util.make_path('logout'))))
103
97
    else:
104
98
        req.write('  <p class="userhello">Not logged in.</p>')
105
99
 
106
 
    # ivleheader_tabs is a separate div, so it can be positioned absolutely
107
 
    req.write('</div>\n<div id="ivleheader_tabs">\n')
108
 
 
109
100
    # If the "debuginfo" app is installed, display a warning to the admin to
110
101
    # make sure it is removed in production.
111
102
    if "debuginfo" in conf.apps.app_url:
112
 
        req.write("  <p><small>Warning: debuginfo is enabled. Set "
113
 
            "enable_debuginfo = False in lib/conf/apps.py, when placing IVLE "
114
 
            "into production.</small></p>\n")
 
103
        req.write("  <p><small>Warning: debuginfo is enabled. Remove this "
 
104
            "app from conf.apps.app_url when placed into production."
 
105
            "</small></p>\n")
 
106
    # ivleheader_tabs is a separate div, so it can be positioned absolutely
 
107
    req.write('</div>\n<div id="ivleheader_tabs">\n')
115
108
 
116
 
    # If req has a "no_agreement" attribute, then it is because the user has
117
 
    # not signed the agreement; therefore we are displaying the TOS page.
118
 
    # Do not show apps (see dispatch.login).
119
 
    if req.user and not req.user.state == 'no_agreement':
 
109
    if req.username:
120
110
        # Only print app tabs if logged in
121
111
        print_apps_list(req, req.app)
122
112
    req.write('</div>\n<div id="ivlebody">\n')
131
121
def get_help_url(req):
132
122
    """Gets the help URL most relevant to this page, to place as the
133
123
    "help" link at the top of the page."""
134
 
    reqapp = req.app if hasattr(req, 'app') else None
135
 
    if reqapp == 'help':
 
124
    if req.app == 'help':
136
125
        # We're already in help. Link to the exact current page
137
126
        # instead of the generic help page.
138
127
        return req.uri
139
 
    if reqapp is not None and conf.apps.app_url[reqapp].hashelp:
140
 
        help_path = os.path.join('help', reqapp)
 
128
    if conf.apps.app_url[req.app].hashelp:
 
129
        help_path = os.path.join('help', req.app)
141
130
    else:
142
131
        help_path = 'help'
143
132
    return util.make_path(help_path)
146
135
    """Given an app's url name, gets the URL of the icon image for this app,
147
136
    relative to the site root. Returns None if the app has no icon."""
148
137
    if appurl is None: return None
149
 
    try:
150
 
        app = conf.apps.app_url[appurl]
151
 
    except KeyError:
152
 
        # Due to navigating to a bad app
153
 
        return None
 
138
    app = conf.apps.app_url[appurl]
154
139
    if small:
155
140
        icon_dir = conf.apps.app_icon_dir_small
156
141
    else:
176
161
        file.write('    <li%s>' % li_attr)
177
162
        if app.icon:
178
163
            file.write('<img src="%s" alt="" /> '
179
 
                % urllib.quote(get_icon_url(urlname)))
180
 
        file.write('<a href="%s" title="%s">%s</a></li>\n'
181
 
            % (urllib.quote(util.make_path(urlname)), cgi.escape(app.desc),
182
 
                cgi.escape(app.name)))
 
164
                % cgi.escape(get_icon_url(urlname)))
 
165
        file.write('<a href="%s">%s</a></li>\n'
 
166
            % (cgi.escape(util.make_path(urlname)), cgi.escape(app.name)))
183
167
 
184
168
    file.write('  </ul>\n')