Remove obsolete loading animation
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / BookmarkPage.kt
1 package net.pterodactylus.sone.web
2
3 import net.pterodactylus.sone.utils.isPOST
4 import net.pterodactylus.sone.web.page.FreenetRequest
5 import net.pterodactylus.util.template.Template
6 import net.pterodactylus.util.template.TemplateContext
7
8 /**
9  * Page that lets the user bookmark a post.
10  */
11 class BookmarkPage(template: Template, webInterface: WebInterface)
12         : SoneTemplatePage("bookmark.html", template, "Page.Bookmark.Title", webInterface) {
13
14         override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
15                 if (freenetRequest.isPOST) {
16                         val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
17                         val postId = freenetRequest.httpRequest.getPartAsStringFailsafe("post", 36)
18                         webInterface.core.getPost(postId).orNull()?.let {
19                                 webInterface.core.bookmarkPost(it)
20                         }
21                         throw RedirectException(returnPage)
22                 }
23         }
24
25 }