various small changes to ymarks

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7339 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
apfelmaennchen 14 years ago
parent 8a50670546
commit 737aaf6952

@ -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)#::
<form action="Table_YMark_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8" id="tablelisting">
<fieldset>
<legend><label for="tablelisting">Table Editor: showing table '#[table]#'</label></legend>
<legend><label for="tablelisting">Table Editor: showing table '#[table]#' containing #[bmksize]# bookmarks with #[tagsize]# tags in #[foldersize]# folders
</label></legend>
<p>
<input type="hidden" name="table" value="#[table]#" />
<input type="hidden" name="num" value="#[num]#" />
@ -159,7 +160,7 @@
<select name="tags" style="width: 180px" onchange='this.form.submit()' id="tags">
<option value="" selected="selected">select a tag</option>
#{tags}#
<option value="#[tagName]#">#[tagName]#</option>
<option value="#[tagName]#">#[tagName]# [#[tagCount]#]</option>
#{/tags}#
</select>
</dd>
@ -170,7 +171,7 @@
<select name="folders" style="width: 180px" onchange='this.form.submit()' id="folders">
<option value="" selected="selected">select a folder</option>
#{folders}#
<option value="#[folderName]#">#[folderName]#</option>
<option value="#[folderName]#">#[folderName]# [#[folderCount]#]</option>
#{/folders}#
</select>
</dd>

@ -57,12 +57,15 @@ public class Table_YMark_p {
// get available tags and folders
count = 0;
byte[] key;
String name;
try {
Iterator<byte[]> 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

@ -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<String, String> 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()));
}
}
}

@ -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<count && i<topwords.size() ; i++) {
if(words.get(topwords.get(i)).occurrences() > 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<String,Word> getWordCounts(final Document document) {

@ -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:

Loading…
Cancel
Save