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
34
32
class XHTMLView(BaseView):
66
67
tmpl = loader.load(app_template)
67
68
app = self.filter(tmpl.generate(viewctx), viewctx)
69
71
for plugin in self.plugin_scripts:
70
72
for path in self.plugin_scripts[plugin]:
71
req.scripts.append(media_url(req, plugin, path))
73
view_scripts.append(media_url(req, plugin, path))
73
76
for plugin in self.plugin_styles:
74
77
for path in self.plugin_styles[plugin]:
75
req.styles.append(media_url(req, plugin, path))
78
view_styles.append(media_url(req, plugin, path))
78
81
ctx = genshi.template.Context()
79
# XXX: Leave this here!! (Before req.styles is read)
80
ctx['overlays'] = self.render_overlays(req) if req.user else []
83
overlay_bits = self.render_overlays(req) if req.user else [[]]*4
84
ctx['overlays'] = overlay_bits[0]
82
86
ctx['styles'] = [media_url(req, CorePlugin, 'ivle.css')]
83
ctx['styles'] += req.styles
87
ctx['styles'] += view_styles
88
ctx['styles'] += overlay_bits[1]
85
90
ctx['scripts'] = [media_url(req, CorePlugin, path) for path in
86
91
('util.js', 'json2.js', 'md5.js')]
87
92
ctx['scripts'].append(media_url(req, '+external/jquery', 'jquery.js'))
88
ctx['scripts'] += req.scripts
93
ctx['scripts'] += view_scripts
94
ctx['scripts'] += overlay_bits[2]
90
ctx['scripts_init'] = req.scripts_init
96
ctx['scripts_init'] = self.scripts_init + overlay_bits[3]
91
97
ctx['app_template'] = app
92
98
ctx['title_img'] = media_url(req, CorePlugin,
93
99
"images/chrome/title.png")
102
108
def populate_headings(self, req, ctx):
103
109
ctx['favicon'] = None
104
ctx['root_dir'] = ivle.conf.root_dir
105
ctx['public_host'] = ivle.conf.public_host
106
ctx['svn_base'] = ivle.conf.svn_addr
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']
107
113
ctx['write_javascript_settings'] = req.write_javascript_settings
109
115
ctx['login'] = req.user.login
136
142
ctx['favicon'] = icon_url
138
144
new_app['has_icon'] = False
139
new_app['path'] = ivle.util.make_path(tab[4])
145
new_app['path'] = req.make_path(tab[4])
140
146
new_app['desc'] = tab[2]
141
147
new_app['name'] = tab[1]
142
148
new_app['weight'] = tab[5]
154
163
if not self.allow_overlays:
164
return (overlays, styles, scripts, scripts_init)
157
166
for plugin in req.config.plugin_index[OverlayPlugin]:
158
167
for overclass in plugin.overlays:
162
171
#TODO: Re-factor this to look nicer
163
172
for mplugin in overlay.plugin_scripts:
164
173
for path in overlay.plugin_scripts[mplugin]:
165
req.scripts.append(media_url(req, mplugin, path))
174
scripts.append(media_url(req, mplugin, path))
167
176
for mplugin in overlay.plugin_styles:
168
177
for path in overlay.plugin_styles[mplugin]:
169
req.styles.append(media_url(req, mplugin, path))
178
styles.append(media_url(req, mplugin, path))
171
req.scripts_init += overlay.plugin_scripts_init
180
scripts_init += overlay.plugin_scripts_init
173
182
overlays.append(overlay.render(req))
183
return (overlays, styles, scripts, scripts_init)
177
186
def get_error_view(cls, e):