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

« back to all changes in this revision

Viewing changes to www/dispatch/html.py

  • Committer: wagrant
  • Date: 2008-07-22 05:21:38 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:933
dispatch: If running in public mode, say so instead of advising that
          we're not logged in.

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.
58
60
        username = "null"
59
61
    req.write("""  <script type="text/javascript">
60
62
    root_dir = %s;
 
63
    public_host = %s;
61
64
    username = %s;
62
65
  </script>
63
 
""" % (repr(conf.root_dir), username))
 
66
""" % (repr(conf.root_dir), repr(conf.public_host), username))
64
67
    iconurl = get_icon_url(req.app, small=True)
65
68
    if iconurl:
66
69
        req.write("""  <link rel="shortcut icon" href="%s" />
75
78
    for script in req.scripts:
76
79
        req.write('  <script type="text/javascript" src="%s"></script>\n'
77
80
            % cgi.escape(util.make_path(script)))
 
81
    req.write('  <script type="text/javascript">\n    /* Init Functions */\n')
 
82
    for init in req.scripts_init:
 
83
        req.write('    window.addEventListener("load", %s, false);\n'%init)
 
84
    req.write('  </script>\n')
78
85
 
79
86
    req.write("</head>\n\n")
80
87
 
86
93
  <h2>Informatics Virtual Learning Environment</h2>
87
94
""")
88
95
 
89
 
    if req.user:
 
96
    if req.publicmode:
 
97
        req.write('   <p class="userhello">Running in public mode.</p>')
 
98
    elif req.user:
90
99
        # Get the user's nickname from the request session
91
100
        nickname = req.user.nick
92
 
        req.write('  <p class="userhello">%s (<span '
93
 
            'class="username">%s</span>) |\n'
 
101
        req.write('  <p class="userhello"><span id="usernick">%s</span> '
 
102
            '(<span class="username">%s</span>) |\n'
94
103
            '    <a href="%s">Settings</a> |\n'
95
104
            '    <a href="%s">Help</a> |\n'
96
105
            '    <a href="%s">Sign out</a>\n'
108
117
    # If the "debuginfo" app is installed, display a warning to the admin to
109
118
    # make sure it is removed in production.
110
119
    if "debuginfo" in conf.apps.app_url:
111
 
        req.write("  <p><small>Warning: debuginfo is enabled. Remove this "
112
 
            "app from conf.apps.app_url when placed into production."
113
 
            "</small></p>\n")
 
120
        req.write("  <p><small>Warning: debuginfo is enabled. Set "
 
121
            "enable_debuginfo = False in lib/conf/apps.py, when placing IVLE "
 
122
            "into production.</small></p>\n")
114
123
 
115
124
    # If req has a "no_agreement" attribute, then it is because the user has
116
125
    # not signed the agreement; therefore we are displaying the TOS page.
135
144
        # We're already in help. Link to the exact current page
136
145
        # instead of the generic help page.
137
146
        return req.uri
138
 
    if reqapp is not None and conf.apps.app_url[reqapp].hashelp:
 
147
    if reqapp is not None and reqapp in conf.apps.app_url and \
 
148
        conf.apps.app_url[reqapp].hashelp:
139
149
        help_path = os.path.join('help', reqapp)
140
150
    else:
141
151
        help_path = 'help'
175
185
        file.write('    <li%s>' % li_attr)
176
186
        if app.icon:
177
187
            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)))
 
188
                % urllib.quote(get_icon_url(urlname)))
 
189
        file.write('<a href="%s" title="%s">%s</a></li>\n'
 
190
            % (urllib.quote(util.make_path(urlname)), cgi.escape(app.desc),
 
191
                cgi.escape(app.name)))
181
192
 
182
193
    file.write('  </ul>\n')