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

« back to all changes in this revision

Viewing changes to www/dispatch/html.py

  • Committer: mattgiuca
  • Date: 2008-02-25 01:17:22 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:560
settings: Python code generates all of the HTML for the static page.
The JavaScript makes a call to get the data but doesn't yet populate the page.

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
31
30
import conf.apps
32
31
from common import util
33
 
import plugins.console
34
32
 
35
33
def write_html_head(req):
36
34
    """Writes the HTML header, given a request object.
58
56
        username = repr(req.user.login)
59
57
    else:
60
58
        username = "null"
61
 
    if req.write_javascript_settings:
62
 
        req.write("""  <script type="text/javascript">
 
59
    req.write("""  <script type="text/javascript">
63
60
    root_dir = %s;
64
 
    public_host = %s;
65
61
    username = %s;
66
62
  </script>
67
 
""" % (repr(conf.root_dir), repr(conf.public_host), username))
 
63
""" % (repr(conf.root_dir), username))
68
64
    iconurl = get_icon_url(req.app, small=True)
69
65
    if iconurl:
70
66
        req.write("""  <link rel="shortcut icon" href="%s" />
79
75
    for script in req.scripts:
80
76
        req.write('  <script type="text/javascript" src="%s"></script>\n'
81
77
            % 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')
87
78
 
88
79
    req.write("</head>\n\n")
89
80
 
95
86
  <h2>Informatics Virtual Learning Environment</h2>
96
87
""")
97
88
 
98
 
    if req.publicmode:
99
 
        req.write('   <p class="userhello">Running in public mode.</p>')
100
 
    elif req.user:
 
89
    if req.user:
101
90
        # Get the user's nickname from the request session
102
91
        nickname = req.user.nick
103
 
        req.write('  <p class="userhello"><span id="usernick">%s</span> '
104
 
            '(<span class="username">%s</span>) |\n'
 
92
        req.write('  <p class="userhello">%s (<span '
 
93
            'class="username">%s</span>) |\n'
105
94
            '    <a href="%s">Settings</a> |\n'
106
95
            '    <a href="%s">Help</a> |\n'
107
96
            '    <a href="%s">Sign out</a>\n'
119
108
    # If the "debuginfo" app is installed, display a warning to the admin to
120
109
    # make sure it is removed in production.
121
110
    if "debuginfo" in conf.apps.app_url:
122
 
        req.write("  <p><small>Warning: debuginfo is enabled. Set "
123
 
            "enable_debuginfo = False in lib/conf/apps.py, when placing IVLE "
124
 
            "into production.</small></p>\n")
 
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")
125
114
 
126
115
    # If req has a "no_agreement" attribute, then it is because the user has
127
116
    # not signed the agreement; therefore we are displaying the TOS page.
146
135
        # We're already in help. Link to the exact current page
147
136
        # instead of the generic help page.
148
137
        return req.uri
149
 
    if reqapp is not None and reqapp in conf.apps.app_url and \
150
 
        conf.apps.app_url[reqapp].hashelp:
 
138
    if reqapp is not None and conf.apps.app_url[reqapp].hashelp:
151
139
        help_path = os.path.join('help', reqapp)
152
140
    else:
153
141
        help_path = 'help'
187
175
        file.write('    <li%s>' % li_attr)
188
176
        if app.icon:
189
177
            file.write('<img src="%s" alt="" /> '
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)))
 
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)))
194
181
 
195
182
    file.write('  </ul>\n')