projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Return the trust of a Sone.
[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
de96780
..
495d805
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/template/PostAccessor.java
+++ b/
src/main/java/net/pterodactylus/sone/template/PostAccessor.java
@@
-17,11
+17,16
@@
package net.pterodactylus.sone.template;
package net.pterodactylus.sone.template;
+import java.io.IOException;
+import java.io.StringReader;
+
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.text.FreenetLinkParser;
import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.ReflectionAccessor;
import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.ReflectionAccessor;
+import net.pterodactylus.util.template.TemplateFactory;
/**
* Accessor for {@link Post} objects that adds additional properties:
/**
* Accessor for {@link Post} objects that adds additional properties:
@@
-34,6
+39,9
@@
import net.pterodactylus.util.template.ReflectionAccessor;
*/
public class PostAccessor extends ReflectionAccessor {
*/
public class PostAccessor extends ReflectionAccessor {
+ /** Parser for Freenet links. */
+ private final FreenetLinkParser linkParser;
+
/** The core to get the replies from. */
private final Core core;
/** The core to get the replies from. */
private final Core core;
@@
-42,9
+50,12
@@
public class PostAccessor extends ReflectionAccessor {
*
* @param core
* The core to get the replies from
*
* @param core
* The core to get the replies from
+ * @param templateFactory
+ * The template factory for the text parser
*/
*/
- public PostAccessor(Core core) {
+ public PostAccessor(Core core
, TemplateFactory templateFactory
) {
this.core = core;
this.core = core;
+ linkParser = new FreenetLinkParser(templateFactory);
}
/**
}
/**
@@
-62,6
+73,16
@@
public class PostAccessor extends ReflectionAccessor {
return (currentSone != null) && (currentSone.isLikedPostId(post.getId()));
} else if (member.equals("new")) {
return core.isNewPost(post.getId(), false);
return (currentSone != null) && (currentSone.isLikedPostId(post.getId()));
} else if (member.equals("new")) {
return core.isNewPost(post.getId(), false);
+ } else if (member.equals("text")) {
+ String text = post.getText();
+ if (text == null) {
+ return null;
+ }
+ try {
+ return linkParser.parse(new StringReader(text));
+ } catch (IOException ioe1) {
+ /* ignore. */
+ }
}
return super.get(dataProvider, object, member);
}
}
return super.get(dataProvider, object, member);
}