93
by mattgiuca
New directory hierarchy. |
1 |
# IVLE
|
2 |
# Copyright (C) 2007-2008 The University of Melbourne
|
|
3 |
#
|
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
16 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17 |
||
18 |
# App: help
|
|
19 |
# Author: Matt Giuca
|
|
20 |
# Date: 12/12/2007
|
|
21 |
||
22 |
# This is an IVLE application.
|
|
23 |
# A sample / testing application for IVLE.
|
|
24 |
||
25 |
import os |
|
458
by mattgiuca
Added "tos" as an app. This app simply displays the Terms of Service |
26 |
import copy |
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
27 |
|
28 |
from ivle import util |
|
29 |
import ivle.conf |
|
93
by mattgiuca
New directory hierarchy. |
30 |
|
1093
by chadnickbok
Adding the changes from my genshi branch into trunk. |
31 |
import genshi |
32 |
import genshi.template |
|
33 |
||
93
by mattgiuca
New directory hierarchy. |
34 |
# TODO: Nicer 404 errors
|
35 |
||
36 |
def handle(req): |
|
37 |
"""Handler for the Help application."""
|
|
38 |
(appurl, subpath) = util.split_path(req.path) |
|
39 |
||
40 |
if appurl is None: |
|
41 |
show_help_menu(req) |
|
42 |
else: |
|
43 |
# app must be valid and have help available
|
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
44 |
if appurl not in ivle.conf.apps.app_url: |
93
by mattgiuca
New directory hierarchy. |
45 |
req.throw_error(req.HTTP_NOT_FOUND) |
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
46 |
app = ivle.conf.apps.app_url[appurl] |
93
by mattgiuca
New directory hierarchy. |
47 |
if not app.hashelp: |
48 |
req.throw_error(req.HTTP_NOT_FOUND) |
|
49 |
# subpath must be empty, for now, as there is only one help file per app
|
|
50 |
if subpath != "": |
|
51 |
req.throw_error(req.HTTP_NOT_FOUND) |
|
52 |
show_help_app(req, app) |
|
53 |
||
54 |
def show_help_menu(req): |
|
55 |
"""Show the help menu."""
|
|
56 |
# Set request attributes
|
|
57 |
req.content_type = "text/html" |
|
58 |
req.write_html_head_foot = True |
|
59 |
||
1093
by chadnickbok
Adding the changes from my genshi branch into trunk. |
60 |
ctx = genshi.template.Context() |
93
by mattgiuca
New directory hierarchy. |
61 |
|
62 |
# Write a list of links to all apps with help modules
|
|
1093
by chadnickbok
Adding the changes from my genshi branch into trunk. |
63 |
ctx['apps'] = [] |
458
by mattgiuca
Added "tos" as an app. This app simply displays the Terms of Service |
64 |
# Tab apps, in order of tabs
|
1079
by William Grant
Merge setup-refactor branch. This completely breaks existing installations; |
65 |
for appurl in ivle.conf.apps.apps_in_tabs: |
66 |
app = ivle.conf.apps.app_url[appurl] |
|
93
by mattgiuca
New directory hierarchy. |
67 |
if app.hashelp: |
1093
by chadnickbok
Adding the changes from my genshi branch into trunk. |
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) |
|
458
by mattgiuca
Added "tos" as an app. This app simply displays the Terms of Service |
72 |
# Terms of Service
|
1093
by chadnickbok
Adding the changes from my genshi branch into trunk. |
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')) |
|
93
by mattgiuca
New directory hierarchy. |
78 |
|
79 |
def show_help_app(req, app): |
|
80 |
"""Show help for an application."""
|
|
81 |
helpfile = os.path.join(util.make_local_path("apps"), app.dir, "help.html") |
|
82 |
||
83 |
# Set request attributes
|
|
84 |
req.content_type = "text/html" |
|
85 |
req.write_html_head_foot = True |
|
731
by dcoles
Help: Wrote a small help document for the console app. Now one less glaring |
86 |
req.styles = ["media/help/help.css"] |
93
by mattgiuca
New directory hierarchy. |
87 |
|
88 |
# Start writing data
|
|
345
by mattgiuca
Global CSS change: ivlebody no longer has 1em of padding (it has none). |
89 |
req.write('<div id="ivle_padding">\n') |
93
by mattgiuca
New directory hierarchy. |
90 |
req.write("<h1>Help - %s</h1>\n" % app.name) |
91 |
||
92 |
# Print out the contents of the HTML help file
|
|
93 |
req.sendfile(helpfile) |
|
345
by mattgiuca
Global CSS change: ivlebody no longer has 1em of padding (it has none). |
94 |
req.write('</div>\n') |