25
25
from ivle.webapp.media import media_url
26
26
from ivle.webapp.core import Plugin as CorePlugin
27
27
from ivle.webapp.base.views import BaseView
28
from ivle.webapp.base.plugins import OverlayPlugin
28
from ivle.webapp.base.plugins import ViewPlugin, OverlayPlugin
29
29
from ivle.webapp.errors import HTTPError, Unauthorized
105
105
ctx['login'] = None
106
106
ctx['logged_in'] = False
107
107
ctx['publicmode'] = req.publicmode
108
ctx['apps_in_tabs'] = []
109
108
if hasattr(self, 'help'):
110
109
ctx['help_path'] = self.help
111
for urlname in ivle.conf.apps.apps_in_tabs:
113
app = ivle.conf.apps.app_url[urlname]
114
new_app['this_app'] = hasattr(self, 'appname') \
115
and urlname == self.appname
117
new_app['has_icon'] = True
118
icon_dir = ivle.conf.apps.app_icon_dir
119
icon_url = ivle.util.make_path(os.path.join(icon_dir, app.icon))
120
new_app['icon_url'] = icon_url
121
if new_app['this_app']:
122
ctx['favicon'] = icon_url
124
new_app['has_icon'] = False
125
new_app['path'] = ivle.util.make_path(urlname)
126
new_app['desc'] = app.desc
127
new_app['name'] = app.name
128
ctx['apps_in_tabs'].append(new_app)
111
ctx['apps_in_tabs'] = []
112
for plugin in req.plugin_index[ViewPlugin]:
113
if not hasattr(plugin, 'tabs'):
116
for tab in plugin.tabs:
117
# tab is a tuple: name, title, desc, icon, path
119
new_app['this_app'] = hasattr(self, 'appname') \
120
and tab[0] == self.appname
123
if tab[3] is not None:
124
new_app['has_icon'] = True
125
icon_url = media_url(req, plugin, tab[3])
126
new_app['icon_url'] = icon_url
127
if new_app['this_app']:
128
ctx['favicon'] = icon_url
130
new_app['has_icon'] = False
131
new_app['path'] = ivle.util.make_path(tab[4])
132
new_app['desc'] = tab[2]
133
new_app['name'] = tab[1]
134
new_app['weight'] = tab[5]
135
ctx['apps_in_tabs'].append(new_app)
137
ctx['apps_in_tabs'].sort(key=lambda tab: tab['weight'])
130
139
def render_overlays(self, req):
131
140
"""Generate XML streams for the overlays.