X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetReplyAjaxPage.kt;h=43960abcb834dbd04079147b3153b7e6259aebf9;hb=bf509980d5097e67d1a32f6b53bef052b396137f;hp=fc4b482a961a55574943bb0370e43164aa9356bd;hpb=4bf90851f9e7a8f31d4f58f4f74dc46d8e4ddec8;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt index fc4b482..43960ab 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt @@ -3,23 +3,25 @@ package net.pterodactylus.sone.web.ajax import net.pterodactylus.sone.data.PostReply import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.utils.jsonObject -import net.pterodactylus.sone.utils.let import net.pterodactylus.sone.utils.parameters import net.pterodactylus.sone.utils.render import net.pterodactylus.sone.web.WebInterface -import net.pterodactylus.sone.web.page.FreenetRequest +import net.pterodactylus.sone.web.page.* import net.pterodactylus.util.template.Template +import net.pterodactylus.util.template.TemplateContextFactory +import javax.inject.Inject /** * This AJAX page returns the details of a reply. */ -class GetReplyAjaxPage(webInterface: WebInterface, private val template: Template) : LoggedInJsonPage("getReply.ajax", webInterface) { +@ToadletPath("getReply.ajax") +class GetReplyAjaxPage @Inject constructor(webInterface: WebInterface, val templateContextFactory: TemplateContextFactory, private val template: Template) : LoggedInJsonPage(webInterface) { override val needsFormPassword = false override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["reply"] - .let(core::getPostReply) + ?.let(core::getPostReply) ?.let { it.toJson(currentSone, request) } ?.let { replyJson -> createSuccessJsonObject().apply { @@ -36,7 +38,7 @@ class GetReplyAjaxPage(webInterface: WebInterface, private val template: Templat ).toList().toTypedArray()) private fun PostReply.render(currentSone: Sone, request: FreenetRequest) = - webInterface.templateContextFactory.createTemplateContext().apply { + templateContextFactory.createTemplateContext().apply { set("core", core) set("request", request) set("reply", this@render)