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:
445a0bc
)
Store request in link parser context.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sun, 24 Apr 2011 12:29:01 +0000
(14:29 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sun, 24 Apr 2011 12:29:01 +0000
(14:29 +0200)
src/main/java/net/pterodactylus/sone/template/ParserFilter.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/text/FreenetLinkParserContext.java
patch
|
blob
|
history
src/test/java/net/pterodactylus/sone/text/FreenetLinkParserTest.java
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/template/ParserFilter.java
b/src/main/java/net/pterodactylus/sone/template/ParserFilter.java
index
477e972
..
db945b5
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/template/ParserFilter.java
+++ b/
src/main/java/net/pterodactylus/sone/template/ParserFilter.java
@@
-25,6
+25,7
@@
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.text.FreenetLinkParser;
import net.pterodactylus.sone.text.FreenetLinkParserContext;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.text.FreenetLinkParser;
import net.pterodactylus.sone.text.FreenetLinkParserContext;
+import net.pterodactylus.sone.web.page.Page.Request;
import net.pterodactylus.util.template.Filter;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.template.TemplateContextFactory;
import net.pterodactylus.util.template.Filter;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.template.TemplateContextFactory;
@@
-70,7
+71,7
@@
public class ParserFilter implements Filter {
if (sone == null) {
sone = core.getSone(soneKey, false);
}
if (sone == null) {
sone = core.getSone(soneKey, false);
}
- FreenetLinkParserContext context = new FreenetLinkParserContext(sone);
+ FreenetLinkParserContext context = new FreenetLinkParserContext(
(Request) templateContext.get("request"),
sone);
try {
return linkParser.parse(context, new StringReader(text));
} catch (IOException ioe1) {
try {
return linkParser.parse(context, new StringReader(text));
} catch (IOException ioe1) {
diff --git
a/src/main/java/net/pterodactylus/sone/text/FreenetLinkParserContext.java
b/src/main/java/net/pterodactylus/sone/text/FreenetLinkParserContext.java
index
e524d91
..
0712fc0
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/text/FreenetLinkParserContext.java
+++ b/
src/main/java/net/pterodactylus/sone/text/FreenetLinkParserContext.java
@@
-18,6
+18,7
@@
package net.pterodactylus.sone.text;
import net.pterodactylus.sone.data.Sone;
package net.pterodactylus.sone.text;
import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.web.page.Page.Request;
/**
* {@link ParserContext} implementation for the {@link FreenetLinkParser}. It
/**
* {@link ParserContext} implementation for the {@link FreenetLinkParser}. It
@@
-28,20
+29,35
@@
import net.pterodactylus.sone.data.Sone;
*/
public class FreenetLinkParserContext implements ParserContext {
*/
public class FreenetLinkParserContext implements ParserContext {
+ /** The request being processed. */
+ private final Request request;
+
/** The posting Sone. */
private final Sone postingSone;
/**
* Creates a new link parser context.
*
/** The posting Sone. */
private final Sone postingSone;
/**
* Creates a new link parser context.
*
+ * @param request
+ * The request being processed
* @param postingSone
* The posting Sone
*/
* @param postingSone
* The posting Sone
*/
- public FreenetLinkParserContext(Sone postingSone) {
+ public FreenetLinkParserContext(Request request, Sone postingSone) {
+ this.request = request;
this.postingSone = postingSone;
}
/**
this.postingSone = postingSone;
}
/**
+ * Returns the request that is currently being processed.
+ *
+ * @return The request being processed
+ */
+ public Request getRequest() {
+ return request;
+ }
+
+ /**
* Returns the Sone that provided the text that is being parsed.
*
* @return The posting Sone
* Returns the Sone that provided the text that is being parsed.
*
* @return The posting Sone
diff --git
a/src/test/java/net/pterodactylus/sone/text/FreenetLinkParserTest.java
b/src/test/java/net/pterodactylus/sone/text/FreenetLinkParserTest.java
index
7e05fd5
..
e667aeb
100644
(file)
--- a/
src/test/java/net/pterodactylus/sone/text/FreenetLinkParserTest.java
+++ b/
src/test/java/net/pterodactylus/sone/text/FreenetLinkParserTest.java
@@
-41,7
+41,7
@@
public class FreenetLinkParserTest extends TestCase {
TemplateContextFactory templateContextFactory = new TemplateContextFactory();
templateContextFactory.addFilter("html", new HtmlFilter());
FreenetLinkParser parser = new FreenetLinkParser(null, templateContextFactory);
TemplateContextFactory templateContextFactory = new TemplateContextFactory();
templateContextFactory.addFilter("html", new HtmlFilter());
FreenetLinkParser parser = new FreenetLinkParser(null, templateContextFactory);
- FreenetLinkParserContext context = new FreenetLinkParserContext(null);
+ FreenetLinkParserContext context = new FreenetLinkParserContext(null
, null
);
Part part;
part = parser.parse(context, new StringReader("Text."));
Part part;
part = parser.parse(context, new StringReader("Text."));