projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Process Sone templates in their own method
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
web
/
NewPage.java
diff --git
a/src/main/java/net/pterodactylus/sone/web/NewPage.java
b/src/main/java/net/pterodactylus/sone/web/NewPage.java
index
af7c1ec
..
56da5dc
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/NewPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/NewPage.java
@@
-17,12
+17,16
@@
package net.pterodactylus.sone.web;
package net.pterodactylus.sone.web;
+import static net.pterodactylus.sone.utils.NumberParsers.parseInt;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import com.google.common.collect.Collections2;
+
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.notify.ListNotificationFilters;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.notify.ListNotificationFilters;
@@
-31,9
+35,6
@@
import net.pterodactylus.util.collection.Pagination;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
-import com.google.common.base.Optional;
-import com.google.common.primitives.Ints;
-
/**
* Page that displays all new posts and replies. The posts are filtered using
* {@link ListNotificationFilters#filterPosts(java.util.Collection, net.pterodactylus.sone.data.Sone)}
/**
* Page that displays all new posts and replies. The posts are filtered using
* {@link ListNotificationFilters#filterPosts(java.util.Collection, net.pterodactylus.sone.data.Sone)}
@@
-63,13
+64,11
@@
public class NewPage extends SoneTemplatePage {
* {@inheritDoc}
*/
@Override
* {@inheritDoc}
*/
@Override
- protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
- super.processTemplate(request, templateContext);
-
+ protected void processSonePage(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
/* collect new elements from notifications. */
Set<Post> posts = new HashSet<Post>(webInterface.getNewPosts());
/* collect new elements from notifications. */
Set<Post> posts = new HashSet<Post>(webInterface.getNewPosts());
- for (PostReply reply :
webInterface.getNewReplies(
)) {
- posts.add(reply.getPost());
+ for (PostReply reply :
Collections2.filter(webInterface.getNewReplies(), PostReply.HAS_POST_FILTER
)) {
+ posts.add(reply.getPost()
.get()
);
}
/* filter and sort them. */
}
/* filter and sort them. */
@@
-77,7
+76,7
@@
public class NewPage extends SoneTemplatePage {
Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
/* paginate them. */
Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
/* paginate them. */
- Pagination<Post> pagination = new Pagination<Post>(sortedPosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(
Optional.fromNullable(Ints.tryParse(request.getHttpRequest().getParam("page"))).or(
0));
+ Pagination<Post> pagination = new Pagination<Post>(sortedPosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(
parseInt(request.getHttpRequest().getParam("page"),
0));
templateContext.set("pagination", pagination);
templateContext.set("posts", pagination.getItems());
}
templateContext.set("pagination", pagination);
templateContext.set("posts", pagination.getItems());
}