projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add Gradle build file
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
template
/
PostAccessor.java
diff --git
a/src/main/java/net/pterodactylus/sone/template/PostAccessor.java
b/src/main/java/net/pterodactylus/sone/template/PostAccessor.java
index
2c0b59e
..
11cafea
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/template/PostAccessor.java
+++ b/
src/main/java/net/pterodactylus/sone/template/PostAccessor.java
@@
-1,5
+1,5
@@
/*
/*
- * Sone - PostAccessor.java - Copyright © 2010 David Roden
+ * Sone - PostAccessor.java - Copyright © 2010
–2016
David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-19,9
+19,12
@@
package net.pterodactylus.sone.template;
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Post;
+import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.ReflectionAccessor;
import net.pterodactylus.util.template.ReflectionAccessor;
+import net.pterodactylus.util.template.TemplateContext;
+
+import com.google.common.collect.Collections2;
/**
* Accessor for {@link Post} objects that adds additional properties:
/**
* Accessor for {@link Post} objects that adds additional properties:
@@
-51,17
+54,21
@@
public class PostAccessor extends ReflectionAccessor {
* {@inheritDoc}
*/
@Override
* {@inheritDoc}
*/
@Override
- public Object get(
DataProvider dataProvider
, Object object, String member) {
+ public Object get(
TemplateContext templateContext
, Object object, String member) {
Post post = (Post) object;
if ("replies".equals(member)) {
Post post = (Post) object;
if ("replies".equals(member)) {
- return
core.getReplies(post
);
+ return
Collections2.filter(core.getReplies(post.getId()), Reply.FUTURE_REPLY_FILTER
);
} else if (member.equals("likes")) {
return core.getLikes(post);
} else if (member.equals("liked")) {
} else if (member.equals("likes")) {
return core.getLikes(post);
} else if (member.equals("liked")) {
- Sone currentSone = (Sone)
dataProvider.getData
("currentSone");
+ Sone currentSone = (Sone)
templateContext.get
("currentSone");
return (currentSone != null) && (currentSone.isLikedPostId(post.getId()));
return (currentSone != null) && (currentSone.isLikedPostId(post.getId()));
+ } else if (member.equals("new")) {
+ return !post.isKnown();
+ } else if (member.equals("bookmarked")) {
+ return core.isBookmarked(post);
}
}
- return super.get(
dataProvider
, object, member);
+ return super.get(
templateContext
, object, member);
}
}
}
}