~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-06-24 10:47:38 UTC
  • mfrom: (1288 trunk)
  • mto: (1281.1.8 aufsless)
  • mto: This revision was merged to the branch mainline in revision 1300.
  • Revision ID: grantw@unimelb.edu.au-20090624104738-ezgfy17mjzwz09i3
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    """
38
38
 
39
39
    template = 'template.html'
 
40
 
40
41
    plugin_scripts = {}
41
42
    plugin_styles = {}
 
43
    scripts_init = []
 
44
 
42
45
    allow_overlays = True
43
46
    overlay_blacklist = []
44
47
 
64
67
        tmpl = loader.load(app_template)
65
68
        app = self.filter(tmpl.generate(viewctx), viewctx)
66
69
 
 
70
        view_scripts = []
67
71
        for plugin in self.plugin_scripts:
68
72
            for path in self.plugin_scripts[plugin]:
69
 
                req.scripts.append(media_url(req, plugin, path))
 
73
                view_scripts.append(media_url(req, plugin, path))
70
74
 
 
75
        view_styles = []
71
76
        for plugin in self.plugin_styles:
72
77
            for path in self.plugin_styles[plugin]:
73
 
                req.styles.append(media_url(req, plugin, path))
 
78
                view_styles.append(media_url(req, plugin, path))
74
79
 
75
80
        # Global template
76
81
        ctx = genshi.template.Context()
77
 
        # XXX: Leave this here!! (Before req.styles is read)
78
 
        ctx['overlays'] = self.render_overlays(req) if req.user else []
 
82
 
 
83
        overlay_bits = self.render_overlays(req) if req.user else [[]]*4
 
84
        ctx['overlays'] = overlay_bits[0]
79
85
 
80
86
        ctx['styles'] = [media_url(req, CorePlugin, 'ivle.css')]
81
 
        ctx['styles'] += req.styles
 
87
        ctx['styles'] += view_styles
 
88
        ctx['styles'] += overlay_bits[1]
82
89
 
83
90
        ctx['scripts'] = [media_url(req, CorePlugin, path) for path in
84
91
                           ('util.js', 'json2.js', 'md5.js')]
85
92
        ctx['scripts'].append(media_url(req, '+external/jquery', 'jquery.js'))
86
 
        ctx['scripts'] += req.scripts
 
93
        ctx['scripts'] += view_scripts
 
94
        ctx['scripts'] += overlay_bits[2]
87
95
 
88
 
        ctx['scripts_init'] = req.scripts_init
 
96
        ctx['scripts_init'] = self.scripts_init + overlay_bits[3]
89
97
        ctx['app_template'] = app
90
98
        ctx['title_img'] = media_url(req, CorePlugin,
91
99
                                     "images/chrome/title.png")
149
157
        scripts_init.
150
158
        """
151
159
        overlays = []
 
160
        styles = []
 
161
        scripts = []
 
162
        scripts_init = []
152
163
        if not self.allow_overlays:
153
 
            return overlays
 
164
            return (overlays, styles, scripts, scripts_init)
154
165
 
155
166
        for plugin in req.config.plugin_index[OverlayPlugin]:
156
167
            for overclass in plugin.overlays:
160
171
                #TODO: Re-factor this to look nicer
161
172
                for mplugin in overlay.plugin_scripts:
162
173
                    for path in overlay.plugin_scripts[mplugin]:
163
 
                        req.scripts.append(media_url(req, mplugin, path))
 
174
                        scripts.append(media_url(req, mplugin, path))
164
175
 
165
176
                for mplugin in overlay.plugin_styles:
166
177
                    for path in overlay.plugin_styles[mplugin]:
167
 
                        req.styles.append(media_url(req, mplugin, path))
 
178
                        styles.append(media_url(req, mplugin, path))
168
179
 
169
 
                req.scripts_init += overlay.plugin_scripts_init
 
180
                scripts_init += overlay.plugin_scripts_init
170
181
 
171
182
                overlays.append(overlay.render(req))
172
 
        return overlays
 
183
        return (overlays, styles, scripts, scripts_init)
173
184
 
174
185
    @classmethod
175
186
    def get_error_view(cls, e):