projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
3e1573f
)
Use new parser filter for posts and replies, too.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sun, 16 Jan 2011 14:43:16 +0000
(15:43 +0100)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sun, 16 Jan 2011 14:43:16 +0000
(15:43 +0100)
src/main/java/net/pterodactylus/sone/template/PostAccessor.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/WebInterface.java
patch
|
blob
|
history
src/main/resources/templates/include/viewPost.html
patch
|
blob
|
history
src/main/resources/templates/include/viewReply.html
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/template/PostAccessor.java
b/src/main/java/net/pterodactylus/sone/template/PostAccessor.java
index
ef8577d
..
d3af897
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/template/PostAccessor.java
+++ b/
src/main/java/net/pterodactylus/sone/template/PostAccessor.java
@@
-17,17
+17,11
@@
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.sone.text.FreenetLinkParserContext;
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:
@@
-40,9
+34,6
@@
import net.pterodactylus.util.template.TemplateFactory;
*/
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;
@@
-51,12
+42,9
@@
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
, TemplateFactory templateFactory
) {
+ public PostAccessor(Core core) {
this.core = core;
this.core = core;
- linkParser = new FreenetLinkParser(templateFactory);
}
/**
}
/**
@@
-74,16
+62,6
@@
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 FreenetLinkParserContext(post.getSone()), new StringReader(text));
- } catch (IOException ioe1) {
- /* ignore. */
- }
}
return super.get(dataProvider, object, member);
}
}
return super.get(dataProvider, object, member);
}
diff --git
a/src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java
b/src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java
index
de0c9c3
..
41fbf4e
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java
+++ b/
src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java
@@
-17,18
+17,12
@@
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.Reply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.text.FreenetLinkParser;
-import net.pterodactylus.sone.text.FreenetLinkParserContext;
import net.pterodactylus.util.template.Accessor;
import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.ReflectionAccessor;
import net.pterodactylus.util.template.Accessor;
import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.ReflectionAccessor;
-import net.pterodactylus.util.template.TemplateFactory;
/**
* {@link Accessor} implementation that adds a couple of properties to
/**
* {@link Accessor} implementation that adds a couple of properties to
@@
-38,9
+32,6
@@
import net.pterodactylus.util.template.TemplateFactory;
*/
public class ReplyAccessor extends ReflectionAccessor {
*/
public class ReplyAccessor extends ReflectionAccessor {
- /** Parser for Freenet links. */
- private final FreenetLinkParser linkParser;
-
/** The core. */
private final Core core;
/** The core. */
private final Core core;
@@
-49,12
+40,9
@@
public class ReplyAccessor extends ReflectionAccessor {
*
* @param core
* The core
*
* @param core
* The core
- * @param templateFactory
- * The template factory for the text parser
*/
*/
- public ReplyAccessor(Core core
, TemplateFactory templateFactory
) {
+ public ReplyAccessor(Core core) {
this.core = core;
this.core = core;
- linkParser = new FreenetLinkParser(templateFactory);
}
/**
}
/**
@@
-70,13
+58,6
@@
public class ReplyAccessor extends ReflectionAccessor {
return (currentSone != null) && (currentSone.isLikedReplyId(reply.getId()));
} else if (member.equals("new")) {
return core.isNewReply(reply.getId(), false);
return (currentSone != null) && (currentSone.isLikedReplyId(reply.getId()));
} else if (member.equals("new")) {
return core.isNewReply(reply.getId(), false);
- } else if (member.equals("text")) {
- String text = reply.getText();
- try {
- return linkParser.parse(new FreenetLinkParserContext(reply.getSone()), new StringReader(text));
- } catch (IOException ioe1) {
- /* ignore. */
- }
}
return super.get(dataProvider, object, member);
}
}
return super.get(dataProvider, object, member);
}
diff --git
a/src/main/java/net/pterodactylus/sone/web/WebInterface.java
b/src/main/java/net/pterodactylus/sone/web/WebInterface.java
index
92aa998
..
8eb35e3
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/WebInterface.java
+++ b/
src/main/java/net/pterodactylus/sone/web/WebInterface.java
@@
-170,8
+170,8
@@
public class WebInterface implements CoreListener {
templateFactory.addAccessor(Object.class, new ReflectionAccessor());
templateFactory.addAccessor(Collection.class, new CollectionAccessor());
templateFactory.addAccessor(Sone.class, new SoneAccessor(getCore()));
templateFactory.addAccessor(Object.class, new ReflectionAccessor());
templateFactory.addAccessor(Collection.class, new CollectionAccessor());
templateFactory.addAccessor(Sone.class, new SoneAccessor(getCore()));
- templateFactory.addAccessor(Post.class, new PostAccessor(getCore()
, templateFactory
));
- templateFactory.addAccessor(Reply.class, new ReplyAccessor(getCore()
, templateFactory
));
+ templateFactory.addAccessor(Post.class, new PostAccessor(getCore()));
+ templateFactory.addAccessor(Reply.class, new ReplyAccessor(getCore()));
templateFactory.addAccessor(Identity.class, new IdentityAccessor(getCore()));
templateFactory.addAccessor(NotificationManager.class, new NotificationManagerAccessor());
templateFactory.addAccessor(Trust.class, new TrustAccessor());
templateFactory.addAccessor(Identity.class, new IdentityAccessor(getCore()));
templateFactory.addAccessor(NotificationManager.class, new NotificationManagerAccessor());
templateFactory.addAccessor(Trust.class, new TrustAccessor());
diff --git
a/src/main/resources/templates/include/viewPost.html
b/src/main/resources/templates/include/viewPost.html
index
64fddea
..
5161dfe
100644
(file)
--- a/
src/main/resources/templates/include/viewPost.html
+++ b/
src/main/resources/templates/include/viewPost.html
@@
-16,7
+16,7
@@
<div class="recipient profile-link"><a href="viewSone.html?sone=<% post.recipient.id|html>"><% post.recipient.niceName|html></a></div>
<%/if>
<%/if>
<div class="recipient profile-link"><a href="viewSone.html?sone=<% post.recipient.id|html>"><% post.recipient.niceName|html></a></div>
<%/if>
<%/if>
- <div class="text"><% post.text></div>
+ <div class="text"><% post.text
|parse sone=post.sone
></div>
</div>
<div class="post-status-line status-line">
<div class="time"><a href="viewPost.html?post=<% post.id|html>"><% post.time|date format="MMM d, yyyy, HH:mm:ss"></a></div>
</div>
<div class="post-status-line status-line">
<div class="time"><a href="viewPost.html?post=<% post.id|html>"><% post.time|date format="MMM d, yyyy, HH:mm:ss"></a></div>
diff --git
a/src/main/resources/templates/include/viewReply.html
b/src/main/resources/templates/include/viewReply.html
index
4daf302
..
805626a
100644
(file)
--- a/
src/main/resources/templates/include/viewReply.html
+++ b/
src/main/resources/templates/include/viewReply.html
@@
-8,7
+8,7
@@
<div class="inner-part">
<div>
<div class="author profile-link"><a href="viewSone.html?sone=<% reply.sone.id|html>"><% reply.sone.niceName|html></a></div>
<div class="inner-part">
<div>
<div class="author profile-link"><a href="viewSone.html?sone=<% reply.sone.id|html>"><% reply.sone.niceName|html></a></div>
- <div class="text"><% reply.text></div>
+ <div class="text"><% reply.text
|parse sone=reply.sone
></div>
</div>
<div class="reply-status-line status-line">
<div class="time"><% reply.time|date format="MMM d, yyyy, HH:mm:ss"></div>
</div>
<div class="reply-status-line status-line">
<div class="time"><% reply.time|date format="MMM d, yyyy, HH:mm:ss"></div>