From 6f87b531e0bf13a96f4b596a36a098e9b8d3878a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 30 May 2012 13:39:49 +0200 Subject: [PATCH] Paginate images in gallery mode. --- src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java | 6 +++++- src/main/resources/templates/imageBrowser.html | 10 ++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java b/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java index 93d35b9..a6d3daf 100644 --- a/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java @@ -26,6 +26,8 @@ import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Image; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.page.FreenetRequest; +import net.pterodactylus.util.collection.Pagination; +import net.pterodactylus.util.number.Numbers; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; @@ -87,7 +89,9 @@ public class ImageBrowserPage extends SoneTemplatePage { albums.addAll(sone.getAllAlbums()); } Collections.sort(albums, Album.TITLE_COMPARATOR); - templateContext.set("albums", albums); + Pagination albumPagination = new Pagination(albums, 12).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0)); + templateContext.set("albumPagination", albumPagination); + templateContext.set("albums", albumPagination.getItems()); return; } Sone sone = getCurrentSone(request.getToadletContext(), false); diff --git a/src/main/resources/templates/imageBrowser.html b/src/main/resources/templates/imageBrowser.html index 55705e1..2d94de0 100644 --- a/src/main/resources/templates/imageBrowser.html +++ b/src/main/resources/templates/imageBrowser.html @@ -591,7 +591,10 @@ <%elseif galleryRequested> <%foreach albums album> - <%first>

<%= Page.ImageBrowser.Header.Albums|l10n|html>

<%/first> + <%first> +

<%= Page.ImageBrowser.Header.Albums|l10n|html>

+ <%include include/pagination.html pagination=albumPagination pageParameter=="page"> + <%/first> <%if loop.count|mod divisor=3>
<%/if>
@@ -613,7 +616,10 @@ <%= false|store key=endRow> <%if loop.count|mod divisor=3 offset=1><%= true|store key=endRow><%/if> <%last><%= true|store key=endRow><%/last> - <%if endRow>
<%/if> + <%if endRow> +
+ <%include include/pagination.html pagination=albumPagination pageParameter=="page"> + <%/if> <%/foreach> <%/if> -- 2.7.4