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