Slightly improve CSS of linked HTML pages
[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.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
10
11 /**
12  * Page that lets the user browse all his bookmarked posts.
13  */
14 class BookmarksPage(template: Template, webInterface: WebInterface): SoneTemplatePage("bookmarks.html", template, "Page.Bookmarks.Title", webInterface) {
15
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 }
22                 }
23         }
24
25 }