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

« back to all changes in this revision

Viewing changes to www/apps/help/__init__.py

  • Committer: chadnickbok
  • Date: 2009-02-02 04:00:25 UTC
  • Revision ID: svn-v4:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1189
Adding the changes from my genshi branch into trunk.

Most apps now use the Genshi templating engine, in preparation
for future changes to dispatch

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from ivle import util
29
29
import ivle.conf
30
30
 
 
31
import genshi
 
32
import genshi.template
 
33
 
31
34
# TODO: Nicer 404 errors
32
35
 
33
36
def handle(req):
50
53
 
51
54
def show_help_menu(req):
52
55
    """Show the help menu."""
53
 
 
54
56
    # Set request attributes
55
57
    req.content_type = "text/html"
56
58
    req.write_html_head_foot = True
57
59
 
58
 
    # Start writing data
59
 
    req.write('<div id="ivle_padding">\n')
60
 
    req.write("<h1>Help</h1>\n")
 
60
    ctx = genshi.template.Context()
61
61
 
62
62
    # Write a list of links to all apps with help modules
63
 
    req.write("<ul>\n")
 
63
    ctx['apps'] = []
64
64
    # Tab apps, in order of tabs
65
65
    for appurl in ivle.conf.apps.apps_in_tabs:
66
66
        app = ivle.conf.apps.app_url[appurl]
67
67
        if app.hashelp:
68
 
            req.write('  <li><a href="%s">%s</a></li>\n'
69
 
                % (os.path.join(util.make_path("help"), appurl), app.name))
 
68
            new_app = {}
 
69
            new_app['appurl'] = os.path.join(util.make_path("help"), appurl)
 
70
            new_app['name'] = app.name
 
71
            ctx['apps'].append(new_app)
70
72
    # Terms of Service
71
 
    req.write('  <li><a href="%s">Terms of Service</a></li>\n'
72
 
        % (util.make_path("tos")))
73
 
    req.write("</ul>\n")
74
 
    req.write('</div>\n')
 
73
    ctx['tos'] = util.make_path("tos")
 
74
 
 
75
    loader = genshi.template.TemplateLoader(".", auto_reload=True)
 
76
    tmpl = loader.load(util.make_local_path("apps/help/template.html"))
 
77
    req.write(tmpl.generate(ctx).render('html')) #'xhtml', doctype='xhtml'))
75
78
 
76
79
def show_help_app(req, app):
77
80
    """Show help for an application."""