🔥 Remove trust settings from options page
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / pages / BookmarksPage.kt
1 package net.pterodactylus.sone.web.pages
2
3 import net.pterodactylus.sone.data.*
4 import net.pterodactylus.sone.main.*
5 import net.pterodactylus.sone.utils.*
6 import net.pterodactylus.sone.web.*
7 import net.pterodactylus.sone.web.page.*
8 import net.pterodactylus.util.template.*
9 import javax.inject.*
10
11 /**
12  * Page that lets the user browse all his bookmarked posts.
13  */
14 @MenuName("Bookmarks")
15 @TemplatePath("/templates/bookmarks.html")
16 @ToadletPath("bookmarks.html")
17 class BookmarksPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
18                 SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.Bookmarks.Title") {
19
20         override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
21                 soneRequest.core.bookmarkedPosts.let { posts ->
22                         val pagination = posts.filter(Post::isLoaded).sortedByDescending { it.time }.paginate(soneRequest.core.preferences.postsPerPage)
23                         templateContext["pagination"] = pagination
24                         templateContext["posts"] = pagination.items
25                         templateContext["postsNotLoaded"] = posts.any { !it.isLoaded }
26                 }
27         }
28
29 }