From 73f18ed5b2bfa007dca8282bd8493793c0d9be85 Mon Sep 17 00:00:00 2001 From: allo Date: Mon, 13 Feb 2006 14:42:19 +0000 Subject: [PATCH] git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1627 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/xml/bookmarks/posts/all.java | 12 ++++----- htroot/xml/bookmarks/posts/all_p.java | 12 ++++----- source/de/anomic/data/bookmarksDB.java | 29 ++++++++++++---------- source/de/anomic/server/serverObjects.java | 8 ++++++ 4 files changed, 36 insertions(+), 25 deletions(-) diff --git a/htroot/xml/bookmarks/posts/all.java b/htroot/xml/bookmarks/posts/all.java index ec09770d4..19a1c5015 100644 --- a/htroot/xml/bookmarks/posts/all.java +++ b/htroot/xml/bookmarks/posts/all.java @@ -71,13 +71,13 @@ public class all { Date date; while(it.hasNext()){ bookmark=switchboard.bookmarksDB.getBookmark((String) it.next()); - prop.put("posts_"+count+"_url", bookmark.getUrl()); - prop.put("posts_"+count+"_title", bookmark.getTitle()); - prop.put("posts_"+count+"_description", bookmark.getDescription()); - prop.put("posts_"+count+"_md5", serverCodings.encodeMD5Hex(bookmark.getUrl())); + prop.putNoHTML("posts_"+count+"_url", bookmark.getUrl()); + prop.putNoHTML("posts_"+count+"_title", bookmark.getTitle()); + prop.putNoHTML("posts_"+count+"_description", bookmark.getDescription()); + prop.putNoHTML("posts_"+count+"_md5", serverCodings.encodeMD5Hex(bookmark.getUrl())); date=new Date(bookmark.getTimeStamp()); - prop.put("posts_"+count+"_time", bookmarksDB.dateToiso8601(date)); - prop.put("posts_"+count+"_tags", bookmark.getTags().replaceAll(","," ")); + prop.putNoHTML("posts_"+count+"_time", bookmarksDB.dateToiso8601(date)); + prop.putNoHTML("posts_"+count+"_tags", bookmark.getTags().replaceAll(","," ")); count++; } prop.put("posts", count); diff --git a/htroot/xml/bookmarks/posts/all_p.java b/htroot/xml/bookmarks/posts/all_p.java index ad87db5a9..12a2d865a 100644 --- a/htroot/xml/bookmarks/posts/all_p.java +++ b/htroot/xml/bookmarks/posts/all_p.java @@ -71,13 +71,13 @@ public class all_p { Date date; while(it.hasNext()){ bookmark=switchboard.bookmarksDB.getBookmark((String) it.next()); - prop.put("posts_"+count+"_url", bookmark.getUrl()); - prop.put("posts_"+count+"_title", bookmark.getTitle()); - prop.put("posts_"+count+"_description", bookmark.getDescription()); - prop.put("posts_"+count+"_md5", serverCodings.encodeMD5Hex(bookmark.getUrl())); + prop.putNoHTML("posts_"+count+"_url", bookmark.getUrl()); + prop.putNoHTML("posts_"+count+"_title", bookmark.getTitle()); + prop.putNoHTML("posts_"+count+"_description", bookmark.getDescription()); + prop.putNoHTML("posts_"+count+"_md5", serverCodings.encodeMD5Hex(bookmark.getUrl())); date=new Date(bookmark.getTimeStamp()); - prop.put("posts_"+count+"_time", (new SimpleDateFormat("yyyy-MM-dd")).format(date)+"T"+(new SimpleDateFormat("HH:mm:ss")).format(date)+"Z"); - prop.put("posts_"+count+"_tags", bookmark.getTags().replaceAll(","," ")); + prop.putNoHTML("posts_"+count+"_time", (new SimpleDateFormat("yyyy-MM-dd")).format(date)+"T"+(new SimpleDateFormat("HH:mm:ss")).format(date)+"Z"); + prop.putNoHTML("posts_"+count+"_tags", bookmark.getTags().replaceAll(","," ")); count++; } prop.put("posts", count); diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java index b54d44c06..0f49be0b4 100644 --- a/source/de/anomic/data/bookmarksDB.java +++ b/source/de/anomic/data/bookmarksDB.java @@ -339,21 +339,16 @@ public class bookmarksDB { return set.iterator(); } public Iterator getTagIterator(boolean priv){ - if(priv){ - return tagIterator(true); - }else{ - Vector publicTags=new Vector(); - Iterator it=tagIterator(true); - Tag tag; - while(it.hasNext()){ - tag=(Tag)it.next(); - //this may be slow... - if(tag.hasPublicItems()){ - publicTags.add(tag); - } + TreeSet set=new TreeSet(new tagComparator()); + Iterator it=tagIterator(true); + Tag tag; + while(it.hasNext()){ + tag=(Tag) it.next(); + if(!priv ||tag.hasPublicItems()){ + set.add(tag); } - return publicTags.iterator(); } + return set.iterator(); } public boolean removeBookmark(String urlHash){ Bookmark bookmark = getBookmark(urlHash); @@ -829,4 +824,12 @@ public class bookmarksDB { return (new Long(bm1.getTimeStamp() - bm2.getTimeStamp())).intValue(); } } + /** + * sorts the tag for name + */ + public class tagComparator implements Comparator{ + public int compare(Object obj1, Object obj2){ + return ((Tag)obj1).getTagName().compareTo(((Tag)obj2).getTagName()); + } + } } diff --git a/source/de/anomic/server/serverObjects.java b/source/de/anomic/server/serverObjects.java index 507e66622..6364eeaf7 100644 --- a/source/de/anomic/server/serverObjects.java +++ b/source/de/anomic/server/serverObjects.java @@ -66,6 +66,7 @@ import java.util.Enumeration; import java.util.Hashtable; import java.util.Map; +import de.anomic.data.wikiCode; import de.anomic.http.httpHeader; public final class serverObjects extends Hashtable implements Cloneable { @@ -94,6 +95,13 @@ public final class serverObjects extends Hashtable implements Cloneable { super(input); } + /** + * like put, but it replaces any HTML special chars. + */ + public Object putNoHTML(Object key, String value){ + return put(key, wikiCode.replaceHTMLonly(value)); + } + // new put takes also null values public Object put(Object key, Object value) { if (key == null) {