use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class RPCHandler method listLinks.
public Vector listLinks(String pagename) throws XmlRpcException {
pagename = parsePageCheckCondition(pagename);
WikiPage page = m_engine.getPage(pagename);
String pagedata = m_engine.getPureText(page);
LinkCollector localCollector = new LinkCollector();
LinkCollector extCollector = new LinkCollector();
LinkCollector attCollector = new LinkCollector();
WikiContext context = new WikiContext(m_engine, page);
context.setVariable(WikiEngine.PROP_REFSTYLE, "absolute");
m_engine.textToHTML(context, pagedata, localCollector, extCollector, attCollector);
Vector<Hashtable<String, String>> result = new Vector<Hashtable<String, String>>();
//
for (Iterator<String> i = localCollector.getLinks().iterator(); i.hasNext(); ) {
String link = i.next();
Hashtable<String, String> ht = new Hashtable<String, String>();
ht.put("page", toRPCString(link));
ht.put("type", LINK_LOCAL);
if (m_engine.pageExists(link)) {
ht.put("href", context.getURL(WikiContext.VIEW, link));
} else {
ht.put("href", context.getURL(WikiContext.EDIT, link));
}
result.add(ht);
}
//
for (Iterator<String> i = attCollector.getLinks().iterator(); i.hasNext(); ) {
String link = i.next();
Hashtable<String, String> ht = new Hashtable<String, String>();
ht.put("page", toRPCString(link));
ht.put("type", LINK_LOCAL);
ht.put("href", context.getURL(WikiContext.ATTACH, link));
result.add(ht);
}
for (Iterator<String> i = extCollector.getLinks().iterator(); i.hasNext(); ) {
String link = i.next();
Hashtable<String, String> ht = new Hashtable<String, String>();
ht.put("page", link);
ht.put("type", LINK_EXTERNAL);
ht.put("href", link);
result.add(ht);
}
return result;
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class RPCHandlerUTF8 method listLinks.
public Vector listLinks(String pagename) throws XmlRpcException {
pagename = parsePageCheckCondition(pagename);
WikiPage page = m_engine.getPage(pagename);
String pagedata = m_engine.getPureText(page);
LinkCollector localCollector = new LinkCollector();
LinkCollector extCollector = new LinkCollector();
LinkCollector attCollector = new LinkCollector();
WikiContext context = new WikiContext(m_engine, page);
context.setVariable(WikiEngine.PROP_REFSTYLE, "absolute");
m_engine.textToHTML(context, pagedata, localCollector, extCollector, attCollector);
Vector<Hashtable<String, String>> result = new Vector<Hashtable<String, String>>();
//
for (Iterator<String> i = localCollector.getLinks().iterator(); i.hasNext(); ) {
String link = i.next();
Hashtable<String, String> ht = new Hashtable<String, String>();
ht.put("page", link);
ht.put("type", LINK_LOCAL);
if (m_engine.pageExists(link)) {
ht.put("href", context.getViewURL(link));
} else {
ht.put("href", context.getURL(WikiContext.EDIT, link));
}
result.add(ht);
}
//
for (String link : attCollector.getLinks()) {
Hashtable<String, String> ht = new Hashtable<String, String>();
ht.put("page", link);
ht.put("type", LINK_LOCAL);
ht.put("href", context.getURL(WikiContext.ATTACH, link));
result.add(ht);
}
for (String link : extCollector.getLinks()) {
Hashtable<String, String> ht = new Hashtable<String, String>();
ht.put("page", link);
ht.put("type", LINK_EXTERNAL);
ht.put("href", link);
result.add(ht);
}
return result;
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class JSPWikiMarkupParserTest method translate.
private String translate(WikiEngine e, WikiPage p, String src) throws IOException, NoRequiredPropertyException, ServletException {
WikiContext context = new WikiContext(e, testEngine.newHttpRequest(), p);
JSPWikiMarkupParser tr = new JSPWikiMarkupParser(context, new BufferedReader(new StringReader(src)));
XHTMLRenderer conv = new XHTMLRenderer(context, tr.parse());
return conv.getString();
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class CounterPluginTest method translate.
private String translate(String src) throws IOException, NoRequiredPropertyException, ServletException {
WikiContext context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage"));
MarkupParser p = new JSPWikiMarkupParser(context, new StringReader(src));
WikiDocument dom = p.parse();
WikiRenderer r = new XHTMLRenderer(context, dom);
return r.getString();
}
use of org.apache.wiki.WikiContext in project jspwiki by apache.
the class PageRenamerTest method testReferrerNoWikiName.
@Test
public void testReferrerNoWikiName() throws Exception {
m_engine.saveText("Test", "foo");
m_engine.saveText("TestPage2", "[Test] [Test#anchor] test Test [test] [link|test] [link|test]");
WikiPage p = m_engine.getPage("TestPage");
WikiContext context = new WikiContext(m_engine, p);
m_engine.renamePage(context, "Test", "TestPage", true);
String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
Assert.assertEquals("wrong data", "[TestPage] [TestPage#anchor] test Test [TestPage] [link|TestPage] [link|TestPage]", data.trim());
}
Aggregations