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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-07-05 07:54:29 UTC
  • mto: (1294.4.2 ui-the-third)
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20090705075429-qyh9midyp0v73gnv
Add export details for the breadcrumb chevron SVG.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
31
 
from ivle.webapp.publisher import NoPath
32
 
from ivle.webapp.breadcrumbs import Breadcrumber
 
31
from ivle.webapp.routing import NoPath
33
32
 
34
33
class XHTMLView(BaseView):
35
34
    """
39
38
    """
40
39
 
41
40
    template = 'template.html'
 
41
 
 
42
    plugin_scripts = {}
 
43
    plugin_styles = {}
 
44
    scripts_init = []
 
45
 
42
46
    allow_overlays = True
43
 
 
44
 
    def __init__(self, *args, **kwargs):
45
 
        super(XHTMLView, self).__init__(*args, **kwargs)
46
 
 
47
 
        self.overlay_blacklist = []
48
 
 
49
 
        self.plugin_scripts = {}
50
 
        self.plugin_styles = {}
51
 
        self.scripts_init = []
52
 
 
53
 
        self.extra_breadcrumbs = []
54
 
        self.overlay_blacklist = []
55
 
 
56
 
    def get_context_ancestry(self, req):
57
 
        return req.publisher.get_ancestors(self.context)
 
47
    overlay_blacklist = []
58
48
 
59
49
    def filter(self, stream, ctx):
60
50
        return stream
105
95
        ctx['title_img'] = media_url(req, CorePlugin,
106
96
                                     "images/chrome/root-breadcrumb.png")
107
97
        try:
108
 
            ctx['ancestry'] = self.get_context_ancestry(req)
 
98
            ctx['ancestry'] = req.router.get_ancestors(self.context)
109
99
        except NoPath:
110
100
            ctx['ancestry'] = []
111
 
 
112
 
        # Allow the view to add its own fake breadcrumbs.
113
 
        ctx['extra_breadcrumbs'] = self.extra_breadcrumbs
114
 
 
115
 
        ctx['crumb'] = Breadcrumber(req).crumb
 
101
        ctx['breadcrumb_text'] = lambda x: x # TODO: Do it properly.
 
102
        ctx['url'] = req.router.generate
116
103
        self.populate_headings(req, ctx)
117
104
        tmpl = loader.load(os.path.join(os.path.dirname(__file__), 
118
105
                                                        'ivle-headings.html'))
209
196
class XHTMLErrorView(XHTMLView):
210
197
    template = 'xhtmlerror.html'
211
198
 
212
 
    def __init__(self, req, context, lastobj):
213
 
        super(XHTMLErrorView, self).__init__(req, context)
214
 
        self.lastobj = lastobj
215
 
 
216
 
    def get_context_ancestry(self, req):
217
 
        return req.publisher.get_ancestors(self.lastobj)
218
 
 
219
199
    def populate(self, req, ctx):
220
200
        ctx['req'] = req
221
201
        ctx['exception'] = self.context
223
203
class XHTMLUnauthorizedView(XHTMLErrorView):
224
204
    template = 'xhtmlunauthorized.html'
225
205
 
226
 
    def __init__(self, req, exception, lastobj):
227
 
        super(XHTMLUnauthorizedView, self).__init__(req, exception, lastobj)
 
206
    def __init__(self, req, exception):
 
207
        super(XHTMLUnauthorizedView, self).__init__(req, exception)
228
208
 
229
209
        if req.user is None:
230
210
            # Not logged in. Redirect to login page.