From 98cb777e1877896010644cd69d9c646140db8974 Mon Sep 17 00:00:00 2001 From: allo Date: Mon, 29 Jan 2007 15:09:58 +0000 Subject: [PATCH] abstract wikiCode in putWiki git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3293 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Wiki.java | 6 ++---- source/de/anomic/server/serverObjects.java | 9 +++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htroot/Wiki.java b/htroot/Wiki.java index 9cc7d587a..51643a39f 100644 --- a/htroot/Wiki.java +++ b/htroot/Wiki.java @@ -151,12 +151,11 @@ public class Wiki { //contributed by [MN] else if (post.containsKey("preview")) { // preview the page - wikiCode wikiTransformer=new wikiCode(switchboard); prop.put("mode", 2);//preview prop.put("mode_pagename", pagename); prop.put("mode_author", author); prop.put("mode_date", dateString(new Date())); - prop.putASIS("mode_page", wikiTransformer.transform(post.get("content", ""))); + prop.putWiki("mode_page", post.get("content", "")); prop.put("mode_page-code", post.get("content", "").replaceAll("<","<").replaceAll(">",">")); } //end contrib of [MN] @@ -187,13 +186,12 @@ public class Wiki { } else { - wikiCode wikiTransformer=new wikiCode(switchboard); // show page prop.put("mode", 0); //viewing prop.put("mode_pagename", pagename); prop.put("mode_author", page.author()); prop.put("mode_date", dateString(page.date())); - prop.putASIS("mode_page", wikiTransformer.transform(page.page())); + prop.putWiki("mode_page", page.page()); prop.put("controls", 0); prop.put("controls_pagename", pagename); diff --git a/source/de/anomic/server/serverObjects.java b/source/de/anomic/server/serverObjects.java index f40e367ad..3fb3cffc4 100644 --- a/source/de/anomic/server/serverObjects.java +++ b/source/de/anomic/server/serverObjects.java @@ -67,6 +67,7 @@ import java.util.Hashtable; import java.util.Map; import de.anomic.data.wikiCode; +import de.anomic.plasma.plasmaSwitchboard; public class serverObjects extends Hashtable implements Cloneable { @@ -120,6 +121,14 @@ public class serverObjects extends Hashtable implements Cloneable { public String putASIS(Object key, String value) { return (String) this.put(key, (Object) value); } + public String putWiki(Object key, String wikiCode){ + //XXX: This is ineffizient, if a lot of wikiCode is used on the same page. + //TODO: Cache the wikiCode Object? + return this.putASIS(key, (new wikiCode(plasmaSwitchboard.getSwitchboard())).transform(wikiCode)); + } + public String putWiki(Object key, byte[] wikiCode){ + return this.putASIS(key, (new wikiCode(plasmaSwitchboard.getSwitchboard())).transform(wikiCode)); + } // long variant public long put(String key, long value) {