1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.template.SoneAccessor
4 import net.pterodactylus.sone.utils.let
5 import net.pterodactylus.sone.utils.parameters
6 import net.pterodactylus.sone.web.WebInterface
7 import net.pterodactylus.sone.web.page.FreenetRequest
8 import net.pterodactylus.util.template.Template
9 import net.pterodactylus.util.template.TemplateContext
13 * This page lets the user view a post and all its replies.
15 class ViewPostPage(template: Template, webInterface: WebInterface):
16 SoneTemplatePage("viewPost.html", template, "Page.ViewPost.Title", webInterface, false) {
18 override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
19 templateContext["post"] = freenetRequest.parameters["post"]?.let(webInterface.core::getPost)
20 templateContext["raw"] = freenetRequest.parameters["raw"] == "true"
23 override fun isLinkExcepted(link: URI?) = true
25 public override fun getPageTitle(freenetRequest: FreenetRequest) =
26 (freenetRequest.parameters["post"]?.let(webInterface.core::getPost)?.let {
27 if (it.text.length > 20) {
28 it.text.substring(0..19) + "…"
31 } + " - ${SoneAccessor.getNiceName(it.sone)} - "
32 } ?: "") + super.getPageTitle(freenetRequest)