39
39
template = 'template.html'
40
41
plugin_scripts = {}
42
45
allow_overlays = True
43
46
overlay_blacklist = []
45
def __init__(self, req, **kwargs):
47
setattr(self, key, kwargs[key])
49
48
def filter(self, stream, ctx):
64
63
tmpl = loader.load(app_template)
65
64
app = self.filter(tmpl.generate(viewctx), viewctx)
67
67
for plugin in self.plugin_scripts:
68
68
for path in self.plugin_scripts[plugin]:
69
req.scripts.append(media_url(req, plugin, path))
69
view_scripts.append(media_url(req, plugin, path))
71
72
for plugin in self.plugin_styles:
72
73
for path in self.plugin_styles[plugin]:
73
req.styles.append(media_url(req, plugin, path))
74
view_styles.append(media_url(req, plugin, path))
76
77
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 []
79
overlay_bits = self.render_overlays(req) if req.user else [[]]*4
80
ctx['overlays'] = overlay_bits[0]
80
82
ctx['styles'] = [media_url(req, CorePlugin, 'ivle.css')]
81
ctx['styles'] += req.styles
83
ctx['styles'] += view_styles
84
ctx['styles'] += overlay_bits[1]
83
86
ctx['scripts'] = [media_url(req, CorePlugin, path) for path in
84
87
('util.js', 'json2.js', 'md5.js')]
85
88
ctx['scripts'].append(media_url(req, '+external/jquery', 'jquery.js'))
86
ctx['scripts'] += req.scripts
89
ctx['scripts'] += view_scripts
90
ctx['scripts'] += overlay_bits[2]
88
ctx['scripts_init'] = req.scripts_init
92
ctx['scripts_init'] = self.scripts_init + overlay_bits[3]
89
93
ctx['app_template'] = app
90
94
ctx['title_img'] = media_url(req, CorePlugin,
91
95
"images/chrome/title.png")
152
159
if not self.allow_overlays:
160
return (overlays, styles, scripts, scripts_init)
155
162
for plugin in req.config.plugin_index[OverlayPlugin]:
156
163
for overclass in plugin.overlays:
160
167
#TODO: Re-factor this to look nicer
161
168
for mplugin in overlay.plugin_scripts:
162
169
for path in overlay.plugin_scripts[mplugin]:
163
req.scripts.append(media_url(req, mplugin, path))
170
scripts.append(media_url(req, mplugin, path))
165
172
for mplugin in overlay.plugin_styles:
166
173
for path in overlay.plugin_styles[mplugin]:
167
req.styles.append(media_url(req, mplugin, path))
174
styles.append(media_url(req, mplugin, path))
169
req.scripts_init += overlay.plugin_scripts_init
176
scripts_init += overlay.plugin_scripts_init
171
178
overlays.append(overlay.render(req))
179
return (overlays, styles, scripts, scripts_init)
175
182
def get_error_view(cls, e):
182
189
class XHTMLErrorView(XHTMLView):
183
190
template = 'xhtmlerror.html'
185
def __init__(self, req, exception):
186
self.context = exception
188
192
def populate(self, req, ctx):
189
194
ctx['exception'] = self.context
191
196
class XHTMLUnauthorizedView(XHTMLErrorView):