Replace delete reply page with Kotlin version
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / BookmarksPage.kt
1 package net.pterodactylus.sone.web
2
3 import net.pterodactylus.sone.data.Post
4 import net.pterodactylus.sone.web.page.FreenetRequest
5 import net.pterodactylus.util.collection.Pagination
6 import net.pterodactylus.util.template.Template
7 import net.pterodactylus.util.template.TemplateContext
8
9 /**
10  * Page that lets the user browse all his bookmarked posts.
11  */
12 class BookmarksPage(template: Template, webInterface: WebInterface): SoneTemplatePage("bookmarks.html", template, "Page.Bookmarks.Title", webInterface) {
13
14         override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) {
15                 webInterface.core.bookmarkedPosts.let { posts ->
16                         val pagination = Pagination<Post>(posts.filter { it.isLoaded }.sortedByDescending { it.time }, webInterface.core.preferences.postsPerPage)
17                         templateContext["pagination"] = pagination
18                         templateContext["posts"] = pagination.items
19                         templateContext["postsNotLoaded"] = posts.any { !it.isLoaded }
20                 }
21         }
22
23 }