X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FUnbookmarkPage.kt;h=aed315f282f8d0a0a2a3a2fcdd90d0b3225e68ad;hp=ec4242b66fadeb87b13cee9d76da794883254ac7;hb=e3da46d8947ab8a542a156069b3b24c13fd011df;hpb=d63b7445567b65ffdbd50fa8f7ffbfea1304dff9 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt index ec4242b..aed315f 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt @@ -1,34 +1,32 @@ package net.pterodactylus.sone.web.pages -import net.pterodactylus.sone.data.Post -import net.pterodactylus.sone.utils.also -import net.pterodactylus.sone.utils.isGET -import net.pterodactylus.sone.utils.isPOST -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 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.* +import javax.inject.* /** * Page that lets the user unbookmark a post. */ -class UnbookmarkPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("unbookmark.html", webInterface, template, "Page.Unbookmark.Title") { +class UnbookmarkPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer): + SoneTemplatePage("unbookmark.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.Unbookmark.Title") { - override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) { when { - freenetRequest.isGET && (freenetRequest.parameters["post"] == "allNotLoaded") -> { - webInterface.core.bookmarkedPosts + soneRequest.isGET && (soneRequest.parameters["post"] == "allNotLoaded") -> { + soneRequest.core.bookmarkedPosts .filterNot(Post::isLoaded) - .forEach(webInterface.core::unbookmarkPost) + .forEach(soneRequest.core::unbookmarkPost) throw RedirectException("bookmarks.html") } - freenetRequest.isPOST -> { - freenetRequest.parameters["post", 36] - ?.let(webInterface.core::getPost) - ?.also(webInterface.core::unbookmarkPost) - throw RedirectException(freenetRequest.parameters["returnPage", 256]) + soneRequest.isPOST -> { + soneRequest.parameters["post", 36] + ?.let(soneRequest.core::getPost) + ?.also(soneRequest.core::unbookmarkPost) + throw RedirectException(soneRequest.parameters["returnPage", 256]) } } }