This resolves #32.
import java.util.List;
import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.util.collection.Pagination;
import net.pterodactylus.util.filter.Filters;
Pagination<Post> pagination = new Pagination<Post>(allPosts, 25).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0));
templateContext.set("pagination", pagination);
templateContext.set("posts", pagination.getItems());
-
- /* mark it all as known. */
- for (Post post : pagination.getItems()) {
- webInterface.getCore().markPostKnown(post);
- for (Reply reply : webInterface.getCore().getReplies(post)) {
- webInterface.getCore().markReplyKnown(reply);
- }
- }
-
}
}
Pagination<Sone> sonePagination = new Pagination<Sone>(knownSones, 25).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0));
templateContext.set("pagination", sonePagination);
templateContext.set("knownSones", sonePagination.getItems());
-
- /* mark Sones as known. */
- for (Sone sone : sonePagination.getItems()) {
- webInterface.getCore().markSoneKnown(sone);
- }
}
}
templateContext.set("soneHits", sonePagination.getItems());
templateContext.set("postPagination", postPagination);
templateContext.set("postHits", postPagination.getItems());
-
- /* mark found posts and Sones as knew. */
- for (Sone sone : sonePagination.getItems()) {
- webInterface.getCore().markSoneKnown(sone);
- }
- for (Post post : postPagination.getItems()) {
- webInterface.getCore().markPostKnown(post);
- for (Reply reply : webInterface.getCore().getReplies(post)) {
- webInterface.getCore().markReplyKnown(reply);
- }
- }
}
//
package net.pterodactylus.sone.web;
import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.template.SoneAccessor;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
Post post = webInterface.getCore().getPost(postId);
templateContext.set("post", post);
templateContext.set("raw", raw);
- webInterface.getCore().markPostKnown(post);
- for (Reply reply : webInterface.getCore().getReplies(post)) {
- webInterface.getCore().markReplyKnown(reply);
- }
}
}
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.template.SoneAccessor;
-import net.pterodactylus.util.collection.ListBuilder;
import net.pterodactylus.util.collection.Pagination;
import net.pterodactylus.util.number.Numbers;
import net.pterodactylus.util.template.Template;
Pagination<Post> repliedPostPagination = new Pagination<Post>(posts, 10).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("repliedPostPage"), 0));
templateContext.set("repliedPostPagination", repliedPostPagination);
templateContext.set("repliedPosts", repliedPostPagination.getItems());
-
- /* mark Sone and posts and replies as known. */
- webInterface.getCore().markSoneKnown(sone);
- for (Post post : new ListBuilder<Post>().addAll(postPagination.getItems()).addAll(repliedPostPagination.getItems()).get()) {
- if (post.getSone() != null) {
- webInterface.getCore().markPostKnown(post);
- }
- for (Reply reply : webInterface.getCore().getReplies(post)) {
- webInterface.getCore().markReplyKnown(reply);
- }
- }
}
}