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