X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FViewPostPage.kt;h=04a60b08b214e3ca30c324297367693af0565d45;hp=457e13f0b749a7a9169492ee31b3c000adf902aa;hb=d14188d87056cfd63490ef9f16f4aae0c1864864;hpb=ffd92ca2374c0b2218e583d02e0bdd24b8c110ae diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt index 457e13f..04a60b0 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt @@ -1,29 +1,28 @@ package net.pterodactylus.sone.web.pages -import net.pterodactylus.sone.template.SoneAccessor -import net.pterodactylus.sone.utils.let -import net.pterodactylus.sone.utils.parameters -import net.pterodactylus.sone.web.WebInterface -import net.pterodactylus.sone.web.page.FreenetRequest -import net.pterodactylus.util.template.Template -import net.pterodactylus.util.template.TemplateContext -import java.net.URI +import net.pterodactylus.sone.template.* +import net.pterodactylus.sone.utils.* +import net.pterodactylus.sone.web.* +import net.pterodactylus.sone.web.page.* +import net.pterodactylus.util.template.* +import java.net.* +import javax.inject.* /** * This page lets the user view a post and all its replies. */ -class ViewPostPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("viewPost.html", template, "Page.ViewPost.Title", webInterface, false) { +class ViewPostPage @Inject constructor(template: Template, webInterface: WebInterface): + SoneTemplatePage("viewPost.html", webInterface, template, "Page.ViewPost.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { - templateContext["post"] = freenetRequest.parameters["post"].let(webInterface.core::getPost).orNull() + templateContext["post"] = freenetRequest.parameters["post"]?.let(webInterface.core::getPost) templateContext["raw"] = freenetRequest.parameters["raw"] == "true" } override fun isLinkExcepted(link: URI?) = true - public override fun getPageTitle(freenetRequest: FreenetRequest) = - (freenetRequest.parameters["post"].let(webInterface.core::getPost).let { + override fun getPageTitle(freenetRequest: FreenetRequest) = + (freenetRequest.parameters["post"]?.let(webInterface.core::getPost)?.let { if (it.text.length > 20) { it.text.substring(0..19) + "…" } else {