Пример #1
0
    def GET(self, path):  
        i = web.input(b=None, a=None)
        # default value of b is latest revision and default value of a is b-1
        
        def get(path, revision):
            if revision == 0:
                page = web.ctx.site.new(path, {'revision': 0, 'type': {'key': '/type/object'}, 'key': path})
            else:
                page = web.ctx.site.get(path, revision)
            return page
        
        def is_int(n):
            return n is None or safeint(n, None) is not None
            
        # if either or i.a or i.b is bad, then redirect to latest diff
        if not is_int(i.b) or not is_int(i.a):
            return web.redirect(web.changequery(b=None, a=None))

        b = get(path, safeint(i.b, None))

        # if the page is not there go to view page
        if b is None:
            raise web.seeother(web.changequery(query={}))
        
        a = get(path, safeint(i.a, b.revision-1))            
        return render.diff(a, b)
Пример #2
0
    def GET(self, path):
        i = web.input(b=None, a=None)

        # default value of b is latest revision and default value of a is b-1

        def get(path, revision):
            if revision == 0:
                page = web.ctx.site.new(path, {
                    'revision': 0,
                    'type': {
                        'key': '/type/object'
                    },
                    'key': path
                })
            else:
                page = web.ctx.site.get(path, revision)
            return page

        def is_int(n):
            return n is None or safeint(n, None) is not None

        # if either or i.a or i.b is bad, then redirect to latest diff
        if not is_int(i.b) or not is_int(i.a):
            return web.redirect(web.changequery(b=None, a=None))

        b = get(path, safeint(i.b, None))

        # if the page is not there go to view page
        if b is None:
            raise web.seeother(web.changequery(query={}))

        a = get(path, max(1, safeint(i.a, b.revision - 1)))
        return render.diff(a, b)
Пример #3
0
        def diff(key, revision):
            b = db.get_version(key, revision)

            rev_a = revision -1
            if rev_a is 0:
                a = web.ctx.site.new(key, {})
                a.revision = 0
            else: 
                a = db.get_version(key, revision=rev_a)
                
            diff = render.diff(a, b)

            #@@ dirty hack to extract diff table from diff
            import re
            rx = re.compile(r"^.*(<table.*<\/table>).*$", re.S)
            return rx.sub(r'\1', str(diff))
Пример #4
0
        def diff(key, revision):
            b = db.get_version(key, revision)

            rev_a = revision -1
            if rev_a == 0:
                a = web.ctx.site.new(key, {})
                a.revision = 0
            else:
                a = db.get_version(key, revision=rev_a)

            diff = render.diff(a, b)

            #@@ dirty hack to extract diff table from diff
            import re
            rx = re.compile(r"^.*(<table.*<\/table>).*$", re.S)
            return rx.sub(r'\1', str(diff))
Пример #5
0
    def GET(self, site, path):
        user = core.auth.get_user()
        i = input()

        if i.a == 0:
            alines = []
            xa = web.storage(created="", revision=0)
        else:
            xa = core.db.get_version(site, path, revision=i.a)
            alines = xa.data.body.splitlines()

        xb = core.db.get_version(site, path, revision=i.b)
        blines = xb.data.body.splitlines()
        map = core.diff.better_diff(alines, blines)

        view.add_stylesheet('core', 'diff.css')
        diff = render.diff(map, xa, xb)

        return render.review(path, diff, i.a, i.b, i.c)
Пример #6
0
    def GET(self, site, path):
        user = core.auth.get_user()
        i = input()

        if i.a == 0:
            alines = []
            xa = web.storage(created="", revision=0)
        else:
            xa = core.db.get_version(site, path, revision=i.a)
            alines = xa.data.body.splitlines()

        xb = core.db.get_version(site, path, revision=i.b)
        blines = xb.data.body.splitlines()
        map = core.diff.better_diff(alines, blines)

        view.add_stylesheet('core', 'diff.css')
        diff = render.diff(map, xa, xb)
        
        return render.review(path, diff, i.a, i.b, i.c)