Ejemplo n.º 1
0
    def render(self):
        self.perm.assert_permission (perm.BROWSER_VIEW)
        
        rev = self.args.get('rev', None)
        path = self.args.get('path', '/')
        order = self.args.get('order', 'name').lower()
        desc = self.args.has_key('desc')
        
        self.authzperm.assert_permission (path)
        
        if not rev:
            rev_specified = 0
            rev = svn.fs.youngest_rev(self.fs_ptr, self.pool)
        else:
            try:
                rev = int(rev)
                rev_specified = 1
            except:
                rev_specified = rev.lower() in ['head', 'latest', 'trunk']
                rev = svn.fs.youngest_rev(self.fs_ptr, self.pool)

        info = self.get_info(path, rev, rev_specified)
        if order == 'date':
            if desc:
                info.sort(lambda y, x: cmp(x['date_seconds'],
                                           y['date_seconds']))
            else:
                info.sort(lambda x, y: cmp(x['date_seconds'],
                                           y['date_seconds']))
        else:
            if desc:
                info.sort(lambda y, x: cmp(util.rstrip(x['name'], '/'),
                                           util.rstrip(y['name'], '/')))
            else:
                info.sort(lambda x, y: cmp(util.rstrip(x['name'], '/'),
                                           util.rstrip(y['name'], '/')))

        # Always put directories before files
        info.sort(lambda x, y: cmp(y['is_dir'], x['is_dir']))

        util.add_dictlist_to_hdf(info, self.req.hdf, 'browser.items')

        self.generate_path_links(path, rev, rev_specified)

        if path != '/':
            parent = string.join(path.split('/')[:-2], '/') + '/'
            if rev_specified:
                self.req.hdf.setValue('browser.parent_href',
                                      self.env.href.browser(parent, rev))
            else:
                self.req.hdf.setValue('browser.parent_href',
                                      self.env.href.browser(parent))

        self.req.hdf.setValue('title', path)
        self.req.hdf.setValue('browser.path', path)
        self.req.hdf.setValue('browser.revision', str(rev))
        self.req.hdf.setValue('browser.order', order)
        self.req.hdf.setValue('browser.order_dir', desc and 'desc' or 'asc')
        self.req.hdf.setValue('browser.current_href', self.env.href.browser(path))
        self.req.hdf.setValue('browser.log_href', self.env.href.log(path))
Ejemplo n.º 2
0
    def render (self):
        self.perm.assert_permission(perm.TIMELINE_VIEW)

        self.add_link('alternate', '?daysback=90&max=50&format=rss',
            'RSS Feed', 'application/rss+xml', 'rss')

        _from = self.args.get('from', '')
        _daysback = self.args.get('daysback', '')

        # Parse the from date and adjust the timestamp to the last second of the day
        t = time.localtime()
        if _from:
            try:
                t = time.strptime(_from, '%x')
            except:
                pass
        _from = time.mktime((t[0], t[1], t[2], 23, 59, 59, t[6], t[7], t[8]))
        try:
            daysback = int(_daysback)
            assert daysback >= 0
        except:
            daysback = 30
        self.req.hdf.setValue('timeline.from',
                              time.strftime('%x', time.localtime(_from)))
        self.req.hdf.setValue('timeline.daysback', str(daysback))

        stop  = _from
        start = stop - daysback * 86400
        maxrows = int(self.args.get('max', 0))

        wiki = self.args.has_key('wiki') 
        ticket = self.args.has_key('ticket')
        changeset = self.args.has_key('changeset')
        milestone = self.args.has_key('milestone')
        if not (wiki or ticket or changeset or milestone):
            wiki = ticket = changeset = milestone = 1

        if wiki:
            self.req.hdf.setValue('timeline.wiki', 'checked')
        if ticket:
            self.req.hdf.setValue('timeline.ticket', 'checked')
        if changeset:
            self.req.hdf.setValue('timeline.changeset', 'checked')
        if milestone:
            self.req.hdf.setValue('timeline.milestone', 'checked')

        info = self.get_info (start, stop, maxrows, ticket,
                              changeset, wiki, milestone)
        util.add_dictlist_to_hdf(info, self.req.hdf, 'timeline.items')
        self.req.hdf.setValue('title', 'Timeline')
Ejemplo n.º 3
0
    def render(self):
        self.perm.assert_permission(perm.CHANGESET_VIEW)

        self.add_link('alternate', '?format=diff', 'Unified Diff',
                      'text/plain', 'diff')

        youngest_rev = svn.fs.youngest_rev(self.fs_ptr, self.pool)
        if self.args.has_key('rev'):
            self.rev = int(self.args.get('rev'))
        else:
            self.rev = youngest_rev

        Diff.get_options(self.env, self.req, self.args, 1)
        if self.args.has_key('update'):
            self.req.redirect(self.env.href.changeset(self.rev))

        change_info = self.get_change_info(self.rev)
        changeset_info = self.get_changeset_info(self.rev)

        self.req.hdf.setValue('title', '[%d] (changeset)' % self.rev)
        self.req.hdf.setValue(
            'changeset.time',
            time.asctime(time.localtime(int(changeset_info['time']))))
        author = changeset_info['author'] or 'anonymous'
        self.req.hdf.setValue('changeset.author', util.escape(author))
        message = changeset_info['message'] or '--'
        self.req.hdf.setValue(
            'changeset.message',
            wiki_to_html(util.wiki_escape_newline(message), self.req.hdf,
                         self.env, self.db))
        self.req.hdf.setValue('changeset.revision', str(self.rev))
        util.add_dictlist_to_hdf(change_info, self.req.hdf,
                                 'changeset.changes')

        self.req.hdf.setValue('changeset.href',
                              self.env.href.changeset(self.rev))
        if self.rev > 1:
            self.add_link('first', self.env.href.changeset(1), 'Changeset 1')
            self.add_link('prev', self.env.href.changeset(self.rev - 1),
                          'Changeset %d' % (self.rev - 1))
        if self.rev < youngest_rev:
            self.add_link('next', self.env.href.changeset(self.rev + 1),
                          'Changeset %d' % (self.rev + 1))
            self.add_link('last', self.env.href.changeset(youngest_rev),
                          'Changeset %d' % youngest_rev)
Ejemplo n.º 4
0
    def render (self):
        self.perm.assert_permission(perm.SEARCH_VIEW)
        self.req.hdf.setValue('title', 'Search')
        self.req.hdf.setValue('search.ticket', 'checked')
        self.req.hdf.setValue('search.changeset', 'checked')
        self.req.hdf.setValue('search.wiki', 'checked')
        self.req.hdf.setValue('search.results_per_page', str(self.RESULTS_PER_PAGE))
        
        if self.args.has_key('q'):
            query = self.args.get('q')
            self.req.hdf.setValue('title', 'Search Results')
            self.req.hdf.setValue('search.q', query.replace('"', "&#34;"))
            tickets = self.args.has_key('ticket')
            changesets = self.args.has_key('changeset')
            wiki = self.args.has_key('wiki')

            # If no search options chosen, choose all
            if not (tickets or changesets or wiki):
                tickets = changesets = wiki = 1
            if not tickets:
                self.req.hdf.setValue('search.ticket', '')
            if not changesets:
                self.req.hdf.setValue('search.changeset', '')
            if not wiki:
                self.req.hdf.setValue('search.wiki', '')

            page = int(self.args.get('page', '0'))
            self.req.hdf.setValue('search.result_page', str(page))
            info, more = self.perform_query(query, changesets, tickets, wiki,
                                            page)
            add_dictlist_to_hdf(info, self.req.hdf, 'search.result')

            include = []
            if tickets: include.append('ticket')
            if changesets: include.append('changeset')
            if wiki: include.append('wiki')
            if page:
                self.add_link('first',
                              self.env.href.search(query, 0, include))
                self.add_link('prev',
                              self.env.href.search(query, page - 1, include))
            if more:
                self.add_link('next',
                              self.env.href.search(query, page + 1, include))
Ejemplo n.º 5
0
    def render(self):
        self.perm.assert_permission(perm.LOG_VIEW)

        self.add_link('alternate', '?format=rss', 'RSS Feed',
                      'application/rss+xml', 'rss')

        self.path = self.args.get('path', '/')
        if self.args.has_key('rev'):
            try:
                rev = int(self.args.get('rev'))
                rev_specified = 1
            except ValueError:
                rev = svn.fs.youngest_rev(self.fs_ptr, self.pool)
                rev_specified = 0
        else:
            rev = svn.fs.youngest_rev(self.fs_ptr, self.pool)
            rev_specified = 0

        try:
            root = svn.fs.revision_root(self.fs_ptr, rev, self.pool)
        except svn.core.SubversionException:
            raise util.TracError('Invalid revision number: %d' % rev)

        # We display an error message if the file doesn't exist (any more).
        # All we know is that the path isn't valid in the youngest
        # revision of the repository. The file might have existed
        # before, but we don't know for sure...
        if not svn.fs.check_path(root, self.path, self.pool) in \
               [svn.core.svn_node_file, svn.core.svn_node_dir]:
            raise util.TracError(
                'The file or directory "%s" doesn\'t exist in the '
                'repository at revision %d.' % (self.path, rev),
                'Nonexistent path')
        else:
            info = self.get_info(self.path, rev)
            util.add_dictlist_to_hdf(info, self.req.hdf, 'log.items')

        self.generate_path_links(rev, rev_specified)
        self.req.hdf.setValue('title', self.path + ' (log)')
        self.req.hdf.setValue('log.path', self.path)
        self.req.hdf.setValue('log.href', self.env.href.log(self.path))