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

« back to all changes in this revision

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

  • Committer: Matt Giuca
  • Date: 2009-05-19 02:54:08 UTC
  • mfrom: (1258 trunk)
  • mto: This revision was merged to the branch mainline in revision 1322.
  • Revision ID: matt.giuca@gmail.com-20090519025408-19c7cjl7w6ot6frm
MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import cjson
27
27
import genshi
28
28
 
29
 
import ivle.conf
30
29
import ivle.interpret
31
30
from ivle.webapp.base.xhtml import XHTMLView
32
31
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin
33
32
from ivle.webapp.errors import NotFound, BadRequest
 
33
from ivle.webapp.filesystem import make_path_segments
34
34
 
35
35
class DiffView(XHTMLView):
36
36
    '''A view to present a nice XHTML Subversion diff from a user's jail.'''
37
37
    template = 'template.html'
 
38
    tab = 'files'
38
39
 
39
40
    def __init__(self, req, path):
40
41
        self.path = path
51
52
 
52
53
        revs = [revfield.value for revfield in revfields]
53
54
 
54
 
        jail_dir = os.path.join(ivle.conf.jail_base, req.user.login)
 
55
        jail_dir = os.path.join(req.config['paths']['jails']['mounts'],
 
56
                                req.user.login)
55
57
        (out, err) = ivle.interpret.execute_raw(req.user, jail_dir, '/home',
56
 
                    os.path.join(ivle.conf.share_path, 'services/diffservice'),
57
 
                    [self.path] + revs)
 
58
                                    os.path.join(req.config['paths']['share'],
 
59
                                                 'services/diffservice'),
 
60
                                    [self.path] + revs)
58
61
        assert not err
59
62
 
60
63
        response = cjson.decode(out)
73
76
            r'^Index: (.*)\n\=+\n((?:[^I].*\n)*)',re.MULTILINE
74
77
        )
75
78
 
 
79
        ctx['title'] = self.path.rsplit('/', 1)[-1]
 
80
        ctx['paths'] = make_path_segments(self.path)
 
81
 
76
82
        # Create a dict with (name, HTMLdiff) pairs for each non-empty diff.
77
83
        ctx['files'] = dict([(fd[0], genshi.XML(htmlfy_diff(fd[1])))
78
84
                             for fd in diff_matcher.findall(diff)