~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/base/xhtml.py

  • Committer: Matt Giuca
  • Date: 2010-02-11 03:17:12 UTC
  • Revision ID: matt.giuca@gmail.com-20100211031712-79c74lgh3mj7507s
docs: Tour of IVLE: Added lecturer tour (complete).

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    template = 'template.html'
42
42
    allow_overlays = True
43
43
    breadcrumb_text = None
44
 
    _loader = None
45
44
 
46
45
    def __init__(self, *args, **kwargs):
47
46
        super(XHTMLView, self).__init__(*args, **kwargs)
48
47
 
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,
55
 
                max_cache_size=100)
56
 
 
57
48
        self.overlay_blacklist = []
58
49
 
59
50
        self.plugin_scripts = {}
80
71
        # view.
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)
85
77
 
86
78
        view_scripts = []
121
113
        crumber = Breadcrumber(req)
122
114
 
123
115
        ctx['breadcrumbs'] = []
124
 
        if not req.publicmode:
125
 
            for ancestor in ancestry:
126
 
                crumb = crumber.crumb(ancestor)
127
 
                if crumb is None:
128
 
                    continue
129
 
 
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)
135
 
 
136
 
            # If the view has specified text for a breadcrumb, add one.
137
 
            if self.breadcrumb_text:
138
 
                ctx['breadcrumbs'].append(ViewBreadcrumb(req, self))
139
 
 
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)
 
118
            if crumb is None:
 
119
                continue
 
120
 
 
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)
 
126
 
 
127
        # If the view has specified text for a breadcrumb, add one.
 
128
        if self.breadcrumb_text:
 
129
            ctx['breadcrumbs'].append(ViewBreadcrumb(req, self))
 
130
 
 
131
        # Allow the view to add its own fake breadcrumbs.
 
132
        ctx['breadcrumbs'].extend(self.extra_breadcrumbs)
142
133
 
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'))
147
138
        
171
162
                continue
172
163
 
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
176
166
                new_app = {}
177
167
                new_app['this_app'] = hasattr(self, 'tab') \
178
168
                                      and tab[0] == self.tab
186
176
                        ctx['favicon'] = icon_url
187
177
                else:
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]:
192
 
                    # Admin-only tab
193
 
                    if not (req.user and req.user.admin):
194
 
                        break
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):
254
238
        ctx['req'] = req
255
239
        ctx['exception'] = self.context
256
 
        req.headers_out['X-IVLE-Error'] = self.context.message
257
240
 
258
241
class XHTMLUnauthorizedView(XHTMLErrorView):
259
242
    template = 'xhtmlunauthorized.html'