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