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