1 package net.pterodactylus.sone.web
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
10 * Page that lets the user browse all his bookmarked posts.
12 class BookmarksPage(template: Template, webInterface: WebInterface): SoneTemplatePage("bookmarks.html", template, "Page.Bookmarks.Title", webInterface) {
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 }