From: David ‘Bombe’ Roden Date: Mon, 17 Jan 2011 09:55:52 +0000 (+0100) Subject: Mark Sones as known on “view Sone” and “known Sones” pages, move pagination out of... X-Git-Tag: 0.4.2^2~27^2~11 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=eecb3e46d0d97084e96f5fe70eed93fd59327d34;p=Sone.git Mark Sones as known on “view Sone” and “known Sones” pages, move pagination out of HTML. --- 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>