From: David ‘Bombe’ Roden Date: Thu, 13 Jan 2011 14:52:23 +0000 (+0100) Subject: Move the pagination out of the HTML. This fixes #51. X-Git-Tag: 0.3.7^2~4 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=a4ec77c6eb6d56e4ea7a8829ab50b199c18cbe87 Move the pagination out of the HTML. This fixes #51. --- diff --git a/src/main/java/net/pterodactylus/sone/web/IndexPage.java b/src/main/java/net/pterodactylus/sone/web/IndexPage.java index 825267b..b0a27f7 100644 --- a/src/main/java/net/pterodactylus/sone/web/IndexPage.java +++ b/src/main/java/net/pterodactylus/sone/web/IndexPage.java @@ -24,6 +24,8 @@ import java.util.List; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.util.collection.Pagination; +import net.pterodactylus.util.number.Numbers; import net.pterodactylus.util.template.DataProvider; import net.pterodactylus.util.template.Template; @@ -72,7 +74,9 @@ public class IndexPage extends SoneTemplatePage { } } Collections.sort(allPosts, Post.TIME_COMPARATOR); - dataProvider.set("posts", allPosts); + Pagination pagination = new Pagination(allPosts, 25).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0)); + dataProvider.set("pagination", pagination); + dataProvider.set("posts", pagination.getItems()); } /** diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 39d53f1..345f376 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -5,8 +5,6 @@

<%= Page.Index.PostList.Title|l10n|html>

- <%getpage> - <%paginate list=posts pagesize=25> <%= page|store key=pageParameter> <%include include/pagination.html> <%foreach pagination.items post>