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

« back to all changes in this revision

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

  • Committer: Nick Chadwick
  • Date: 2009-02-25 16:39:59 UTC
  • mto: (1099.1.227 exercise-ui)
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090225163959-3hsedlesu2pjm12e
Added a few extra files. I'm not sure if they're necessary, and I don't
have time to find out.

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