~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 13:58:53 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:199
Added small versions of all the app icons to images. These are used for
browser favicons.
conf/apps.py: Added new constant app_icon_dir_small.
dispatch.html: HTML now has a link to the favicon, the small version of the
    icon (for display in browser tab/address bar).
    Also rearranged the order of title, "IVLE - <app>" is now "<app> - IVLE".

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    req: An IVLE request object. Reads attributes such as title. Also used to
36
36
    write to."""
37
37
 
 
38
    app = conf.apps.app_url[req.app]
38
39
    # Write the XHTML opening and head element
39
40
    # Note the inline JavaScript, which provides the client with constants
40
41
    # derived from the server configuration.
41
42
    if req.title != None:
42
 
        titlepart = ' - ' + req.title
 
43
        titlepart = req.title + ' - '
43
44
    else:
44
45
        titlepart = ''
45
46
    req.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
46
47
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
47
48
<html xmlns="http://www.w3.org/1999/xhtml">
48
49
<head>
49
 
  <title>IVLE%s</title>
 
50
  <title>%sIVLE</title>
50
51
  <meta http-equiv="Content-Type" content="%s; charset=utf-8" />
51
52
  <script type="text/javascript">
52
53
    root_dir = "%s";
53
54
  </script>
54
 
  <link rel="stylesheet" type="text/css" href="%s" />
55
55
""" % (titlepart, req.content_type,
56
 
        repr(conf.root_dir)[1:-1],
57
 
        util.make_path('media/common/ivle.css')))
 
56
        repr(conf.root_dir)[1:-1]))
 
57
    iconurl = get_icon_url(conf.apps.app_url[req.app])
 
58
    if iconurl:
 
59
        req.write("""  <link rel="shortcut icon" href="%s" />
 
60
""" % iconurl)
 
61
    req.write("""  <link rel="stylesheet" type="text/css" href="%s" />
 
62
""" % util.make_path('media/common/ivle.css'))
58
63
 
59
64
    # Write any app-specific style and script links
60
65
    for style in req.styles:
115
120
        help_path = 'help'
116
121
    return util.make_path(help_path)
117
122
 
 
123
def get_icon_url(app, small=False):
 
124
    """Given an App object, gets the URL of the icon image for this app,
 
125
    relative to the site root. Returns None if the app has no icon."""
 
126
    if small:
 
127
        icon_dir = conf.apps.app_icon_dir_small
 
128
    else:
 
129
        icon_dir = conf.apps.app_icon_dir
 
130
    if app.icon is None: return None
 
131
    return util.make_path(os.path.join(icon_dir, app.icon))
 
132
 
118
133
def print_apps_list(file, thisapp):
119
134
    """Prints all app tabs, as a UL. Prints a list item for each app that has
120
135
    a tab.
132
147
            li_attr = ''
133
148
        file.write('    <li%s>' % li_attr)
134
149
        if app.icon:
135
 
            file.write('<img src="%s" alt="" /> ' %
136
 
                util.make_path(os.path.join(conf.apps.app_icon_dir,
137
 
                app.icon)))
 
150
            file.write('<img src="%s" alt="" /> ' % get_icon_url(app))
138
151
        file.write('<a href="%s">%s</a></li>\n'
139
152
            % (util.make_path(urlname), app.name))
140
153