Mercurial > bitten > bitten-test
changeset 214:f0e37bee64c5
Paging on build configuration page. Closes #24.
author | cmlenz |
---|---|
date | Tue, 20 Sep 2005 23:03:03 +0000 |
parents | 25f84dd9f159 |
children | e4db8355497e |
files | bitten/trac_ext/templates/bitten_config.cs bitten/trac_ext/web_ui.py |
diffstat | 2 files changed, 44 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/bitten/trac_ext/templates/bitten_config.cs +++ b/bitten/trac_ext/templates/bitten_config.cs @@ -1,5 +1,23 @@ <?cs include:"header.cs" ?> - <div id="ctxtnav" class="nav"></div> + <div id="ctxtnav" class="nav"><?cs + if:page.mode == 'view_config' ?><?cs + with:links = chrome.links ?><?cs + if:len(links.prev) || len(links.next) ?><ul><?cs + if:len(links.prev) ?> + <li class="first<?cs if:!len(links.up) && !len(links.next) ?> last<?cs /if ?>"> + ← <a href="<?cs var:links.prev.0.href ?>"><?cs + var:links.prev.0.title ?></a> + </li><?cs + /if ?><?cs + if:len(links.next) ?> + <li class="<?cs if:!len(links.prev) && !len(links.up) ?>first <?cs /if ?>last"> + <a href="<?cs var:links.next.0.href ?>"><?cs + var:links.next.0.title ?></a> → + </li><?cs + /if ?></ul><?cs + /if ?><?cs + /with ?><?cs + /if ?></div> <div id="content" class="build"> <h1><?cs var:title ?></h1><?cs
--- a/bitten/trac_ext/web_ui.py +++ b/bitten/trac_ext/web_ui.py @@ -344,10 +344,15 @@ if charts_license: req.hdf['config.charts_license'] = escape(charts_license) + page = max(1, int(req.args.get('page', 1))) + more = False + req.hdf['page.number'] = page + repos = self.env.get_repository(req.authname) try: root = repos.get_node(config.path) - for idx, (path, rev, chg) in enumerate(root.get_history()): + idx = 0 + for path, rev, chg in root.get_history(): # Don't follow moves/copies if path != repos.normalize_path(config.path): break @@ -360,6 +365,10 @@ if is_empty: continue + if idx <= (page - 1) * 12: + idx += 1 + continue + prefix = 'config.builds.%d' % rev req.hdf[prefix + '.href'] = self.env.href.changeset(rev) for build in Build.select(self.env, config=config.name, rev=rev): @@ -367,8 +376,22 @@ continue build_hdf = _build_to_hdf(self.env, req, build) req.hdf['%s.%s' % (prefix, build.platform)] = build_hdf - if idx > 12: + + idx += 1 + if idx > page * 12: + more = True break + + if page > 1: + if page == 2: + prev_href = self.env.href.build(config.name) + else: + prev_href = self.env.href.build(config.name, page=page - 1) + add_link(req, 'prev', prev_href, 'Previous Page') + if more: + next_href = self.env.href.build(config.name, page=page + 1) + add_link(req, 'next', next_href, 'Next Page') + except TracError, e: self.log.error('Error accessing repository info', exc_info=True)