yacyWiki now supports the [[Image:]] tag

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@478 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
low012 20 years ago
parent 470839a16a
commit 77f4a3d99d

@ -40,6 +40,7 @@
// Contributions and changes to the program code must be marked as such.
// Contains contributions from Alexandier Schier [AS]
// and Marc Nause [MN]
// You must compile this file with
// javac -classpath .:../classes Wiki.java
@ -334,27 +335,59 @@ public class Wiki {
// create links
String kl, kv;
String kl, kv, alt, align;
int p;
// internal links
// internal links and images
while ((p0 = result.indexOf("[[")) >= 0) {
p1 = result.indexOf("]]", p0 + 2);
if (p1 <= p0) break; else; {
kl = result.substring(p0 + 2, p1);
if ((p = kl.indexOf("|")) > 0) {
kv = kl.substring(p + 1);
kl = kl.substring(0, p);
} else {
kv = kl;
}
if (switchboard.wikiDB.read(kl) != null)
result = result.substring(0, p0) +
"<a class=\"known\" href=\"Wiki.html?page=" + kl + "\">" + kv + "</a>" +
result.substring(p1 + 2);
else
result = result.substring(0, p0) +
"<a class=\"unknown\" href=\"Wiki.html?page=" + kl + "&edit=Edit\">" + kv + "</a>" +
result.substring(p1 + 2);
// this is the part of the code that's responsible for images
// contibuted by [MN]
if(kl.startsWith("Image:")){
alt = "";
align = "";
kv = "";
kl = kl.substring(6);
// are there any arguments for the image?
if ((p = kl.indexOf("|")) > 0) {
kv = kl.substring(p+1);
kl = kl.substring(0, p);
// if there are 2 arguments, write them into ALIGN and ALT
if ((p = kv.indexOf("|")) > 0) {
align = " align=\"" + kv.substring(0, p) +"\"";
alt = " alt=\"" + kv.substring(p + 1) +"\"";
}
// if there is just one, put it into ALT
else alt = " alt=\"" + kv +"\"";
}
result = result.substring(0, p0) + "<img src=\"" + kl + "\"" + align + alt +">" + result.substring(p1 + 2);
}
// end contrib [MN]
// if it's no image, it might be an internal link
else {
if ((p = kl.indexOf("|")) > 0) {
kv = kl.substring(p + 1);
kl = kl.substring(0, p);
} else {
kv = kl;
}
if (switchboard.wikiDB.read(kl) != null)
result = result.substring(0, p0) +
"<a class=\"known\" href=\"Wiki.html?page=" + kl + "\">" + kv + "</a>" +
result.substring(p1 + 2);
else
result = result.substring(0, p0) +
"<a class=\"unknown\" href=\"Wiki.html?page=" + kl + "&edit=Edit\">" + kv + "</a>" +
result.substring(p1 + 2);
}
}
}

Loading…
Cancel
Save