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

« back to all changes in this revision

Viewing changes to ivle/webapp/base/xhtml.py

  • Committer: William Grant
  • Date: 2009-05-26 03:06:53 UTC
  • Revision ID: grantw@unimelb.edu.au-20090526030653-axxawt0o5ws4icbt
Remove ivle.conf usage from ivle.studpath.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from ivle.webapp.base.views import BaseView
29
29
from ivle.webapp.base.plugins import ViewPlugin, OverlayPlugin
30
30
from ivle.webapp.errors import HTTPError, Unauthorized
31
 
import ivle.conf
32
 
import ivle.util
33
31
 
34
32
class XHTMLView(BaseView):
35
33
    """
48
46
        for key in kwargs:
49
47
            setattr(self, key, kwargs[key])
50
48
 
 
49
    def filter(self, stream, ctx):
 
50
        return stream
 
51
 
51
52
    def render(self, req):
52
53
        req.content_type = 'text/html' # TODO: Detect application/xhtml+xml
53
54
 
61
62
                        inspect.getmodule(self).__file__), self.template) 
62
63
        loader = genshi.template.TemplateLoader(".", auto_reload=True)
63
64
        tmpl = loader.load(app_template)
64
 
        app = tmpl.generate(viewctx)
 
65
        app = self.filter(tmpl.generate(viewctx), viewctx)
65
66
 
66
67
        for plugin in self.plugin_scripts:
67
68
            for path in self.plugin_scripts[plugin]:
81
82
 
82
83
        ctx['scripts'] = [media_url(req, CorePlugin, path) for path in
83
84
                           ('util.js', 'json2.js', 'md5.js')]
 
85
        ctx['scripts'].append(media_url(req, '+external/jquery', 'jquery.js'))
84
86
        ctx['scripts'] += req.scripts
85
87
 
86
88
        ctx['scripts_init'] = req.scripts_init
87
89
        ctx['app_template'] = app
 
90
        ctx['title_img'] = media_url(req, CorePlugin,
 
91
                                     "images/chrome/title.png")
88
92
        self.populate_headings(req, ctx)
89
93
        tmpl = loader.load(os.path.join(os.path.dirname(__file__), 
90
94
                                                        'ivle-headings.html'))
95
99
 
96
100
    def populate_headings(self, req, ctx):
97
101
        ctx['favicon'] = None
98
 
        ctx['root_dir'] = ivle.conf.root_dir
99
 
        ctx['public_host'] = ivle.conf.public_host
 
102
        ctx['root_dir'] = req.config['urls']['root']
 
103
        ctx['public_host'] = req.config['urls']['public_host']
 
104
        ctx['svn_base'] = req.config['urls']['svn_addr']
100
105
        ctx['write_javascript_settings'] = req.write_javascript_settings
101
106
        if req.user:
102
107
            ctx['login'] = req.user.login
117
122
            for tab in plugin.tabs:
118
123
                # tab is a tuple: name, title, desc, icon, path
119
124
                new_app = {}
120
 
                new_app['this_app'] = hasattr(self, 'appname') \
121
 
                                      and tab[0] == self.appname
 
125
                new_app['this_app'] = hasattr(self, 'tab') \
 
126
                                      and tab[0] == self.tab
122
127
 
123
128
                # Icon name
124
129
                if tab[3] is not None:
129
134
                        ctx['favicon'] = icon_url
130
135
                else:
131
136
                    new_app['has_icon'] = False
132
 
                new_app['path'] = ivle.util.make_path(tab[4])
 
137
                new_app['path'] = req.make_path(tab[4])
133
138
                new_app['desc'] = tab[2]
134
139
                new_app['name'] = tab[1]
135
140
                new_app['weight'] = tab[5]