diff --git a/htroot/Table_YMark_p.html b/htroot/Table_YMark_p.html index 5e6ee0162..79e81c8a8 100644 --- a/htroot/Table_YMark_p.html +++ b/htroot/Table_YMark_p.html @@ -29,7 +29,7 @@ var width = document.documentElement.clientWidth; var height = document.documentElement.clientHeight; width = width - 490; - height = height - 225; + height = height - 250; $("#table").width(width); $("#table").height(height); $("#content_area").width(width); @@ -47,7 +47,8 @@ #(showtable)#::
@@ -159,7 +160,7 @@ select a tag #{tags}# - #[tagName]# + #[tagName]# [#[tagCount]#] #{/tags}# @@ -170,7 +171,7 @@ select a folder #{folders}# - #[folderName]# + #[folderName]# [#[folderCount]#] #{/folders}# diff --git a/htroot/Table_YMark_p.java b/htroot/Table_YMark_p.java index c81cafab1..ae0796d8e 100644 --- a/htroot/Table_YMark_p.java +++ b/htroot/Table_YMark_p.java @@ -57,12 +57,15 @@ public class Table_YMark_p { // get available tags and folders count = 0; byte[] key; + String name; try { Iterator iter = sb.tables.keys(YMarkTables.TABLES.TAGS.tablename(bmk_user)); while(iter.hasNext()) { key = iter.next(); + name = sb.tables.bookmarks.tags.getKeyname(bmk_user, key); prop.put("showselection_tags_" + count + "_tagHash", new String(key)); - prop.put("showselection_tags_" + count + "_tagName", sb.tables.bookmarks.tags.getKeyname(bmk_user, key)); + prop.put("showselection_tags_" + count + "_tagName", name); + prop.put("showselection_tags_" + count + "_tagCount", sb.tables.bookmarks.tags.getBookmarkIds(bmk_user, name).size()); count++; } prop.put("showselection_tags", count); @@ -70,8 +73,10 @@ public class Table_YMark_p { iter = sb.tables.keys(YMarkTables.TABLES.FOLDERS.tablename(bmk_user)); while(iter.hasNext()) { key = iter.next(); + name = sb.tables.bookmarks.folders.getKeyname(bmk_user, key); prop.put("showselection_folders_" + count + "_folderHash", new String(key)); - prop.put("showselection_folders_" + count + "_folderName", sb.tables.bookmarks.folders.getKeyname(bmk_user, key)); + prop.put("showselection_folders_" + count + "_folderName", name); + prop.put("showselection_folders_" + count + "_folderCount", sb.tables.bookmarks.folders.getBookmarkIds(bmk_user, name).size()); count++; } prop.put("showselection_folders", count); @@ -198,6 +203,18 @@ public class Table_YMark_p { } else { prop.put("showtable", 1); prop.put("showtable_table", table); + + + try { + prop.put("showtable_bmksize", sb.tables.size(table)); + prop.put("showtable_tagsize", sb.tables.size(YMarkTables.TABLES.TAGS.tablename(bmk_user))); + prop.put("showtable_foldersize", sb.tables.size(YMarkTables.TABLES.FOLDERS.tablename(bmk_user))); + } catch (IOException e) { + Log.logException(e); + prop.put("showtable_bmksize", 0); + prop.put("showtable_tagsize", 0); + prop.put("showtable_foldersize", 0); + } // insert the columns diff --git a/htroot/api/ymarks/import_ymark.java b/htroot/api/ymarks/import_ymark.java index 202daa612..0294bd2cd 100644 --- a/htroot/api/ymarks/import_ymark.java +++ b/htroot/api/ymarks/import_ymark.java @@ -2,15 +2,22 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.HashMap; -import org.xml.sax.SAXException; import net.yacy.cora.protocol.RequestHeader; +import net.yacy.document.Document; +import net.yacy.document.Parser.Failure; +import net.yacy.kelondro.data.meta.DigestURI; import net.yacy.kelondro.index.RowSpaceExceededException; import net.yacy.kelondro.logging.Log; + +import org.xml.sax.SAXException; + +import de.anomic.crawler.CrawlProfile; +import de.anomic.crawler.retrieval.Response; +import de.anomic.data.UserDB; import de.anomic.data.YMarkTables; import de.anomic.data.YMarksHTMLImporter; import de.anomic.data.YMarksXBELImporter; -import de.anomic.data.UserDB; import de.anomic.search.Switchboard; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; @@ -48,17 +55,7 @@ public class import_ymark { t = new Thread(htmlImporter, "YMarks - HTML Importer"); t.start(); while ((bmk = htmlImporter.take()) != YMarkTables.POISON) { - try { - sb.tables.bookmarks.addBookmark(bmk_user, bmk, true); - } catch (IOException e) { - Log.logWarning(YMarkTables.BOOKMARKS_LOG.toString(), "HTML Importer - IOException for URL: "+bmk.get(YMarkTables.BOOKMARK.URL.key())); - continue; - } catch (RowSpaceExceededException e) { - //TODO: display an error message - Log.logException(e); - prop.put("result", "0"); - return prop; - } + putBookmark(sb, bmk_user, bmk); } prop.put("result", "1"); } else if(post.get("importer").equals("xbel") && byteIn != null) { @@ -75,17 +72,7 @@ public class import_ymark { t = new Thread(xbelImporter, "YMarks - XBEL Importer"); t.start(); while ((bmk = xbelImporter.take()) != YMarkTables.POISON) { - try { - sb.tables.bookmarks.addBookmark(bmk_user, bmk, true); - } catch (IOException e) { - Log.logWarning(YMarkTables.BOOKMARKS_LOG.toString(), "XBEL Importer - IOException for URL: "+bmk.get(YMarkTables.BOOKMARK.URL.key())); - continue; - } catch (RowSpaceExceededException e) { - //TODO: display an error message - Log.logException(e); - prop.put("result", "0"); - return prop; - } + putBookmark(sb, bmk_user, bmk); } prop.put("result", "1"); } @@ -100,6 +87,26 @@ public class import_ymark { // return rewrite properties return prop; } + + public static void putBookmark(final Switchboard sb, final String bmk_user, final HashMap bmk) { + try { + if(!bmk.containsKey(YMarkTables.BOOKMARK.TAGS.key()) || bmk.get(YMarkTables.BOOKMARK.TAGS.key()).equals(YMarkTables.BOOKMARK.TAGS.deflt())) { + final DigestURI u = new DigestURI(bmk.get(YMarkTables.BOOKMARK.URL.key())); + Response response = sb.loader.load(sb.loader.request(u, true, false), CrawlProfile.CacheStrategy.IFEXIST, Long.MAX_VALUE); + final Document document = Document.mergeDocuments(response.url(), response.getMimeType(), response.parse()); + if(document != null) { + bmk.put(YMarkTables.BOOKMARK.TAGS.key(), sb.tables.bookmarks.autoTag(document, bmk_user, 3)); + } + } + sb.tables.bookmarks.addBookmark(bmk_user, bmk, true); + } catch (IOException e) { + Log.logWarning(YMarkTables.BOOKMARKS_LOG.toString(), "Importer - IOException for URL: "+bmk.get(YMarkTables.BOOKMARK.URL.key())); + } catch (RowSpaceExceededException e) { + Log.logException(e); + } catch (Failure e) { + Log.logWarning(YMarkTables.BOOKMARKS_LOG.toString(), "Importer - Failure for URL: "+bmk.get(YMarkTables.BOOKMARK.URL.key())); + } + } } diff --git a/source/de/anomic/data/YMarkTables.java b/source/de/anomic/data/YMarkTables.java index 5c9641f53..c2faa4410 100644 --- a/source/de/anomic/data/YMarkTables.java +++ b/source/de/anomic/data/YMarkTables.java @@ -27,7 +27,6 @@ import net.yacy.kelondro.index.RowSpaceExceededException; import net.yacy.kelondro.logging.Log; import net.yacy.kelondro.util.DateFormatter; import de.anomic.search.Segment; -import de.anomic.data.YMarkWordCountComparator; public class YMarkTables { @@ -243,6 +242,8 @@ public class YMarkTables { public final static String cleanTagsString(final String tagsString) { StringBuilder ts = new StringBuilder(tagsString); + if(ts.length() == 0) + return YMarkTables.BOOKMARK.TAGS.deflt(); // get rid of double commas and space characters following a comma for (int i = 0; i < ts.length()-1; i++) { if (ts.charAt(i) == TAGS_SEPARATOR.charAt(0)) { @@ -262,6 +263,8 @@ public class YMarkTables { public final static String cleanFoldersString(final String foldersString) { StringBuilder fs = new StringBuilder(cleanTagsString(foldersString)); + if(fs.length() == 0) + return YMarkTables.BOOKMARK.FOLDERS.deflt(); for (int i = 0; i < fs.length()-1; i++) { if (fs.charAt(i) == FOLDERS_SEPARATOR.charAt(0)) { if (fs.charAt(i+1) == TAGS_SEPARATOR.charAt(0) || fs.charAt(i+1) == FOLDERS_SEPARATOR.charAt(0)) { @@ -482,25 +485,16 @@ public class YMarkTables { for(int i=0; i 100) { buffer.append(topwords.get(i)); - /* - buffer.append('['); - buffer.append(words.get(topwords.get(i)).occurrences()); - buffer.append(']'); - */ - buffer.append(','); + buffer.append(YMarkTables.TAGS_SEPARATOR); } } - if(buffer.length() > 0) { - buffer.deleteCharAt(buffer.length()-1); - } - } catch (UnsupportedEncodingException e) { Log.logException(e); } catch (IOException e) { Log.logException(e); } } - return buffer.toString(); + return YMarkTables.cleanTagsString(buffer.toString()); } public static TreeMap getWordCounts(final Document document) { diff --git a/source/de/anomic/data/YMarksHTMLImporter.java b/source/de/anomic/data/YMarksHTMLImporter.java index da5f802aa..7dc3d5230 100644 --- a/source/de/anomic/data/YMarksHTMLImporter.java +++ b/source/de/anomic/data/YMarksHTMLImporter.java @@ -103,11 +103,12 @@ public class YMarksHTMLImporter extends HTMLEditorKit.ParserCallback implements final String url = (String)a.getAttribute(HTML.Attribute.HREF); this.bmk.put(YMarkTables.BOOKMARK.URL.key(), url); - for (YMarkTables.BOOKMARK bmk : YMarkTables.BOOKMARK.values()) { - final String s = (String)a.getAttribute(bmk.html_attrb()); + for (YMarkTables.BOOKMARK bmk : YMarkTables.BOOKMARK.values()) { + final String s = (String)a.getAttribute(bmk.html_attrb()); if(s != null) { switch(bmk) { case TAGS: + // mozilla shortcuturl this.bmk.put(bmk.key(), YMarkTables.cleanTagsString(s)); break; case DATE_ADDED: