Move web pages to their own package
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / DeleteSonePage.kt
1 package net.pterodactylus.sone.web.pages
2
3 import net.pterodactylus.sone.utils.isPOST
4 import net.pterodactylus.sone.web.pages.SoneTemplatePage
5 import net.pterodactylus.sone.web.WebInterface
6 import net.pterodactylus.sone.web.page.FreenetRequest
7 import net.pterodactylus.util.template.Template
8 import net.pterodactylus.util.template.TemplateContext
9
10 /**
11  * Lets the user delete a Sone. Of course the Sone is not really deleted from
12  * Freenet; merely all references to it are removed from the local plugin
13  * installation.
14  */
15 class DeleteSonePage(template: Template, webInterface: WebInterface):
16                 SoneTemplatePage("deleteSone.html", template, "Page.DeleteSone.Title", webInterface, true) {
17
18         override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
19                 if (request.isPOST) {
20                         if (request.httpRequest.isPartSet("deleteSone")) {
21                                 webInterface.core.deleteSone(getCurrentSone(request.toadletContext))
22                         }
23                         throw RedirectException("index.html")
24                 }
25         }
26
27 }