X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetPostAjaxPage.kt;h=d5595d2ed4911d6943ae526f70de5bfbc78d6025;hb=bf509980d5097e67d1a32f6b53bef052b396137f;hp=d91fe90b409f03eaa0657009dbc8f904a8895e91;hpb=6f1f26e3998cfef155b0cf59152827accea70d30;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt index d91fe90..d5595d2 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt @@ -3,17 +3,19 @@ package net.pterodactylus.sone.web.ajax import net.pterodactylus.sone.data.Post 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 handler retrieves information and rendered representation of a [Post]. */ -class GetPostAjaxPage(webInterface: WebInterface, private val postTemplate: Template) : LoggedInJsonPage("getPost.ajax", webInterface) { +@ToadletPath("getPost.ajax") +class GetPostAjaxPage @Inject constructor(webInterface: WebInterface, private val templateContextFactory: TemplateContextFactory, private val postTemplate: Template) : LoggedInJsonPage(webInterface) { override val needsFormPassword = false @@ -32,7 +34,7 @@ class GetPostAjaxPage(webInterface: WebInterface, private val postTemplate: Temp } ?: createErrorJsonObject("invalid-post-id") private fun Post.render(currentSone: Sone, request: FreenetRequest) = - webInterface.templateContextFactory.createTemplateContext().apply { + templateContextFactory.createTemplateContext().apply { set("core", core) set("request", request) set("post", this@render)