From eecb3e46d0d97084e96f5fe70eed93fd59327d34 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 17 Jan 2011 10:55:52 +0100 Subject: [PATCH] =?utf8?q?Mark=20Sones=20as=20known=20on=20=E2=80=9Cview?= =?utf8?q?=20Sone=E2=80=9D=20and=20=E2=80=9Cknown=20Sones=E2=80=9D=20pages?= =?utf8?q?,=20move=20pagination=20out=20of=20HTML.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../net/pterodactylus/sone/web/KnownSonesPage.java | 19 ++++++++++++++++++- .../java/net/pterodactylus/sone/web/ViewSonePage.java | 1 + src/main/resources/templates/knownSones.html | 2 -- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java b/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java index 774f410..a2ebc66 100644 --- a/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java +++ b/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java @@ -22,6 +22,8 @@ import java.util.Collections; import java.util.List; 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; @@ -56,7 +58,22 @@ public class KnownSonesPage extends SoneTemplatePage { super.processTemplate(request, dataProvider); List knownSones = new ArrayList(webInterface.getCore().getSones()); Collections.sort(knownSones, Sone.NICE_NAME_COMPARATOR); - dataProvider.set("knownSones", knownSones); + Pagination sonePagination = new Pagination(knownSones, 25).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0)); + dataProvider.set("pagination", sonePagination); + dataProvider.set("knownSones", sonePagination.getItems()); + } + + /** + * {@inheritDoc} + */ + @Override + protected void postProcess(Request request, DataProvider dataProvider) { + super.postProcess(request, dataProvider); + @SuppressWarnings("unchecked") + List sones = (List) dataProvider.get("knownSones"); + for (Sone sone : sones) { + webInterface.getCore().markSoneKnown(sone); + } } } diff --git a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java index 9746afd..e9810a6 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java @@ -68,6 +68,7 @@ public class ViewSonePage extends SoneTemplatePage { if (sone == null) { return; } + webInterface.getCore().markSoneKnown(sone); List posts = sone.getPosts(); for (Post post : posts) { webInterface.getCore().markPostKnown(post); diff --git a/src/main/resources/templates/knownSones.html b/src/main/resources/templates/knownSones.html index f5907a0..33f0e27 100644 --- a/src/main/resources/templates/knownSones.html +++ b/src/main/resources/templates/knownSones.html @@ -5,8 +5,6 @@

<%= Page.KnownSones.Page.Title|l10n|html>

- <%getpage parameter=page> - <%paginate list=knownSones pagesize=25> <%= page|store key=pageParameter> <%include include/pagination.html> <%foreach pagination.items sone> -- 2.7.4