X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FViewSonePage.kt;h=145be72eda6e51ca5e9dec4a9dbee1174fe47c52;hp=90bc1474900f249ab25fe6b30f865b1949b9fc68;hb=74a72a878cc5a6fe5805b3656c0ff6b726002124;hpb=3cb0e2c78bb37f2d70ecde92ad4fcf642de788a3 diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt index 90bc147..145be72 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt @@ -3,7 +3,6 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.sone.data.Post import net.pterodactylus.sone.data.PostReply import net.pterodactylus.sone.template.SoneAccessor -import net.pterodactylus.sone.utils.let import net.pterodactylus.sone.utils.mapPresent import net.pterodactylus.sone.utils.paginate import net.pterodactylus.sone.utils.parameters @@ -12,16 +11,17 @@ import net.pterodactylus.sone.web.page.FreenetRequest import net.pterodactylus.util.template.Template import net.pterodactylus.util.template.TemplateContext import java.net.URI +import javax.inject.Inject /** * Lets the user browser another Sone. */ -class ViewSonePage(template: Template, webInterface: WebInterface): - SoneTemplatePage("viewSone.html", template, webInterface, false) { +class ViewSonePage @Inject constructor(template: Template, webInterface: WebInterface): + SoneTemplatePage("viewSone.html", webInterface, template) { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { templateContext["soneId"] = freenetRequest.parameters["sone"] - freenetRequest.parameters["sone"].let(webInterface.core::getSone).let { sone -> + freenetRequest.parameters["sone"]!!.let(webInterface.core::getSone)?.let { sone -> templateContext["sone"] = sone val sonePosts = sone.posts val directedPosts = webInterface.core.getDirectedPosts(sone.id) @@ -50,8 +50,8 @@ class ViewSonePage(template: Template, webInterface: WebInterface): override fun isLinkExcepted(link: URI?) = true - public override fun getPageTitle(freenetRequest: FreenetRequest): String = - freenetRequest.parameters["sone"].let(webInterface.core::getSone).let { sone -> + override fun getPageTitle(freenetRequest: FreenetRequest): String = + freenetRequest.parameters["sone"]!!.let(webInterface.core::getSone)?.let { sone -> "${SoneAccessor.getNiceName(sone)} - ${webInterface.l10n.getString("Page.ViewSone.Title")}" } ?: webInterface.l10n.getString("Page.ViewSone.Page.TitleWithoutSone")