X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FImageBrowserPage.kt;h=bf1ed2a7e4422fc85eadfd6581192041de7cc0f6;hp=31813551d5017e26261ba2f5467267005217a0d4;hb=d4d31bed957e29d50bd313ab973a034eba5a07f3;hpb=ffd92ca2374c0b2218e583d02e0bdd24b8c110ae diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt index 3181355..bf1ed2a 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt @@ -2,7 +2,7 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.sone.data.Album import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.utils.Pagination +import net.pterodactylus.sone.utils.paginate import net.pterodactylus.sone.utils.parameters import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest @@ -14,9 +14,9 @@ import java.net.URI * The image browser page is the entry page for the image management. */ class ImageBrowserPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("imageBrowser.html", template, "Page.ImageBrowser.Title", webInterface, true) { + LoggedInPage("imageBrowser.html", template, "Page.ImageBrowser.Title", webInterface) { - override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { if ("album" in freenetRequest.parameters) { templateContext["albumRequested"] = true templateContext["album"] = webInterface.core.getAlbum(freenetRequest.parameters["album"]!!) @@ -33,14 +33,16 @@ class ImageBrowserPage(template: Template, webInterface: WebInterface): .filterNot(Album::isEmpty) .sortedBy(Album::getTitle) .also { albums -> - Pagination(albums, webInterface.core.preferences.imagesPerPage).apply { page = freenetRequest.parameters["page"]?.toIntOrNull() ?: 0 }.also { pagination -> + albums.paginate(webInterface.core.preferences.imagesPerPage) + .turnTo(freenetRequest.parameters["page"]?.toIntOrNull() ?: 0) + .also { pagination -> templateContext["albumPagination"] = pagination templateContext["albums"] = pagination.items } } } else { templateContext["soneRequested"] = true - templateContext["sone"] = webInterface.core.getSone(freenetRequest.httpRequest.getParam("sone")).orNull() ?: getCurrentSone(freenetRequest.toadletContext) + templateContext["sone"] = webInterface.core.getSone(freenetRequest.httpRequest.getParam("sone")) ?: currentSone } }