X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FImageBrowserPage.java;h=ea039ca5d2404199d4e1a02baf62e1e2cc5cb2e0;hb=d5efb086bee8f103cbe90c7a953ffbb7ff27b689;hp=a6d3dafc429c47dd78e758d884dad5329953de54;hpb=6f87b531e0bf13a96f4b596a36a098e9b8d3878a;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java b/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java index a6d3daf..ea039ca 100644 --- a/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java @@ -1,5 +1,5 @@ /* - * Sone - ImageBrowserPage.java - Copyright © 2011–2012 David Roden + * Sone - ImageBrowserPage.java - Copyright © 2011–2013 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,10 +27,12 @@ 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; +import com.google.common.base.Optional; +import com.google.common.primitives.Ints; + /** * The image browser page is the entry page for the image management. * @@ -65,6 +67,7 @@ public class ImageBrowserPage extends SoneTemplatePage { Album album = webInterface.getCore().getAlbum(albumId, false); templateContext.set("albumRequested", true); templateContext.set("album", album); + templateContext.set("page", request.getHttpRequest().getParam("page")); return; } String imageId = request.getHttpRequest().getParam("image", null); @@ -89,7 +92,7 @@ public class ImageBrowserPage extends SoneTemplatePage { albums.addAll(sone.getAllAlbums()); } Collections.sort(albums, Album.TITLE_COMPARATOR); - Pagination albumPagination = new Pagination(albums, 12).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0)); + Pagination albumPagination = new Pagination(albums, 12).setPage(Optional.fromNullable(Ints.tryParse(request.getHttpRequest().getParam("page"))).or(0)); templateContext.set("albumPagination", albumPagination); templateContext.set("albums", albumPagination.getItems()); return;