import net.pterodactylus.sone.data.Post;
import net.pterodactylus.util.collection.Pagination;
+import net.pterodactylus.util.filter.Filter;
+import net.pterodactylus.util.filter.Filters;
import net.pterodactylus.util.number.Numbers;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
@Override
protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
- Set<Post> posts = webInterface.getCore().getBookmarkedPosts();
- List<Post> sortedPosts = new ArrayList<Post>(posts);
+ Set<Post> allPosts = webInterface.getCore().getBookmarkedPosts();
+ Set<Post> loadedPosts = Filters.filteredSet(allPosts, new Filter<Post>() {
+
+ @Override
+ public boolean filterObject(Post post) {
+ return post.getSone() != null;
+ }
+ });
+ List<Post> sortedPosts = new ArrayList<Post>(loadedPosts);
Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
Pagination<Post> pagination = new Pagination<Post>(sortedPosts, 25).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0));
templateContext.set("pagination", pagination);
templateContext.set("posts", pagination.getItems());
+ templateContext.set("postsNotLoaded", allPosts.size() != loadedPosts.size());
}
}
Page.Bookmarks.Title=Bookmarks - Sone
Page.Bookmarks.Page.Title=Bookmarks
Page.Bookmarks.Text.NoBookmarks=You don’t have any bookmarks defined right now. You can bookmark posts by clicking the star below the post.
-Page.Bookmarks.Text.PostsNotLoaded=Some of your bookmarked posts have not been shown because they could not be loaded. This can happen if your restarted Sone recently or if the originating Sone has deleted the post.
+Page.Bookmarks.Text.PostsNotLoaded=Some of your bookmarked posts have not been shown because they could not be loaded. This can happen if you restarted Sone recently or if the originating Sone has deleted the post. If you are reasonable sure that these posts do not exist anymore, you can {link}unbookmark them{/link}.
Page.NoPermission.Title=Unauthorized Access - Sone
Page.NoPermission.Page.Title=Unauthorized Access
<div id="posts">
<%include include/pagination.html>
<%foreach posts post>
- <%if post.loaded>
- <%= true|store key=postShown parent=true>
- <%include include/viewPost.html>
- <%else>
- <%= true|store key=postNotLoaded parent=true>
- <%/if>
+ <%include include/viewPost.html>
<%/foreach>
<%include include/pagination.html>
- <%if postNotLoaded>
- <p><%= Page.Bookmarks.Text.PostsNotLoaded|l10n|html></p>
- <%else>
- <%if !postShown>
- <p><%= Page.Bookmarks.Text.NoBookmarks|l10n|html></p>
- <%/if>
+ <%if postsNotLoaded>
+ <p><%= Page.Bookmarks.Text.PostsNotLoaded|l10n|html|replace needle='{link}' replacement='<a href="unbookmark.html?post=allNotLoaded">'|replace needle='{/link}' replacement='</a>'></p>
+ <%elseif posts.empty>
+ <p><%= Page.Bookmarks.Text.NoBookmarks|l10n|html></p>
<%/if>
</div>