~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-03-26 12:15:37 UTC
  • mto: (1165.3.1 submissions)
  • mto: This revision was merged to the branch mainline in revision 1174.
  • Revision ID: grantw@unimelb.edu.au-20090326121537-e2r5pqr4kksnqeq5
Fix the SubmitView XHTML up a bit.

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
    """
37
39
    """
38
40
 
39
41
    template = 'template.html'
40
 
 
41
42
    plugin_scripts = {}
42
43
    plugin_styles = {}
43
 
    scripts_init = []
44
 
 
45
44
    allow_overlays = True
46
45
    overlay_blacklist = []
47
46
 
67
66
        tmpl = loader.load(app_template)
68
67
        app = self.filter(tmpl.generate(viewctx), viewctx)
69
68
 
70
 
        view_scripts = []
71
69
        for plugin in self.plugin_scripts:
72
70
            for path in self.plugin_scripts[plugin]:
73
 
                view_scripts.append(media_url(req, plugin, path))
 
71
                req.scripts.append(media_url(req, plugin, path))
74
72
 
75
 
        view_styles = []
76
73
        for plugin in self.plugin_styles:
77
74
            for path in self.plugin_styles[plugin]:
78
 
                view_styles.append(media_url(req, plugin, path))
 
75
                req.styles.append(media_url(req, plugin, path))
79
76
 
80
77
        # Global template
81
78
        ctx = genshi.template.Context()
82
 
 
83
 
        overlay_bits = self.render_overlays(req) if req.user else [[]]*4
84
 
        ctx['overlays'] = overlay_bits[0]
 
79
        # XXX: Leave this here!! (Before req.styles is read)
 
80
        ctx['overlays'] = self.render_overlays(req) if req.user else []
85
81
 
86
82
        ctx['styles'] = [media_url(req, CorePlugin, 'ivle.css')]
87
 
        ctx['styles'] += view_styles
88
 
        ctx['styles'] += overlay_bits[1]
 
83
        ctx['styles'] += req.styles
89
84
 
90
85
        ctx['scripts'] = [media_url(req, CorePlugin, path) for path in
91
86
                           ('util.js', 'json2.js', 'md5.js')]
92
87
        ctx['scripts'].append(media_url(req, '+external/jquery', 'jquery.js'))
93
 
        ctx['scripts'] += view_scripts
94
 
        ctx['scripts'] += overlay_bits[2]
 
88
        ctx['scripts'] += req.scripts
95
89
 
96
 
        ctx['scripts_init'] = self.scripts_init + overlay_bits[3]
 
90
        ctx['scripts_init'] = req.scripts_init
97
91
        ctx['app_template'] = app
98
92
        ctx['title_img'] = media_url(req, CorePlugin,
99
93
                                     "images/chrome/title.png")
107
101
 
108
102
    def populate_headings(self, req, ctx):
109
103
        ctx['favicon'] = None
110
 
        ctx['root_dir'] = req.config['urls']['root']
111
 
        ctx['public_host'] = req.config['urls']['public_host']
112
 
        ctx['svn_base'] = req.config['urls']['svn_addr']
 
104
        ctx['root_dir'] = ivle.conf.root_dir
 
105
        ctx['public_host'] = ivle.conf.public_host
113
106
        ctx['write_javascript_settings'] = req.write_javascript_settings
114
107
        if req.user:
115
108
            ctx['login'] = req.user.login
142
135
                        ctx['favicon'] = icon_url
143
136
                else:
144
137
                    new_app['has_icon'] = False
145
 
                new_app['path'] = req.make_path(tab[4])
 
138
                new_app['path'] = ivle.util.make_path(tab[4])
146
139
                new_app['desc'] = tab[2]
147
140
                new_app['name'] = tab[1]
148
141
                new_app['weight'] = tab[5]
157
150
        scripts_init.
158
151
        """
159
152
        overlays = []
160
 
        styles = []
161
 
        scripts = []
162
 
        scripts_init = []
163
153
        if not self.allow_overlays:
164
 
            return (overlays, styles, scripts, scripts_init)
 
154
            return overlays
165
155
 
166
156
        for plugin in req.config.plugin_index[OverlayPlugin]:
167
157
            for overclass in plugin.overlays:
171
161
                #TODO: Re-factor this to look nicer
172
162
                for mplugin in overlay.plugin_scripts:
173
163
                    for path in overlay.plugin_scripts[mplugin]:
174
 
                        scripts.append(media_url(req, mplugin, path))
 
164
                        req.scripts.append(media_url(req, mplugin, path))
175
165
 
176
166
                for mplugin in overlay.plugin_styles:
177
167
                    for path in overlay.plugin_styles[mplugin]:
178
 
                        styles.append(media_url(req, mplugin, path))
 
168
                        req.styles.append(media_url(req, mplugin, path))
179
169
 
180
 
                scripts_init += overlay.plugin_scripts_init
 
170
                req.scripts_init += overlay.plugin_scripts_init
181
171
 
182
172
                overlays.append(overlay.render(req))
183
 
        return (overlays, styles, scripts, scripts_init)
 
173
        return overlays
184
174
 
185
175
    @classmethod
186
176
    def get_error_view(cls, e):