You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/01/23 18:30:02 UTC
[20/28] git commit: [#4257] Added basic paging to Activity page
[#4257] Added basic paging to Activity page
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/28f74b11
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/28f74b11
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/28f74b11
Branch: refs/heads/cj/4257
Commit: 28f74b117b018468a80558824601a085afd2cb90
Parents: 88b2500
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Sat Jan 18 00:46:57 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Jan 23 17:26:26 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/widgets/form_fields.py | 14 +++++++++++++-
Allura/allura/templates/widgets/page_list.html | 6 ++++--
ForgeActivity/forgeactivity/main.py | 13 +++++++++++--
ForgeActivity/forgeactivity/templates/index.html | 1 +
4 files changed, 29 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/28f74b11/Allura/allura/lib/widgets/form_fields.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/form_fields.py b/Allura/allura/lib/widgets/form_fields.py
index 2249372..e3060dc 100644
--- a/Allura/allura/lib/widgets/form_fields.py
+++ b/Allura/allura/lib/widgets/form_fields.py
@@ -285,7 +285,9 @@ class PageList(ew_core.Widget):
limit=None,
count=0,
page=0,
- show_label=False)
+ show_label=True,
+ show_if_single_page=False,
+ force_next=False)
def paginator(self, count, page, limit, zero_based_pages=True):
page_offset = 1 if zero_based_pages else 0
@@ -298,6 +300,16 @@ class PageList(ew_core.Widget):
return paginate.Page(range(count), page + page_offset, int(limit),
url=page_url)
+ def prepare_context(self, context):
+ context = super(PageList, self).prepare_context(context)
+ count = context['count']
+ page = context['page']
+ limit = context['limit']
+ context['paginator'] = self.paginator(count, page, limit)
+ if context['force_next']:
+ context['paginator'].next_page = context['paginator'].page + 1
+ return context
+
def resources(self):
yield ew.CSSLink('css/page_list.css')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/28f74b11/Allura/allura/templates/widgets/page_list.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/page_list.html b/Allura/allura/templates/widgets/page_list.html
index a5f39b2..64ff18f 100644
--- a/Allura/allura/templates/widgets/page_list.html
+++ b/Allura/allura/templates/widgets/page_list.html
@@ -18,8 +18,10 @@
-#}
<div>
<div class="page_list">
- {% set paginator = widget.paginator(count, page, limit) %}
- {{paginator.pager('$link_first $link_previous ~2~ $link_next $link_last (Page $page of $page_count)')}}
+ {{paginator.pager(
+ format='$link_first $link_previous ~2~ $link_next $link_last' + (show_label and ' (Page $page of $page_count)' or ''),
+ show_if_single_page=show_if_single_page
+ )}}
</div>
<div class="clear"></div>
</div>
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/28f74b11/ForgeActivity/forgeactivity/main.py
----------------------------------------------------------------------
diff --git a/ForgeActivity/forgeactivity/main.py b/ForgeActivity/forgeactivity/main.py
index da81307..991bb61 100644
--- a/ForgeActivity/forgeactivity/main.py
+++ b/ForgeActivity/forgeactivity/main.py
@@ -22,7 +22,7 @@ from pylons import tmpl_context as c, app_globals as g
from pylons import request, response
from tg import expose, validate, config
from tg.decorators import with_trailing_slash, without_trailing_slash
-from paste.deploy.converters import asbool
+from paste.deploy.converters import asbool, asint
from webob import exc
from webhelpers import feedgenerator as FG
@@ -33,6 +33,7 @@ from allura.lib.security import require_authenticated
from allura.model.timeline import perm_check
from allura.lib import helpers as h
from allura.lib.decorators import require_post
+from allura.lib.widgets.form_fields import PageList
from allura.ext.user_profile import ProfileSectionBase
from .widgets.follow import FollowToggle
@@ -65,6 +66,7 @@ class ForgeActivityApp(Application):
class W:
follow_toggle = FollowToggle()
+ page_list = PageList()
class ForgeActivityController(BaseController):
@@ -91,6 +93,7 @@ class ForgeActivityController(BaseController):
raise exc.HTTPNotFound()
c.follow_toggle = W.follow_toggle
+ c.page_list = W.page_list
if c.project.is_user_project:
followee = c.project.user_project_of
actor_only = followee != c.user
@@ -103,7 +106,13 @@ class ForgeActivityController(BaseController):
limit=kw.get('limit', 100),
actor_only=actor_only,
filter_func=perm_check(c.user))
- return dict(followee=followee, following=following, timeline=timeline)
+ return dict(
+ followee=followee,
+ following=following,
+ timeline=timeline,
+ page=asint(kw.get('page', 0)),
+ limit=asint(kw.get('limit', 100)),
+ )
@expose('jinja:forgeactivity:templates/index.html')
@with_trailing_slash
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/28f74b11/ForgeActivity/forgeactivity/templates/index.html
----------------------------------------------------------------------
diff --git a/ForgeActivity/forgeactivity/templates/index.html b/ForgeActivity/forgeactivity/templates/index.html
index 435fc82..e63c904 100644
--- a/ForgeActivity/forgeactivity/templates/index.html
+++ b/ForgeActivity/forgeactivity/templates/index.html
@@ -57,6 +57,7 @@
{% endif %}
</li>
{% endfor %}
+ {{c.page_list.display(limit=1, page=page, count=page+1, show_label=False, show_if_single_page=True, force_next=True)}}
</ul>
{% endif %}
</div>