X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FRescuePage.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FRescuePage.kt;h=b882ee6e29906ceb0b5bb2da2345fd9efbf7cc16;hp=0000000000000000000000000000000000000000;hb=2000b0561c6a7e4b1fbc6e452b89c9504b3b5d33;hpb=06c501b8fef03b648fd71eb55abc92833ef2fb8c diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/RescuePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/RescuePage.kt new file mode 100644 index 0000000..b882ee6 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/RescuePage.kt @@ -0,0 +1,32 @@ +package net.pterodactylus.sone.web.pages + +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 + +/** + * Page that lets the user control the rescue mode for a Sone. + */ +class RescuePage(template: Template, webInterface: WebInterface): + SoneTemplatePage("rescue.html", template, "Page.Rescue.Title", webInterface, true) { + + override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { + val soneRescuer = webInterface.core.getSoneRescuer(getCurrentSone(request.toadletContext)!!) + templateContext["soneRescuer"] = soneRescuer + if (request.isPOST) { + request.parameters["edition", 9]?.toIntOrNull()?.also { + if (it > -1) { + soneRescuer.setEdition(it.toLong()) + } + } + if (request.parameters["fetch", 8] == "true") { + soneRescuer.startNextFetch() + } + throw RedirectException("rescue.html") + } + } + +}