1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.main.*
4 import net.pterodactylus.sone.template.*
5 import net.pterodactylus.sone.utils.*
6 import net.pterodactylus.sone.web.*
7 import net.pterodactylus.sone.web.page.*
8 import net.pterodactylus.util.template.*
13 * This page lets the user view a post and all its replies.
15 @TemplatePath("/templates/viewPost.html")
16 @ToadletPath("viewPost.html")
17 class ViewPostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
18 SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.ViewPost.Title") {
20 override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
21 templateContext["post"] = soneRequest.parameters["post"]?.let(soneRequest.core::getPost)
22 templateContext["raw"] = soneRequest.parameters["raw"] == "true"
25 override fun isLinkExcepted(link: URI) = true
27 override fun getPageTitle(soneRequest: SoneRequest) =
28 (soneRequest.parameters["post"]?.let(soneRequest.core::getPost)?.let {
29 if (it.text.length > 20) {
30 it.text.substring(0..19) + "…"
33 } + " - ${SoneAccessor.getNiceName(it.sone)} - "
34 } ?: "") + super.getPageTitle(soneRequest)