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

« back to all changes in this revision

Viewing changes to www/dispatch/html.py

  • Committer: matt.giuca
  • Date: 2009-01-12 00:33:53 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1072
Renamed scripts to services.
Updated all references (we hope). :)

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
27
28
import os.path
28
29
 
29
30
import conf
30
31
import conf.apps
31
32
from common import util
 
33
import plugins.console
32
34
 
33
35
def write_html_head(req):
34
36
    """Writes the HTML header, given a request object.
56
58
        username = repr(req.user.login)
57
59
    else:
58
60
        username = "null"
59
 
    req.write("""  <script type="text/javascript">
 
61
    if req.write_javascript_settings:
 
62
        req.write("""  <script type="text/javascript">
60
63
    root_dir = %s;
 
64
    public_host = %s;
61
65
    username = %s;
62
66
  </script>
63
 
""" % (repr(conf.root_dir), username))
 
67
""" % (repr(conf.root_dir), repr(conf.public_host), username))
64
68
    iconurl = get_icon_url(req.app, small=True)
65
69
    if iconurl:
66
70
        req.write("""  <link rel="shortcut icon" href="%s" />
75
79
    for script in req.scripts:
76
80
        req.write('  <script type="text/javascript" src="%s"></script>\n'
77
81
            % cgi.escape(util.make_path(script)))
 
82
    if len(req.scripts_init) > 0:
 
83
        req.write('  <script type="text/javascript">\n    /* Init Functions */\n')
 
84
        for init in req.scripts_init:
 
85
            req.write('    window.addEventListener("load", %s, false);\n'%init)
 
86
        req.write('  </script>\n')
78
87
 
79
88
    req.write("</head>\n\n")
80
89
 
86
95
  <h2>Informatics Virtual Learning Environment</h2>
87
96
""")
88
97
 
89
 
    if req.user:
 
98
    if req.publicmode:
 
99
        req.write('   <p class="userhello">Running in public mode.</p>')
 
100
    elif req.user:
90
101
        # Get the user's nickname from the request session
91
102
        nickname = req.user.nick
92
 
        req.write('  <p class="userhello">%s (<span '
93
 
            'class="username">%s</span>) |\n'
 
103
        req.write('  <p class="userhello"><span id="usernick">%s</span> '
 
104
            '(<span class="username">%s</span>) |\n'
94
105
            '    <a href="%s">Settings</a> |\n'
95
106
            '    <a href="%s">Help</a> |\n'
96
107
            '    <a href="%s">Sign out</a>\n'
135
146
        # We're already in help. Link to the exact current page
136
147
        # instead of the generic help page.
137
148
        return req.uri
138
 
    if reqapp is not None and conf.apps.app_url[reqapp].hashelp:
 
149
    if reqapp is not None and reqapp in conf.apps.app_url and \
 
150
        conf.apps.app_url[reqapp].hashelp:
139
151
        help_path = os.path.join('help', reqapp)
140
152
    else:
141
153
        help_path = 'help'
175
187
        file.write('    <li%s>' % li_attr)
176
188
        if app.icon:
177
189
            file.write('<img src="%s" alt="" /> '
178
 
                % cgi.escape(get_icon_url(urlname)))
179
 
        file.write('<a href="%s">%s</a></li>\n'
180
 
            % (cgi.escape(util.make_path(urlname)), cgi.escape(app.name)))
 
190
                % urllib.quote(get_icon_url(urlname)))
 
191
        file.write('<a href="%s" title="%s">%s</a></li>\n'
 
192
            % (urllib.quote(util.make_path(urlname)), cgi.escape(app.desc),
 
193
                cgi.escape(app.name)))
181
194
 
182
195
    file.write('  </ul>\n')