class fields(ew_core.NameList): page_list = ffw.PageList() page_size = ffw.PageSize()
class CommitBrowser(BaseController): TreeBrowserClass = None revision_widget = SCMRevisionWidget() log_widget = SCMLogWidget() page_list = ffw.PageList() DEFAULT_PAGE_LIMIT = 25 def __init__(self, revision): self._revision = revision self._commit = c.app.repo.commit(revision) c.revision = revision if self._commit is None: raise exc.HTTPNotFound @LazyProperty def tree(self): return self.TreeBrowserClass(self._commit, tree=self._commit.tree) @expose('jinja:allura:templates/repo/commit.html') @validate( dict(page=validators.Int(if_empty=0, if_invalid=0), limit=validators.Int(if_empty=DEFAULT_PAGE_LIMIT, if_invalid=DEFAULT_PAGE_LIMIT))) def index(self, page=0, limit=DEFAULT_PAGE_LIMIT, **kw): c.revision_widget = self.revision_widget c.page_list = self.page_list result = dict(commit=self._commit) if self._commit: result.update(self._commit.context()) tree = self._commit.tree limit, page, start = g.handle_paging(limit, page, default=self.DEFAULT_PAGE_LIMIT) diffs = self._commit.paged_diffs(start=start, end=start + limit, onlyChangedFiles=True) result['artifacts'] = [] for t in ('added', 'removed', 'changed', 'copied', 'renamed'): for f in diffs[t]: if t in ('copied', 'renamed'): filepath = f['new'] else: filepath = f is_text = filepath and tree.get_blob_by_path( filepath) and tree.get_blob_by_path(filepath).has_html_view result['artifacts'].append( (t, f, 'blob' if tree.get_blob_by_path(f) else 'tree', is_text)) count = diffs['total'] result.update(dict(page=page, limit=limit, count=count)) # Sort the result['artifacts'] which is in format as below - # [('added', u'aaa.txt', 'blob', True), # ('added', u'eee.txt', 'blob', True), # ('added', u'ggg.txt', 'blob', True), # ('removed', u'bbb.txt', 'tree', None), # ('removed', u'ddd.txt', 'tree', None), # ('changed', u'ccc.txt', 'blob', True)] result['artifacts'].sort( key=lambda x: x[1]['old'] if (isinstance(x[1], dict)) else x[1]) return result @expose('jinja:allura:templates/repo/commit_basic.html') def basic(self, **kw): c.revision_widget = self.revision_widget result = dict(commit=self._commit) if self._commit: result.update(self._commit.context()) return result @expose('jinja:allura:templates/repo/tarball.html') def tarball(self, **kw): path = request.params.get('path') if not asbool(tg.config.get('scm.repos.tarball.enable', False)): raise exc.HTTPNotFound() rev = self._commit.url().split('/')[-2] status = c.app.repo.get_tarball_status(rev, path) if not status and request.method == 'POST': allura.tasks.repo_tasks.tarball.post(rev, path) redirect( 'tarball?path={0}'.format(h.urlquote(path) if path else '')) return dict(commit=self._commit, revision=rev, status=status) @expose('json:') def tarball_status(self, path=None, **kw): if not asbool(tg.config.get('scm.repos.tarball.enable', False)): raise exc.HTTPNotFound() rev = self._commit.url().split('/')[-2] return dict(status=c.app.repo.get_tarball_status(rev, path)) @expose('jinja:allura:templates/repo/log.html') @with_trailing_slash @validate( dict(page=validators.Int(if_empty=0, if_invalid=0), limit=validators.Int(if_empty=0, if_invalid=0))) def log(self, limit=0, path=None, **kw): if not limit: limit = int(tg.config.get('scm.view.log.limit', 25)) is_file = False if path: is_file = c.app.repo.is_file(path, self._commit._id) limit, _ = h.paging_sanitizer(limit, 0) commits = list( c.app.repo.log(revs=self._commit._id, path=path, id_only=False, limit=limit + 1)) # get an extra one to check for a next commit next_commit = None if len(commits) > limit: next_commit = commits.pop() c.log_widget = self.log_widget return dict(username=c.user._id and c.user.username, branch=None, log=commits, next_commit=next_commit, limit=limit, path=path, is_file=is_file, **kw)
class Thread(HierWidget): template = 'jinja:allura:templates/widgets/thread_widget.html' name = 'thread' defaults = dict(HierWidget.defaults, value=None, page=None, limit=50, count=None, show_subject=False, new_post_text='+ New Comment') widgets = dict(page_list=ffw.PageList(), thread_header=ThreadHeader(), post_thread=PostThread(), post=Post(), edit_post=EditPost(submit_text='Submit')) def resources(self): for r in super(Thread, self).resources(): yield r for w in self.widgets.itervalues(): for r in w.resources(): yield r yield ew.JSScript(''' $(document).ready(function () { var thread_tag = $('a.thread_tag'); var thread_spam = $('a.sidebar_thread_spam'); var tag_thread_holder = $('#tag_thread_holder'); var allow_moderate = $('#allow_moderate'); var mod_thread_link = $('#mod_thread_link'); var mod_thread_form = $('#mod_thread_form'); if (mod_thread_link.length) { if (mod_thread_form.length) { mod_thread_link.click(function (e) { mod_thread_form.toggle(); return false; }); } } if (thread_tag.length) { if (tag_thread_holder.length) { var submit_button = $('input[type="submit"]', tag_thread_holder); var cancel_button = $('<a href="#" class="btn link">Cancel</a>').click(function(evt){ evt.preventDefault(); tag_thread_holder.hide(); thread_tag.removeClass('active'); }); submit_button.after(cancel_button); thread_tag.click(function (e) { tag_thread_holder.show(); thread_tag.addClass('active'); // focus the submit to scroll to the form, then focus the subject for them to start typing submit_button.focus(); $('input[type="text"]', tag_thread_holder).focus(); return false; }); } } if (thread_spam.length) { if (allow_moderate.length) { thread_spam[0].style.display='block'; } } }); ''')
class W: search_results = SearchResults() search_help = SearchHelp(comments=False, history=False) page_list = ffw.PageList() page_size = ffw.PageSize() short_url_lightbox = suw.ShortUrlFormWidget()
class fields(ew_core.NameList): threads = _ThreadsTable() page_list = ffw.PageList() page_size = ffw.PageSize()
class fields(ew_core.NameList): # Careful! using the same name as the prop on the model will invoke the RelationalProperty, # causing all related entities to be (re)fetched. _threads = _ThreadsTable() page_list = ffw.PageList() page_size = ffw.PageSize()
class CommitBrowser(BaseController): TreeBrowserClass=None revision_widget = SCMRevisionWidget() log_widget=SCMLogWidget() page_list=ffw.PageList() DEFAULT_PAGE_LIMIT = 25 def __init__(self, revision): self._revision = revision self._commit = c.app.repo.commit(revision) c.revision = revision if self._commit is None: raise exc.HTTPNotFound self.tree = self.TreeBrowserClass(self._commit, tree=self._commit.tree) @expose('jinja:allura:templates/repo/commit.html') @validate(dict(page=validators.Int(if_empty=0), limit=validators.Int(if_empty=DEFAULT_PAGE_LIMIT))) def index(self, page=0, limit=DEFAULT_PAGE_LIMIT, **kw): c.revision_widget = self.revision_widget c.page_list = self.page_list result = dict(commit=self._commit) if self._commit: result.update(self._commit.context()) tree = self._commit.tree limit, page, start = g.handle_paging(limit, page, default=self.DEFAULT_PAGE_LIMIT) diffs = self._commit.paged_diffs(start=start, end=start+limit) result['artifacts'] = [ (t,f) for t in ('added', 'removed', 'changed', 'copied') for f in diffs[t] if t == 'removed' or tree.get_blob_by_path(f)] count = diffs['total'] result.update(dict(page=page, limit=limit, count=count)) return result @expose('jinja:allura:templates/repo/commit_basic.html') def basic(self, **kw): c.revision_widget = self.revision_widget result = dict(commit=self._commit) if self._commit: result.update(self._commit.context()) return result @expose('jinja:allura:templates/repo/tarball.html') def tarball(self, **kw): path = request.params.get('path') if not asbool(tg.config.get('scm.repos.tarball.enable', False)): raise exc.HTTPNotFound() rev = self._commit.url().split('/')[-2] status = c.app.repo.get_tarball_status(rev, path) if status is None and request.method == 'POST': allura.tasks.repo_tasks.tarball.post(revision=rev, path=path) redirect('tarball' + '?path={0}'.format(path) if path else '') return dict(commit=self._commit, revision=rev, status=status or 'na') @expose('json:') def tarball_status(self, path=None, **kw): if not asbool(tg.config.get('scm.repos.tarball.enable', False)): raise exc.HTTPNotFound() rev = self._commit.url().split('/')[-2] return dict(status=c.app.repo.get_tarball_status(rev, path) or 'na') @expose('jinja:allura:templates/repo/log.html') @with_trailing_slash @validate(dict(page=validators.Int(if_empty=0), limit=validators.Int(if_empty=25))) def log(self, limit=25, path=None, **kw): is_file = False if path: is_file = c.app.repo.is_file(path, self._commit._id) commits = list(islice(c.app.repo.log( revs=self._commit._id, path=path, id_only=False, page_size=limit+1), limit+1)) next_commit = None if len(commits) > limit: next_commit = commits.pop() c.log_widget = self.log_widget return dict( username=c.user._id and c.user.username, branch=None, log=commits, next_commit=next_commit, limit=limit, path=path, is_file=is_file, **kw)
class W: page_list = ffw.PageList() page_size = ffw.PageSize() audit = AuditLog() admin_search_form = forms.AdminSearchForm
class fields(ew_core.NameList): forums = _ForumsTable() page_list = ffw.PageList()
class fields(ew_core.NameList): page_list = ffw.PageList() page_size = ffw.PageSize() lightbox = ffw.Lightbox(name='col_list', trigger='#col_menu')
class W: page_list = ffw.PageList() page_size = ffw.PageSize()
class CommitBrowser(BaseController): TreeBrowserClass=None revision_widget = SCMRevisionWidget() log_widget=SCMLogWidget() page_list=ffw.PageList() DEFAULT_PAGE_LIMIT = 25 def __init__(self, revision): self._revision = revision self._commit = c.app.repo.commit(revision) if self._commit is None: raise exc.HTTPNotFound self.tree = self.TreeBrowserClass(self._commit, tree=self._commit.tree) @expose('jinja:allura:templates/repo/commit.html') @validate(dict(page=validators.Int(if_empty=0), limit=validators.Int(if_empty=DEFAULT_PAGE_LIMIT))) def index(self, page=0, limit=DEFAULT_PAGE_LIMIT): c.revision_widget = self.revision_widget c.page_list = self.page_list result = dict(commit=self._commit) if self._commit: result.update(self._commit.context()) tree = self._commit.tree limit, page, start = g.handle_paging(limit, page, default=self.DEFAULT_PAGE_LIMIT) result['artifacts'] = [ (t,f) for t in ('added', 'removed', 'changed', 'copied') for f in self._commit.diffs[t] if t == 'removed' or tree.get_blob_by_path(f)] count = len(result['artifacts']) result['artifacts'] = result['artifacts'][start:start+limit] result.update(dict(page=page, limit=limit, count=count)) return result @expose('jinja:allura:templates/repo/commit_basic.html') def basic(self): c.revision_widget = self.revision_widget result = dict(commit=self._commit) if self._commit: result.update(self._commit.context()) return result @expose('jinja:allura:templates/repo/log.html') @with_trailing_slash @validate(dict(page=validators.Int(if_empty=0), limit=validators.Int(if_empty=25))) def log(self, limit=25, page=0, **kw): limit, page, start = g.handle_paging(limit, page, default=25) revisions = c.app.repo.log( branch=self._commit._id, offset=start, limit=limit) count = c.app.repo.count(branch=self._commit._id) c.log_widget = self.log_widget return dict( username=c.user._id and c.user.username, branch=None, log=revisions, page=page, limit=limit, count=count, **kw)