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

« back to all changes in this revision

Viewing changes to ivle/webapp/filesystem/diff/__init__.py

  • Committer: William Grant
  • Date: 2009-12-08 03:50:24 UTC
  • mfrom: (1294.2.143 ui-the-third)
  • Revision ID: grantw@unimelb.edu.au-20091208035024-wjx8zp54gth15ph8
Merge ui-the-third. This is another UI revamp.

The header is now thin! Thin! The yellow bar is gone. The tabs are gone.
Breadcrumbs are here. Routes is replaced (with an object publishing
mechanism). Views are less repetitive. etc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
from ivle.webapp.base.xhtml import XHTMLView
31
31
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin
32
32
from ivle.webapp.errors import NotFound, BadRequest
33
 
from ivle.webapp.filesystem import make_path_segments
 
33
from ivle.webapp.filesystem import make_path_breadcrumbs
 
34
from ivle.webapp import ApplicationRoot
34
35
 
35
36
class DiffView(XHTMLView):
36
37
    '''A view to present a nice XHTML Subversion diff from a user's jail.'''
37
38
    template = 'template.html'
38
39
    tab = 'files'
39
40
 
40
 
    def __init__(self, req, path):
41
 
        self.path = path
 
41
    subpath_allowed = True
42
42
 
43
43
    def authorize(self, req):
44
44
        return req.user is not None
78
78
        )
79
79
 
80
80
        ctx['title'] = os.path.normpath(self.path).rsplit('/', 1)[-1]
81
 
        ctx['paths'] = make_path_segments(self.path)
 
81
        self.extra_breadcrumbs = make_path_breadcrumbs(req, self.subpath,
 
82
                                                   suffix='(Subversion diff)')
82
83
 
83
84
        # Create a dict with (name, HTMLdiff) pairs for each non-empty diff.
84
85
        ctx['files'] = dict([(fd[0], genshi.XML(htmlfy_diff(fd[1])))
85
86
                             for fd in diff_matcher.findall(diff)
86
87
                             if fd[1]])
87
88
 
 
89
    @property
 
90
    def path(self):
 
91
        return os.path.join(*self.subpath) if self.subpath else ''
 
92
 
88
93
 
89
94
def htmlfy_diff(difftext):
90
95
    """Adds HTML markup to a udiff string"""
108
113
    return '<pre class="diff">%s</pre>' % output
109
114
 
110
115
class Plugin(ViewPlugin, MediaPlugin):
111
 
    '''Registration class for diff components.'''
112
 
    urls = [
113
 
        ('diff/', DiffView, {'path': ''}),
114
 
        ('diff/*(path)', DiffView),
115
 
    ]
 
116
    views = [(ApplicationRoot, 'diff', DiffView)]
116
117
 
117
118
    media = 'media'