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=20219d747c379f1502b2fdfecb7b1017c7063628;hp=d7714cd79ca64a3d85974f2da90a718a5a5d5205;hb=HEAD;hpb=cd72add62ab407336b471d4b7cda8e33dd2df5c6 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 d7714cd..a0ca0d7 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt @@ -1,21 +1,22 @@ package net.pterodactylus.sone.web.pages -import net.pterodactylus.sone.data.Album -import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.utils.paginate -import net.pterodactylus.sone.utils.parameters -import net.pterodactylus.sone.web.WebInterface +import net.pterodactylus.sone.data.* +import net.pterodactylus.sone.main.* +import net.pterodactylus.sone.utils.* +import net.pterodactylus.sone.web.* import net.pterodactylus.sone.web.page.* -import net.pterodactylus.util.template.Template -import net.pterodactylus.util.template.TemplateContext -import java.net.URI -import javax.inject.Inject +import net.pterodactylus.util.template.* +import java.net.* +import javax.inject.* /** * The image browser page is the entry page for the image management. */ -class ImageBrowserPage @Inject constructor(template: Template, webInterface: WebInterface): - LoggedInPage("imageBrowser.html", template, "Page.ImageBrowser.Title", webInterface) { +@MenuName("ImageBrowser") +@TemplatePath("/templates/imageBrowser.html") +@ToadletPath("imageBrowser.html") +class ImageBrowserPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : + LoggedInPage("Page.ImageBrowser.Title", webInterface, loaders, templateRenderer) { override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) { if ("album" in soneRequest.parameters) { @@ -28,18 +29,16 @@ class ImageBrowserPage @Inject constructor(template: Template, webInterface: Web } else if (soneRequest.parameters["mode"] == "gallery") { templateContext["galleryRequested"] = true soneRequest.core.sones - .map(Sone::getRootAlbum) - .flatMap(Album::getAlbums) - .flatMap { Album.FLATTENER.apply(it)!! } + .flatMap(Sone::allAlbums) .filterNot(Album::isEmpty) .sortedBy(Album::getTitle) .also { albums -> albums.paginate(soneRequest.core.preferences.imagesPerPage) .turnTo(soneRequest.parameters["page"]?.toIntOrNull() ?: 0) .also { pagination -> - templateContext["albumPagination"] = pagination - templateContext["albums"] = pagination.items - } + templateContext["albumPagination"] = pagination + templateContext["albums"] = pagination.items + } } } else { templateContext["soneRequested"] = true