X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FEditImagePage.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FEditImagePage.kt;h=76f6e23b711097cf9469099ba3afaae084858125;hp=350dec75c0c280cd84f909f3edc7d359f196c781;hb=03cec6a6772c2d836d94864adddaf544cbe9d72f;hpb=6f1f26e3998cfef155b0cf59152827accea70d30 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditImagePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditImagePage.kt index 350dec7..76f6e23 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditImagePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditImagePage.kt @@ -1,40 +1,42 @@ package net.pterodactylus.sone.web.pages -import net.pterodactylus.sone.data.Image.Modifier.ImageTitleMustNotBeEmpty -import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.text.TextFilter -import net.pterodactylus.sone.utils.isPOST -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.data.Image.Modifier.* +import net.pterodactylus.sone.main.* +import net.pterodactylus.sone.text.* +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 edit title and description of an {@link Image}. */ -class EditImagePage(template: Template, webInterface: WebInterface): - LoggedInPage("editImage.html", template, "Page.EditImage.Title", webInterface) { +@ToadletPath("editImage.html") +class EditImagePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : + LoggedInPage("Page.EditImage.Title", webInterface, loaders, templateRenderer) { - override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { - if (freenetRequest.isPOST) { - val image = webInterface.core.getImage(freenetRequest.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html") + override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) { + if (soneRequest.isPOST) { + val image = soneRequest.core.getImage(soneRequest.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html") if (!image.sone.isLocal) { throw RedirectException("noPermission.html") } - freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256).let { returnPage -> - if (freenetRequest.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") { + soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256).let { returnPage -> + if (soneRequest.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") { image.album.moveImageUp(image) - webInterface.core.touchConfiguration() - } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("moveRight", 4) == "true") { + soneRequest.core.touchConfiguration() + } else if (soneRequest.httpRequest.getPartAsStringFailsafe("moveRight", 4) == "true") { image.album.moveImageDown(image) - webInterface.core.touchConfiguration() + soneRequest.core.touchConfiguration() } else { try { image.modify() - .setTitle(freenetRequest.httpRequest.getPartAsStringFailsafe("title", 100)) - .setDescription(TextFilter.filter(freenetRequest.httpRequest.getHeader("Host"), freenetRequest.httpRequest.getPartAsStringFailsafe("description", 1024))) + .setTitle(soneRequest.httpRequest.getPartAsStringFailsafe("title", 100)) + .setDescription(TextFilter.filter(soneRequest.httpRequest.getHeader("Host"), soneRequest.httpRequest.getPartAsStringFailsafe("description", 1024))) .update() - webInterface.core.touchConfiguration() + soneRequest.core.touchConfiguration() } catch (e: ImageTitleMustNotBeEmpty) { throw RedirectException("emptyImageTitle.html") }