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=fd911ee4d3e9f439d95a53c3a2169dddb90d7b39;hp=027373f22c97aec8cbe3735527b97bf9d88d15cb;hb=cd72add62ab407336b471d4b7cda8e33dd2df5c6;hpb=acf40290db822d7cbdaed590850f692953f51ac1 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 027373f..fd911ee 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt @@ -7,7 +7,7 @@ import net.pterodactylus.sone.utils.mapPresent import net.pterodactylus.sone.utils.paginate import net.pterodactylus.sone.utils.parameters 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.TemplateContext import java.net.URI @@ -19,16 +19,16 @@ import javax.inject.Inject 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 -> + override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) { + templateContext["soneId"] = soneRequest.parameters["sone"] + soneRequest.parameters["sone"]!!.let(soneRequest.core::getSone)?.let { sone -> templateContext["sone"] = sone val sonePosts = sone.posts - val directedPosts = webInterface.core.getDirectedPosts(sone.id) + val directedPosts = soneRequest.core.getDirectedPosts(sone.id) (sonePosts + directedPosts) .sortedByDescending(Post::getTime) - .paginate(webInterface.core.preferences.postsPerPage) - .apply { page = freenetRequest.parameters["postPage"]?.toIntOrNull() ?: 0 } + .paginate(soneRequest.core.preferences.postsPerPage) + .apply { page = soneRequest.parameters["postPage"]?.toIntOrNull() ?: 0 } .also { templateContext["postPagination"] = it templateContext["posts"] = it.items @@ -38,9 +38,9 @@ class ViewSonePage @Inject constructor(template: Template, webInterface: WebInte .distinct() .minus(sonePosts) .minus(directedPosts) - .sortedByDescending { webInterface.core.getReplies(it.id).first().time } - .paginate(webInterface.core.preferences.postsPerPage) - .apply { page = freenetRequest.parameters["repliedPostPage"]?.toIntOrNull() ?: 0 } + .sortedByDescending { soneRequest.core.getReplies(it.id).first().time } + .paginate(soneRequest.core.preferences.postsPerPage) + .apply { page = soneRequest.parameters["repliedPostPage"]?.toIntOrNull() ?: 0 } .also { templateContext["repliedPostPagination"] = it templateContext["repliedPosts"] = it.items @@ -50,9 +50,9 @@ class ViewSonePage @Inject constructor(template: Template, webInterface: WebInte override fun isLinkExcepted(link: URI) = true - 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") + override fun getPageTitle(soneRequest: SoneRequest): String = + soneRequest.parameters["sone"]!!.let(soneRequest.core::getSone)?.let { sone -> + "${SoneAccessor.getNiceName(sone)} - ${soneRequest.l10n.getString("Page.ViewSone.Title")}" + } ?: soneRequest.l10n.getString("Page.ViewSone.Page.TitleWithoutSone") }