def sidebar_menu()

in Allura/allura/lib/repository.py [0:0]


    def sidebar_menu(self):
        if not self.repo or self.repo.status != 'ready':
            return []
        links = []
        if not self.repo.is_empty():
            links.append(SitemapEntry('Browse Commits', c.app.url + 'commit_browser',
                                      ui_icon=g.icons['browse_commits'],
                                      extra_html_attrs=dict(rel='nofollow')))
        if self.forkable and self.repo.status == 'ready' and not self.repo.is_empty():
            links.append(
                SitemapEntry('Fork', c.app.url + 'fork', ui_icon=g.icons['fork'],
                             extra_html_attrs=dict(rel='nofollow')))
        merge_request_count = self.repo.merge_requests_by_statuses(
            'open').count()
        if self.forkable:
            links += [
                SitemapEntry(
                    'Merge Requests', c.app.url + 'merge-requests/',
                    small=merge_request_count,
                    extra_html_attrs=dict(rel='nofollow'))]
        if self.repo.forks:
            links += [
                SitemapEntry('Forks', c.app.url + 'forks/',
                             small=len(self.repo.forks),
                             extra_html_attrs=dict(rel='nofollow'))
            ]

        has_upstream_repo = False
        if self.repo.upstream_repo.name:
            try:
                self.repo.push_upstream_context()
            except Exception:
                log.warning('Could not get upstream repo (perhaps it is gone) for: %s %s',
                            self.repo, self.repo.upstream_repo.name, exc_info=True)
            else:
                has_upstream_repo = True

        if has_upstream_repo:
            repo_path_parts = self.repo.upstream_repo.name.strip(
                '/').split('/')
            links += [
                SitemapEntry('Clone of'),
                SitemapEntry('%s / %s' %
                             (repo_path_parts[1], repo_path_parts[-1]),
                             self.repo.upstream_repo.name)
            ]
            if not c.app.repo.is_empty() and has_access(c.app.repo, 'admin'):
                merge_url = c.app.url + 'request_merge'
                if getattr(c, 'revision', None):
                    merge_url = merge_url + '?branch=' + h.urlquote(c.revision)
                links.append(SitemapEntry('Request Merge', merge_url,
                             ui_icon=g.icons['merge'], extra_html_attrs=dict(rel='nofollow')
                                          ))
            pending_upstream_merges = self.repo.pending_upstream_merges()
            if pending_upstream_merges:
                links.append(SitemapEntry(
                    'Pending Merges',
                    self.repo.upstream_repo.name + 'merge-requests/',
                    small=pending_upstream_merges, extra_html_attrs=dict(rel='nofollow')))
        ref_url = self.repo.url_for_commit(
            self.default_branch_name, url_type='ref')
        branches = self.repo.get_branches()
        if branches:
            links.append(SitemapEntry('Branches'))
            for branch in branches:
                if branch.name == self.default_branch_name:
                    branches.remove(branch)
                    branches.insert(0, branch)
                    break
            max_branches = 10
            for branch in branches[:max_branches]:
                links.append(SitemapEntry(
                    branch.name,
                    h.urlquote(self.repo.url_for_commit(branch.name) + 'tree/'),
                    extra_html_attrs=dict(rel='nofollow')))
            if len(branches) > max_branches:
                links.append(
                    SitemapEntry(
                        'More Branches',
                        ref_url + 'branches/',
                        extra_html_attrs=dict(rel='nofollow')
                    ))
        elif not self.repo.is_empty():
            # SVN repos, for example, should have a sidebar link to get to the main view
            links.append(
                SitemapEntry('Browse Files', c.app.url, extra_html_attrs=dict(rel='nofollow'))
            )

        tags = self.repo.get_tags()
        if tags:
            links.append(SitemapEntry('Tags'))
            max_tags = 10
            for b in tags[:max_tags]:
                links.append(SitemapEntry(
                    b.name,
                    h.urlquote(self.repo.url_for_commit(b.name) + 'tree/'),
                    extra_html_attrs=dict(rel='nofollow')))
            if len(tags) > max_tags:
                links.append(
                    SitemapEntry(
                        'More Tags',
                        ref_url + 'tags/',
                        extra_html_attrs=dict(rel='nofollow')
                    ))
        return links