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=6bbde00d30115018c7968a94aa87af74b8ccae02;hp=e9911e6ab58a95c50ab8a08667e8050fe10a1c59;hb=7782e25c429298770736a86146b57fea506e6ba0;hpb=6f1f26e3998cfef155b0cf59152827accea70d30 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 e9911e6..6bbde00 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt @@ -2,18 +2,19 @@ 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 import net.pterodactylus.util.template.Template import net.pterodactylus.util.template.TemplateContext import java.net.URI +import javax.inject.Inject /** * The image browser page is the entry page for the image management. */ -class ImageBrowserPage(template: Template, webInterface: WebInterface): +class ImageBrowserPage @Inject constructor(template: Template, webInterface: WebInterface): LoggedInPage("imageBrowser.html", template, "Page.ImageBrowser.Title", webInterface) { override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { @@ -33,7 +34,9 @@ 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 }