From 3bafd643c0b311d4d0a58dea71fc44e8e48cf578 Mon Sep 17 00:00:00 2001 From: karlchenofhell Date: Sat, 3 Feb 2007 20:22:39 +0000 Subject: [PATCH] - fix for http://www.yacy-forum.de/viewtopic.php?t=3483 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3330 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/ViewFile.html | 2 +- htroot/ViewFile.java | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/htroot/ViewFile.html b/htroot/ViewFile.html index bcac4ee64..6db33bec0 100644 --- a/htroot/ViewFile.html +++ b/htroot/ViewFile.html @@ -82,7 +82,7 @@ #[nr]# #[type]# #[text]# - #[link]# + #[link]# #[attr]# #{/links}# diff --git a/htroot/ViewFile.java b/htroot/ViewFile.java index d39053f72..5bb7f955a 100644 --- a/htroot/ViewFile.java +++ b/htroot/ViewFile.java @@ -88,7 +88,7 @@ public class ViewFile { plasmaSwitchboard sb = (plasmaSwitchboard)env; if (post != null && post.containsKey("words")) - prop.put("error_words", wikiCode.replaceXMLEntities((String)post.get("words"))); + prop.put("error_words", (String)post.get("words")); else { prop.put("error", 1); prop.put("viewmode", 0); @@ -262,8 +262,7 @@ public class ViewFile { } } - content = wikiCode.replaceXMLEntities( - content.replaceAll("\n", "
").replaceAll("\t", "    ")); + content = content.replaceAll("\n", "
").replaceAll("\t", "    "); prop.put("error", 0); prop.put("viewMode", VIEW_MODE_AS_PLAIN_TEXT); @@ -271,7 +270,7 @@ public class ViewFile { } else if (viewMode.equals("iframe")) { prop.put("viewMode", VIEW_MODE_AS_IFRAME); - prop.put("viewMode_url", wikiCode.replaceXMLEntities(url.toNormalform())); + prop.put("viewMode_url", url.toNormalform()); } else if (viewMode.equals("parsed") || viewMode.equals("sentences") || viewMode.equals("links")) { // parsing the resource content @@ -303,11 +302,11 @@ public class ViewFile { if (viewMode.equals("parsed")) { String content = new String(document.getTextBytes()); - content = wikiCode.replaceHTML(content); // added by Marc Nause + // content = wikiCode.replaceHTML(content); // added by Marc Nause content = content.replaceAll("\n", "
").replaceAll("\t", "    "); prop.put("viewMode", VIEW_MODE_AS_PARSED_TEXT); - prop.put("viewMode_parsedText", markup(wordArray, content)); + prop.putASIS("viewMode_parsedText", markup(wordArray, content)); } else if (viewMode.equals("sentences")) { prop.put("viewMode", VIEW_MODE_AS_PARSED_SENTENCES); @@ -323,7 +322,7 @@ public class ViewFile { sentence = ((StringBuffer) sentences.next()).toString(); if (sentence.trim().length() > 0) { prop.put("viewMode_sentences_" + i + "_nr", Integer.toString(i + 1)); - prop.put("viewMode_sentences_" + i + "_text", markup(wordArray, sentence)); + prop.putASIS("viewMode_sentences_" + i + "_text", markup(wordArray, sentence)); prop.put("viewMode_sentences_" + i + "_dark", ((dark) ? 1 : 0)); dark = !dark; i++; @@ -349,9 +348,13 @@ public class ViewFile { prop.put("viewMode_links_" + i + "_nr", i); prop.put("viewMode_links_" + i + "_dark", ((dark) ? 1 : 0)); prop.put("viewMode_links_" + i + "_type", "image"); - prop.put("viewMode_links_" + i + "_text", markup(wordArray, entry.alt())); - prop.put("viewMode_links_" + i + "_link", "" + markup(wordArray, (String) entry.url().toNormalform()) + ""); - prop.put("viewMode_links_" + i + "_attr", entry.width() + " x " + entry.height()); + prop.putASIS("viewMode_links_" + i + "_text", markup(wordArray, entry.alt())); + prop.put("viewMode_links_" + i + "_url", (String) entry.url().toNormalform()); + prop.putASIS("viewMode_links_" + i + "_link", markup(wordArray, (String) entry.url().toNormalform())); + if (entry.width() > 0 && entry.height() > 0) + prop.putASIS("viewMode_links_" + i + "_attr", entry.width() + "x" + entry.height() + " Pixel"); + else + prop.put("viewMode_links_" + i + "_attr", "unknown"); dark = !dark; i++; } @@ -361,7 +364,7 @@ public class ViewFile { if (document != null) document.close(); } prop.put("error", 0); - prop.put("error_url", wikiCode.replaceXMLEntities(url.toNormalform())); + prop.put("error_url", url.toNormalform()); prop.put("error_hash", urlHash); prop.put("error_wordCount", Integer.toString(wordCount)); prop.put("error_desc", descr); @@ -382,10 +385,11 @@ public class ViewFile { } private static final String markup(String[] wordArray, String message) { - message = wikiCode.replaceHTML(message); + message = wikiCode.replaceXMLEntities(message); if (wordArray != null) for (int j = 0; j < wordArray.length; j++) { String currentWord = wordArray[j].trim(); + // TODO: replace upper-/lowercase words as well message = message.replaceAll(currentWord, "" + currentWord + @@ -403,8 +407,8 @@ public class ViewFile { prop.put("viewMode_links_" + c + "_nr", c); prop.put("viewMode_links_" + c + "_dark", ((dark) ? 1 : 0)); prop.put("viewMode_links_" + c + "_type", name); - prop.put("viewMode_links_" + c + "_text", markup(wordArray, (String) entry.getValue())); - prop.put("viewMode_links_" + c + "_link", "" + markup(wordArray, (String) entry.getKey()) + ""); + prop.putASIS("viewMode_links_" + c + "_text", markup(wordArray, (String) entry.getValue())); + prop.putASIS("viewMode_links_" + c + "_link", markup(wordArray, (String) entry.getKey())); prop.put("viewMode_links_" + c + "_attr", ""); dark = !dark; c++;