39
41
template = 'template.html'
41
42
plugin_scripts = {}
45
44
allow_overlays = True
46
45
overlay_blacklist = []
48
def filter(self, stream, ctx):
47
def __init__(self, req, **kwargs):
49
setattr(self, key, kwargs[key])
51
51
def render(self, req):
52
52
req.content_type = 'text/html' # TODO: Detect application/xhtml+xml
61
61
inspect.getmodule(self).__file__), self.template)
62
62
loader = genshi.template.TemplateLoader(".", auto_reload=True)
63
63
tmpl = loader.load(app_template)
64
app = self.filter(tmpl.generate(viewctx), viewctx)
64
app = tmpl.generate(viewctx)
67
66
for plugin in self.plugin_scripts:
68
67
for path in self.plugin_scripts[plugin]:
69
view_scripts.append(media_url(req, plugin, path))
68
req.scripts.append(media_url(req, plugin, path))
72
70
for plugin in self.plugin_styles:
73
71
for path in self.plugin_styles[plugin]:
74
view_styles.append(media_url(req, plugin, path))
72
req.styles.append(media_url(req, plugin, path))
77
75
ctx = genshi.template.Context()
79
overlay_bits = self.render_overlays(req) if req.user else [[]]*4
80
ctx['overlays'] = overlay_bits[0]
76
# XXX: Leave this here!! (Before req.styles is read)
77
ctx['overlays'] = self.render_overlays(req) if req.user else []
82
79
ctx['styles'] = [media_url(req, CorePlugin, 'ivle.css')]
83
ctx['styles'] += view_styles
84
ctx['styles'] += overlay_bits[1]
80
ctx['styles'] += req.styles
86
82
ctx['scripts'] = [media_url(req, CorePlugin, path) for path in
87
83
('util.js', 'json2.js', 'md5.js')]
88
ctx['scripts'].append(media_url(req, '+external/jquery', 'jquery.js'))
89
ctx['scripts'] += view_scripts
90
ctx['scripts'] += overlay_bits[2]
84
ctx['scripts'] += req.scripts
92
ctx['scripts_init'] = self.scripts_init + overlay_bits[3]
86
ctx['scripts_init'] = req.scripts_init
93
87
ctx['app_template'] = app
94
88
ctx['title_img'] = media_url(req, CorePlugin,
95
89
"images/chrome/title.png")
104
98
def populate_headings(self, req, ctx):
105
99
ctx['favicon'] = None
106
ctx['root_dir'] = req.config['urls']['root']
107
ctx['public_host'] = req.config['urls']['public_host']
108
ctx['svn_base'] = req.config['urls']['svn_addr']
100
ctx['root_dir'] = ivle.conf.root_dir
101
ctx['public_host'] = ivle.conf.public_host
109
102
ctx['write_javascript_settings'] = req.write_javascript_settings
111
104
ctx['login'] = req.user.login
159
149
if not self.allow_overlays:
160
return (overlays, styles, scripts, scripts_init)
162
152
for plugin in req.config.plugin_index[OverlayPlugin]:
163
153
for overclass in plugin.overlays:
167
157
#TODO: Re-factor this to look nicer
168
158
for mplugin in overlay.plugin_scripts:
169
159
for path in overlay.plugin_scripts[mplugin]:
170
scripts.append(media_url(req, mplugin, path))
160
req.scripts.append(media_url(req, mplugin, path))
172
162
for mplugin in overlay.plugin_styles:
173
163
for path in overlay.plugin_styles[mplugin]:
174
styles.append(media_url(req, mplugin, path))
164
req.styles.append(media_url(req, mplugin, path))
176
scripts_init += overlay.plugin_scripts_init
166
req.scripts_init += overlay.plugin_scripts_init
178
168
overlays.append(overlay.render(req))
179
return (overlays, styles, scripts, scripts_init)
182
172
def get_error_view(cls, e):
189
179
class XHTMLErrorView(XHTMLView):
190
180
template = 'xhtmlerror.html'
182
def __init__(self, req, exception):
183
self.context = exception
192
185
def populate(self, req, ctx):
194
186
ctx['exception'] = self.context
196
188
class XHTMLUnauthorizedView(XHTMLErrorView):