~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 11:48:06 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:192
dispatch.html: Only prints tabs if logged in.
    Changed "Welcome" section to include a "Help" link. This links to the
    most relevant help file to the current page (or if there is none, links
    back to the main Help page).

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
# content (the common parts of the HTML pages shared across the entire site).
24
24
# Does not include the login page. See login.py.
25
25
 
 
26
import os.path
 
27
 
26
28
import conf
27
29
import conf.apps
28
30
from common import util
72
74
 
73
75
    if req.username:
74
76
        req.write('  <p class="userhello">Welcome, <span '
75
 
            'class="username">%s</span>. '
76
 
            '<a href="%s">Logout</a>.</p>\n' %
77
 
            (req.username, util.make_path('logout')))
 
77
            'class="username">%s</span> |\n'
 
78
            '    <a href="%s">Help</a> |\n'
 
79
            '    <a href="%s">Logout</a>\n'
 
80
            '  </p>\n' %
 
81
            (req.username, get_help_url(req), util.make_path('logout')))
78
82
    else:
79
83
        req.write('  <p class="userhello">Not logged in.</p>')
80
84
 
85
89
            "app from conf.apps.app_url when placed into production."
86
90
            "</small></p>\n")
87
91
 
88
 
    print_apps_list(req, req.app)
 
92
    if req.username:
 
93
        # Only print app tabs if logged in
 
94
        print_apps_list(req, req.app)
89
95
    req.write('</div>\n<div id="ivlebody">\n')
90
96
 
91
97
def write_html_foot(req):
95
101
    """
96
102
    req.write("</div>\n</body>\n</html>\n")
97
103
 
 
104
def get_help_url(req):
 
105
    """Gets the help URL most relevant to this page, to place as the
 
106
    "help" link at the top of the page."""
 
107
    if req.app == 'help':
 
108
        # We're already in help. Link to the exact current page
 
109
        # instead of the generic help page.
 
110
        return req.uri
 
111
    if conf.apps.app_url[req.app].hashelp:
 
112
        help_path = os.path.join('help', req.app)
 
113
    else:
 
114
        help_path = 'help'
 
115
    return util.make_path(help_path)
 
116
 
98
117
def print_apps_list(file, thisapp):
99
118
    """Prints all app tabs, as a UL. Prints a list item for each app that has
100
119
    a tab.