X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FNewPage.kt;h=070fc4ccfd7b67c4b99a80adf0f451a507158f2f;hb=fda2239d4bd30e90a397d4cc3726250270876856;hp=f572742760797e57aa05bb3c6e39b24455eb6d3a;hpb=a76956e389fcfe6282ad4ca7156bbf76327bb0c0;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/NewPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/NewPage.kt index f572742..070fc4c 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/NewPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/NewPage.kt @@ -1,11 +1,18 @@ package net.pterodactylus.sone.web.pages -import net.pterodactylus.sone.main.* -import net.pterodactylus.sone.utils.* -import net.pterodactylus.sone.web.* -import net.pterodactylus.sone.web.page.* -import net.pterodactylus.util.template.* -import javax.inject.* +import net.pterodactylus.sone.main.Loaders +import net.pterodactylus.sone.utils.mapPresent +import net.pterodactylus.sone.utils.paginate +import net.pterodactylus.sone.utils.parameters +import net.pterodactylus.sone.web.NewElements +import net.pterodactylus.sone.web.WebInterface +import net.pterodactylus.sone.web.page.MenuName +import net.pterodactylus.sone.web.page.SoneRequest +import net.pterodactylus.sone.web.page.TemplatePath +import net.pterodactylus.sone.web.page.TemplateRenderer +import net.pterodactylus.sone.web.page.ToadletPath +import net.pterodactylus.util.template.TemplateContext +import javax.inject.Inject /** * Page that displays all new posts and replies. The posts are filtered using @@ -13,12 +20,13 @@ import javax.inject.* */ @MenuName("New") @TemplatePath("/templates/new.html") -class NewPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer): - SoneTemplatePage("new.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.New.Title") { +@ToadletPath("new.html") +class NewPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer, private val newElements: NewElements) : + SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.New.Title") { override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) = getCurrentSone(soneRequest.toadletContext).let { currentSone -> - (soneRequest.webInterface.getNewPosts(currentSone) + soneRequest.webInterface.getNewReplies(currentSone).mapPresent { it.post }) + (newElements.newPosts() + newElements.newReplies().mapPresent { it.post }) .distinct() .sortedByDescending { it.time } .let { posts ->