Skip to content

Commit

Permalink
- the wiki-parser works for remote wiki-code now, not displaying link…
Browse files Browse the repository at this point in the history
…s anymore as if they were local (ViewProfile comment)

- fixed wrong link to CrawlStart on Status-page

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3816 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
karlchenofhell committed Jun 7, 2007
1 parent e75ca85 commit f05ca43
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 42 deletions.
2 changes: 1 addition & 1 deletion htroot/Status.html
Expand Up @@ -90,7 +90,7 @@

#(hintCrawlStart)#::
<dt class="hintIcon"><img src="env/grafics/idea.png" width="32" height="32" alt="idea"/></dt>
<dd class="hint">Your Web Page Indexer is idle. You can start your own web crawl <a href="IndexCreate_p.html">here</a>
<dd class="hint">Your Web Page Indexer is idle. You can start your own web crawl <a href="CrawlStartSimple_p.html">here</a>
</dd>
#(/hintCrawlStart)#

Expand Down
8 changes: 6 additions & 2 deletions htroot/ViewProfile.java
Expand Up @@ -86,6 +86,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve

// get the profile
HashMap profile = null;
String address = null;
if (hash.equals("localhash")) {
// read the profile from local peer
Properties p = new Properties();
Expand All @@ -102,6 +103,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
prop.put("localremotepeer", 0);
prop.put("success_peername", yacyCore.seedDB.mySeed.getName());
prop.put("success_peerhash", yacyCore.seedDB.mySeed.hash);
address = yacyCore.seedDB.mySeed.getPublicAddress();
} else {
// read the profile from remote peer
yacySeed seed = yacyCore.seedDB.getConnected(hash);
Expand All @@ -128,6 +130,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
}
prop.put("success_peername", seed.getName());
prop.put("success_peerhash", seed.hash);
address = seed.getPublicAddress();
}
prop.put("localremotepeer", 1);
}
Expand Down Expand Up @@ -156,7 +159,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
while (it.hasNext()) {
prop.put("success_" + (String) it.next(), 0);
}

//number of not explicitly recognized but displayed items
int numUnknown = 0;
while (i.hasNext()) {
Expand All @@ -175,7 +178,8 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
if(key.equals("comment")){
prop.putWiki(
"success_" + key + "_value",
((String) entry.getValue()).replaceAll("\r", "").replaceAll("\\\\n", "\n")
((String) entry.getValue()).replaceAll("\r", "").replaceAll("\\\\n", "\n"),
address
);
prop.putASIS("success_" + key + "_b64value",kelondroBase64Order.standardCoder.encodeString((String) entry.getValue()));
}else{
Expand Down
44 changes: 39 additions & 5 deletions source/de/anomic/data/wiki/abstractWikiParser.java
Expand Up @@ -8,29 +8,46 @@
import java.io.UnsupportedEncodingException;

import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.yacy.yacyCore;

public abstract class abstractWikiParser implements wikiParser {

protected plasmaSwitchboard sb;
private plasmaSwitchboard sb;

public abstractWikiParser(plasmaSwitchboard sb) {
this.sb = sb;
}

protected abstract String transform(BufferedReader reader, int length, plasmaSwitchboard sb) throws IOException;
protected abstract String transform(BufferedReader reader, int length, String publicAddress, plasmaSwitchboard sb) throws IOException;

public String transform(String content) {
return transform(content, this.sb);
}

public String transform(String content, plasmaSwitchboard sb) {
try {
return transform(new BufferedReader(new StringReader(content)), content.length(), sb);
return transform(
new BufferedReader(new StringReader(content)),
content.length(),
yacyCore.seedDB.mySeed.getPublicAddress(),
sb);
} catch (IOException e) {
return "internal error: " + e.getMessage();
}
}


public String transform(String content, String publicAddress) {
try {
return transform(
new BufferedReader(new StringReader(content)),
content.length(),
publicAddress,
null);
} catch (IOException e) {
return "internal error: " + e.getMessage();
}
}

public String transform(byte[] content) throws UnsupportedEncodingException {
return transform(content, "UTF-8", this.sb);
}
Expand All @@ -39,10 +56,27 @@ public String transform(byte[] content, String encoding) throws UnsupportedEncod
return transform(content, encoding, this.sb);
}

public String transform(byte[] content, String encoding, String publicAddress) throws UnsupportedEncodingException {
ByteArrayInputStream bais = new ByteArrayInputStream(content);
try {
return transform(
new BufferedReader(new InputStreamReader(bais, encoding)),
content.length,
publicAddress,
null);
} catch (IOException e) {
return "internal error: " + e.getMessage();
}
}

public String transform(byte[] content, String encoding, plasmaSwitchboard switchboard) throws UnsupportedEncodingException {
ByteArrayInputStream bais = new ByteArrayInputStream(content);
try {
return transform(new BufferedReader(new InputStreamReader(bais, encoding)), content.length, switchboard);
return transform(
new BufferedReader(new InputStreamReader(bais, encoding)),
content.length,
yacyCore.seedDB.mySeed.getPublicAddress(),
switchboard);
} catch (IOException e) {
return "internal error: " + e.getMessage();
}
Expand Down
24 changes: 16 additions & 8 deletions source/de/anomic/data/wiki/knwikiParser.java
Expand Up @@ -106,39 +106,47 @@ public static void main(String[] args) {
String t = "[=] ein fucking [= test =]-text[=,ne?!=] joa, [=alles=]wunderbar," +
"[=denk ich=] mal =]";
long l = System.currentTimeMillis();
t = new knwikiParser(null).parse((args.length > 0) ? args[0] : text);
t = new knwikiParser(null).parse((args.length > 0) ? args[0] : text, "localhost:8080");
System.out.println("parsing time: " + (System.currentTimeMillis() - l) + " ms");
System.out.println("--- --- ---");
System.out.println(t);
}

public String transform(String content) {
return parse(content);
return parse(content, null);
}

public String transform(String content, plasmaSwitchboard sb) {
return parse(content);
return parse(content, null);
}

public String transform(byte[] content) throws UnsupportedEncodingException {
return parse(new String(content, "UTF-8"));
return parse(new String(content, "UTF-8"), null);
}

public String transform(
byte[] content, String encoding,
plasmaSwitchboard switchboard) throws UnsupportedEncodingException {
return parse(new String(content, encoding));
return parse(new String(content, encoding), null);
}

public String transform(byte[] content, String encoding) throws UnsupportedEncodingException {
return parse(new String(content, encoding));
return parse(new String(content, encoding), null);
}

public String transform(byte[] text, String encoding, String publicAddress) throws UnsupportedEncodingException {
return parse(new String(text, encoding), publicAddress);
}

public String transform(String text, String publicAddress) {
return parse(text, publicAddress);
}

public String parse(String text) {
public String parse(String text, String publicAddress) {
tokens = new Token[] {
new SimpleToken('=', '=', new String[][] { null, { "h2" }, { "h3" }, { "h4" } }, true),
new SimpleToken('\'', '\'', new String[][] { null, { "i" }, { "b" }, null, { "b", "i" } }, false),
new LinkToken(yacyCore.seedDB.mySeed.getPublicAddress(), "Wiki.html?page=", sb),
new LinkToken((publicAddress == null) ? yacyCore.seedDB.mySeed.getPublicAddress() : publicAddress, "Wiki.html?page=", sb),
new ListToken('*', "ul"),
new ListToken('#', "ol"),
new ListToken(':', "blockquote", null),
Expand Down
2 changes: 2 additions & 0 deletions source/de/anomic/data/wiki/wikiParser.java
Expand Up @@ -8,7 +8,9 @@ public interface wikiParser {

public String transform(String text);
public String transform(String text, plasmaSwitchboard switchboard);
public String transform(String text, String publicAddress);
public String transform(byte[] text) throws UnsupportedEncodingException;
public String transform(byte[] text, String encoding) throws UnsupportedEncodingException;
public String transform(byte[] text, String encoding, plasmaSwitchboard switchboard) throws UnsupportedEncodingException;
public String transform(byte[] text, String encoding, String publicAddress) throws UnsupportedEncodingException;
}

0 comments on commit f05ca43

Please sign in to comment.