41
41
template = 'template.html'
42
42
allow_overlays = True
43
43
breadcrumb_text = None
46
45
def __init__(self, *args, **kwargs):
47
46
super(XHTMLView, self).__init__(*args, **kwargs)
49
# We use a single loader for all views, so we can cache the
50
# parsed templates. auto_reload is convenient and has a minimal
51
# performance penalty, so we'll leave it on.
52
if self.__class__._loader is None:
53
self.__class__._loader = genshi.template.TemplateLoader(
54
".", auto_reload=True,
57
48
self.overlay_blacklist = []
59
50
self.plugin_scripts = {}
81
72
app_template = os.path.join(os.path.dirname(
82
73
inspect.getmodule(self).__file__), self.template)
83
tmpl = self._loader.load(app_template)
74
loader = genshi.template.TemplateLoader(".", auto_reload=True)
75
tmpl = loader.load(app_template)
84
76
app = self.filter(tmpl.generate(viewctx), viewctx)
121
113
crumber = Breadcrumber(req)
123
115
ctx['breadcrumbs'] = []
124
if not req.publicmode:
125
for ancestor in ancestry:
126
crumb = crumber.crumb(ancestor)
130
if hasattr(crumb, 'extra_breadcrumbs_before'):
131
ctx['breadcrumbs'].extend(crumb.extra_breadcrumbs_before)
132
ctx['breadcrumbs'].append(crumb)
133
if hasattr(crumb, 'extra_breadcrumbs_after'):
134
ctx['breadcrumbs'].extend(crumb.extra_breadcrumbs_after)
136
# If the view has specified text for a breadcrumb, add one.
137
if self.breadcrumb_text:
138
ctx['breadcrumbs'].append(ViewBreadcrumb(req, self))
140
# Allow the view to add its own fake breadcrumbs.
141
ctx['breadcrumbs'].extend(self.extra_breadcrumbs)
116
for ancestor in ancestry:
117
crumb = crumber.crumb(ancestor)
121
if hasattr(crumb, 'extra_breadcrumbs_before'):
122
ctx['breadcrumbs'].extend(crumb.extra_breadcrumbs_before)
123
ctx['breadcrumbs'].append(crumb)
124
if hasattr(crumb, 'extra_breadcrumbs_after'):
125
ctx['breadcrumbs'].extend(crumb.extra_breadcrumbs_after)
127
# If the view has specified text for a breadcrumb, add one.
128
if self.breadcrumb_text:
129
ctx['breadcrumbs'].append(ViewBreadcrumb(req, self))
131
# Allow the view to add its own fake breadcrumbs.
132
ctx['breadcrumbs'].extend(self.extra_breadcrumbs)
143
134
self.populate_headings(req, ctx)
144
tmpl = self._loader.load(os.path.join(os.path.dirname(__file__),
135
tmpl = loader.load(os.path.join(os.path.dirname(__file__),
145
136
'ivle-headings.html'))
146
137
req.write(tmpl.generate(ctx).render('xhtml', doctype='xhtml'))
173
164
for tab in plugin.tabs:
174
# tab is a tuple: name, title, desc, icon, path, weight, admin
175
# (Admin is optional, defaults to false)
165
# tab is a tuple: name, title, desc, icon, path
177
167
new_app['this_app'] = hasattr(self, 'tab') \
178
168
and tab[0] == self.tab
186
176
ctx['favicon'] = icon_url
188
178
new_app['has_icon'] = False
189
# The following check is here, so it is AFTER setting the
190
# icon, but BEFORE actually installing the tab in the menu
191
if len(tab) > 6 and tab[6]:
193
if not (req.user and req.user.admin):
195
179
new_app['path'] = req.make_path(tab[4])
196
180
new_app['desc'] = tab[2]
197
181
new_app['name'] = tab[1]
253
237
def populate(self, req, ctx):
255
239
ctx['exception'] = self.context
256
req.headers_out['X-IVLE-Error'] = self.context.message
258
241
class XHTMLUnauthorizedView(XHTMLErrorView):
259
242
template = 'xhtmlunauthorized.html'