X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetPostAjaxPage.kt;h=d5595d2ed4911d6943ae526f70de5bfbc78d6025;hp=1aedd493073d5d5c1d560e2497cf8bd2d0fe7220;hb=bf509980d5097e67d1a32f6b53bef052b396137f;hpb=fe880bd95f2f1bb155e890a9ffd2dc2abc86cb37 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 1aedd49..d5595d2 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt @@ -8,13 +8,14 @@ import net.pterodactylus.sone.utils.render import net.pterodactylus.sone.web.WebInterface 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]. */ @ToadletPath("getPost.ajax") -class GetPostAjaxPage @Inject constructor(webInterface: WebInterface, private val postTemplate: Template) : LoggedInJsonPage(webInterface) { +class GetPostAjaxPage @Inject constructor(webInterface: WebInterface, private val templateContextFactory: TemplateContextFactory, private val postTemplate: Template) : LoggedInJsonPage(webInterface) { override val needsFormPassword = false @@ -33,7 +34,7 @@ class GetPostAjaxPage @Inject constructor(webInterface: WebInterface, private va } ?: 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)