Merge branch 'master' of git://github.com/f1ori/yacy

pull/1/head
admin 13 years ago
commit 005d0c7ddd

@ -146,8 +146,8 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
<input type="radio" name="importer" value="surro" /> Surrogate XML<br />
<input type="radio" name="importer" value="dmoz" disabled="disabled" /> DMOZ XML<br />
<input type="radio" name="importer" value="list" disabled="disabled"/> YaCy White/Black List<br />
<input type="radio" name="importer" value="bmks" /> YaCy old bookmarks.db<br />
<input type="radio" name="importer" value="crawls" /> YaCy Crawl Starts<br />
<input type="radio" name="importer" value="bmks" /> YaCy old bookmarks.db (admin)<br />
<input type="radio" name="importer" value="crawls" /> YaCy Crawl Starts (admin)<br />
</p>
<p>
<small>Bookmark file</small>
@ -194,32 +194,33 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
</div>
<!-- Bookmarks Edit Dialog -->
<div id="ymarks_add_dialog" class="bm_dialog" title="Add & Edit Bookmark">
<div id="ymarks_add_dialog" class="bm_dialog" title="Add & Edit Bookmark">
<img id="bmaddimg" src="/yacy/ui/img-1/Star.png" />
<form id="bmaddform" method="post" accept-charset="UTF-8" action="jQuery"><div>
<label for="bm_url">URL:</label>
<br />
<input type="text" name="bm_url" id="bm_url" class="bm_input" size="80" />
<input type="text" name="url" id="bm_url" class="bm_input" size="80" />
<br />
<label for="bm_title">Title:</label>
<br />
<input type="text" name="bm_title" id="bm_title" class="bm_input" size="80" />
<input type="text" name="title" id="bm_title" class="bm_input" size="80" />
<br />
<label for="bm_desc">Description:</label>
<br />
<textarea name="bm_desc" id="bm_desc" class="bm_input" rows="3" cols="20">
<textarea name="desc" id="bm_desc" class="bm_input" rows="3" cols="20">
</textarea>
<br />
<label for="bm_path">Folder (/folder/subfolder):</label>
<br />
<input type="text" name="bm_path" id="bm_path" class="bm_input" size="80" />
<input type="text" name="folders" id="bm_path" class="bm_input" size="80" />
<br />
<label for="bm_tags">Tags (comma separated):</label>
<br />
<input type="text" name="bm_tags" id="bm_tags" class="bm_input" size="80" />
<input type="text" name="tags" id="bm_tags" class="bm_input" size="80" />
<br />
<label for="bm_public">Public:</label>
<br />
<select name="bm_public" id="bm_public" class="bm_select">
<select name="public" id="bm_public" class="bm_select">
<option value="true">yes</option>
<option value="false">no</option>
</select>

@ -36,7 +36,7 @@ public class add_ymark {
if(post.containsKey("urlHash")) {
final String urlHash = post.get("urlHash",YMarkUtil.EMPTY_STRING);
final DigestURI url = sb.indexSegments.segment(Segments.Process.PUBLIC).urlMetadata().load(urlHash.getBytes()).metadata().url();
final String folders = post.get(YMarkEntry.BOOKMARK.FOLDERS.key(),YMarkEntry.FOLDERS_UNSORTED);
final String folders = post.get(YMarkEntry.BOOKMARK.FOLDERS.key(),YMarkEntry.BOOKMARK.FOLDERS.deflt());
final String tags = post.get(YMarkEntry.BOOKMARK.TAGS.key(),YMarkUtil.EMPTY_STRING);
try {
sb.tables.bookmarks.createBookmark(sb.loader, url, bmk_user, true, tags, folders);
@ -66,13 +66,13 @@ public class add_ymark {
}
final YMarkEntry bmk = new YMarkEntry();
bmk.put(YMarkEntry.BOOKMARK.URL.key(), url);
bmk.put(YMarkEntry.BOOKMARK.TITLE.key(), post.get(YMarkEntry.BOOKMARK.TITLE.key(),YMarkEntry.BOOKMARK.TITLE.deflt()));
bmk.put(YMarkEntry.BOOKMARK.DESC.key(), post.get(YMarkEntry.BOOKMARK.DESC.key(),YMarkEntry.BOOKMARK.DESC.deflt()));
bmk.put(YMarkEntry.BOOKMARK.PUBLIC.key(), post.get(YMarkEntry.BOOKMARK.PUBLIC.key(),YMarkEntry.BOOKMARK.PUBLIC.deflt()));
bmk.put(YMarkEntry.BOOKMARK.TAGS.key(), YMarkUtil.cleanTagsString(post.get(YMarkEntry.BOOKMARK.TAGS.key(),YMarkEntry.BOOKMARK.TAGS.deflt())));
bmk.put(YMarkEntry.BOOKMARK.FOLDERS.key(), YMarkUtil.cleanFoldersString(post.get(YMarkEntry.BOOKMARK.FOLDERS.key(),YMarkEntry.FOLDERS_UNSORTED)));
bmk.put(YMarkEntry.BOOKMARK.TAGS.key(), YMarkUtil.cleanTagsString(post.get(YMarkEntry.BOOKMARK.TAGS.key(),YMarkEntry.BOOKMARK.TAGS.deflt()),YMarkEntry.BOOKMARK.TAGS.deflt()));
bmk.put(YMarkEntry.BOOKMARK.FOLDERS.key(), YMarkUtil.cleanFoldersString(post.get(YMarkEntry.BOOKMARK.FOLDERS.key(),YMarkEntry.BOOKMARK.FOLDERS.deflt()),YMarkEntry.BOOKMARK.FOLDERS.deflt()));
try {
sb.tables.bookmarks.addBookmark(bmk_user, bmk, false, false);

@ -7,6 +7,7 @@ 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.logging.Log;
import net.yacy.search.Switchboard;
import de.anomic.data.UserDB;
import de.anomic.data.ymark.YMarkAutoTagger;
@ -33,7 +34,6 @@ public class get_metadata {
final String bmk_user = (isAuthUser ? user.getUserName() : YMarkTables.USER_ADMIN);
String url = post.get(YMarkEntry.BOOKMARK.URL.key(),YMarkEntry.BOOKMARK.URL.deflt());
boolean hasProtocol = false;
for (final YMarkTables.PROTOCOLS p : YMarkTables.PROTOCOLS.values()) {
@ -70,15 +70,18 @@ public class get_metadata {
}
prop.put("crawlstart", count);
} catch (final MalformedURLException e1) {
} catch (final MalformedURLException e) {
// TODO Auto-generated catch block
e1.printStackTrace();
Log.logException(e);
prop.put("status", "error");
} catch (final IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.logException(e);
prop.put("status", "error");
} catch (final Failure e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.logException(e);
prop.put("status", "error");
}
} else {
prop.put(YMarkTables.USER_AUTHENTICATE,YMarkTables.USER_AUTHENTICATE_MSG);

@ -1,5 +1,5 @@
<?xml version='1.0' encoding="UTF-8" standalone='yes'?>
<info>
<info status="#[status]#">
<title>#[title]#</title>
<desc>#[desc]#</desc>
<keywords>
@ -15,4 +15,5 @@
#{/crawlstart}#
>
</crawlstart>
</info>
</info>

@ -104,7 +104,14 @@ public class get_treeview {
if (foldername.length == n+1) {
prop.put("folders_"+count+"_foldername", foldername[n]);
prop.put("folders_"+count+"_expanded", "false");
prop.put("folders_"+count+"_type", "folder");
if(foldername[n].equals("IOExceptions"))
prop.put("folders_"+count+"_type", "err");
else if(foldername[n].equals("unsorted"))
prop.put("folders_"+count+"_type", "question");
else if(foldername[n].equals("Crawl Start"))
prop.put("folders_"+count+"_type", "crawl");
else
prop.put("folders_"+count+"_type", "folder");
prop.put("folders_"+count+"_hash", folder); //TODO: switch from pathString to folderHash
prop.put("folders_"+count+"_url", ""); //TODO: insert folder url
prop.put("folders_"+count+"_hasChildren", "true"); //TODO: determine if folder has children

@ -5,6 +5,7 @@ import java.util.regex.Pattern;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.document.parser.html.CharacterCoding;
import net.yacy.kelondro.blob.Tables;
import net.yacy.kelondro.blob.Tables.Row;
import net.yacy.kelondro.logging.Log;

@ -142,6 +142,10 @@ public class import_ymark {
}
}
} else if(post.containsKey("importer") && post.get("importer").equals("crawls")) {
if(!isAdmin) {
prop.put(YMarkTables.USER_AUTHENTICATE,YMarkTables.ADMIN_AUTHENTICATE_MSG);
return prop;
}
try {
final Pattern pattern = Pattern.compile("^crawl start for.*");
final Iterator<Tables.Row> APIcalls = sb.tables.iterator(WorkTables.TABLE_API_NAME, WorkTables.TABLE_API_COL_COMMENT, pattern);
@ -165,6 +169,10 @@ public class import_ymark {
e.printStackTrace();
}
} else if(post.containsKey("importer") && post.get("importer").equals("bmks")) {
if(!isAdmin) {
prop.put(YMarkTables.USER_AUTHENTICATE,YMarkTables.ADMIN_AUTHENTICATE_MSG);
return prop;
}
final Iterator<String> bit=sb.bookmarksDB.getBookmarksIterator(isAdmin);
BookmarksDB.Bookmark bookmark;
while(bit.hasNext()){

@ -210,20 +210,19 @@ img.help {
/* overrides for treeview styles
-------------------------------------*/
.filetree span.tag {
background: url(../img/tags/tag_blue.png) 0 0 no-repeat;
.filetree span.err {
background: url(/yacy/ui/img-2/stop.png) 0 0 no-repeat;
padding: 1px 0px 0px 18px;
display: block;
}
.filetree span.topword {
background: url(../img/flexigrid/magnifier.png) 0 0 no-repeat;
.filetree span.question {
background: url(/yacy/ui/img-2/question_blue.png) 0 0 no-repeat;
padding: 1px 0px 0px 18px;
display: block;
}
.filetree ul, .filetree li {
background-color: transparent;
.filetree span.crawl {
background: url(/yacy/ui/img/crawl.png) 0 0 no-repeat;
padding: 1px 0px 0px 18px;
display: block;
}
.tagSelect {
width: 220px;
}

@ -19,25 +19,32 @@ function bm_action(com,grid) {
}
else if (com=='Add') {
$('#bmaddform').resetForm();
$("input[name='bm_url']").removeAttr("disabled");
$("#bm_url").removeAttr("disabled");
$("#bm_url").blur(function() {
var url = $("input[name='bm_url']").getValue();
var url = $("#bm_url").getValue();
$.ajax({
type: "GET",
url: "/api/ymarks/get_metadata.xml?url="+url,
dataType: "xml",
success: function(xml) {
var title = $(xml).find('title').text();
$("input[name='bm_title']").setValue(title);
var desc = $(xml).find('desc').text();
$("textarea[name='bm_desc']").setValue(desc);
var autotags = $(xml).find('autotags')
var title = "";
var desc = "";
var tags = "";
$(autotags).find('tag').each(function(){
tags = tags + "," + $(this).attr('name');
});
$("input[name='bm_tags']").setValue(tags);
if ($(xml).find('info').attr('status') === "error") {
$("#bmaddimg").attr("src","/yacy/ui/img-1/Smiley Star Sad.png");
} else {
var autotags = $(xml).find('autotags')
title = $(xml).find('title').text();
desc = $(xml).find('desc').text();
tags = "";
$(autotags).find('tag').each(function(){
tags = tags + "," + $(this).attr('name');
});
$("#bmaddimg").attr("src","/yacy/ui/img-1/Smiley Star.png");
}
$("#bm_title").setValue(title);
$("#bm_desc").setValue(desc);
$("#bm_tags").setValue(tags);
}
});
});
@ -47,13 +54,13 @@ function bm_action(com,grid) {
alert("Editing of more than one selected bookmark is currently not supportet!");
return false;
}
$("input[name='bm_url']").attr("disabled","disabled");
$("input[name='bm_url']").setValue($('.trSelected',grid).find('.url').text());
$("input[name='bm_title']").setValue($('.trSelected',grid).find('h3.linktitle').text().trim());
$("textarea[name='bm_desc']").setValue($('.trSelected',grid).find('p.desc').text().trim());
$("input[name='bm_tags']").setValue($('.trSelected',grid).find('p.tags').text().trim().replace(/,\s/g,","));
$("input[name='bm_path']").setValue($('.trSelected',grid).find('p.folders').text().replace(/,\s/g,","));
$("select[name='bm_public']").setValue($('.trSelected',grid).find('img').attr('alt'));
$("#bm_url").attr("disabled","disabled");
$("#bm_url").setValue($('.trSelected',grid).find('.url').text());
$("#bm_title").setValue($('.trSelected',grid).find('h3.linktitle').text().trim());
$("#bm_desc").setValue($('.trSelected',grid).find('p.desc').text().trim());
$("#bm_tags").setValue($('.trSelected',grid).find('p.tags').text().trim().replace(/,\s/g,","));
$("#bm_path").setValue($('.trSelected',grid).find('p.folders').text().replace(/,\s/g,","));
$("#bm_public").setValue($('.trSelected',grid).find('img').attr('alt'));
$("#ymarks_add_dialog").dialog('open');
} else if (com=='Crawl') {
if ($('.trSelected',grid).length == 1 && $(this).find('.apicall_pk').text() == "") {
@ -107,23 +114,24 @@ function bm_dialog() {
/* Initialize Bookmark Dialog */
$("#ymarks_add_dialog").dialog({
autoOpen: false,
height: 420,
height: 450,
width: 340,
position: ['top',100],
modal: true,
resizable: false,
buttons: {
OK: function() {
var url = $("input[name='bm_url']").getValue();
var title = $("input[name='bm_title']").getValue();
var desc = $("textarea[name='bm_desc']").getValue();
var tags = $("input[name='bm_tags']").getValue()
var path = $("input[name='bm_path']").getValue();
var pub = $("select[name='bm_public']").getValue();
var param = [];
var i = 0;
$("#bmaddform input,#bmaddform select,#bm_desc").each(function() {
var item = {name : $(this).attr("name"), value : $(this).attr("value")};
param[i] = item;
i++;
});
$.ajax({
type: "POST",
url: "/api/ymarks/add_ymark.xml",
data: "url="+url+"&title="+title+"&desc="+desc+"&tags="+tags+"&folders="+path+"&public="+pub,
data: param,
dataType: "xml",
success: function(xml) {
$('#bmaddform').resetForm();

@ -216,7 +216,7 @@ function loadTags(select, sortorder, tags) {
$(xml).find('tag').each(function(){
var count = $(this).attr('count');
var tag = $(this).attr('tag');
$('<option value="'+tag+'">'+tag+' ['+count+']</option>').appendTo(select);
$('<option value="'+tag+'">'+HTMLenc(tag)+' ['+count+']</option>').appendTo(select);
}); //close each(
$(select).multiselect('refresh');
}

@ -16,7 +16,6 @@ public class YMarkEntry extends TreeMap<String, String> {
public static final String BOOKMARKS_ID = "id";
public static final String BOOKMARKS_REF = "ref";
public static final String FOLDERS_IMPORTED = "/imported";
public static final String FOLDERS_UNSORTED = "/unsorted";
public static enum BOOKMARK {
// key dc_attrb dflt html_attrb xbel_attrb json_attrb type

@ -88,7 +88,8 @@ public class YMarkTables {
public final static String BOOKMARKS_LOG = "BOOKMARKS";
public final static String USER_ADMIN = "admin";
public final static String USER_AUTHENTICATE = "AUTHENTICATE";
public final static String USER_AUTHENTICATE_MSG = "Authentication required!";
public final static String USER_AUTHENTICATE_MSG = "Bookmark user authentication required!";
public final static String ADMIN_AUTHENTICATE_MSG = "Admin authentication required!";
public final static String p1 = "(?:^|.*,)";
public final static String p2 = "\\Q";
@ -299,7 +300,11 @@ public class YMarkTables {
bmk_entry.put(YMarkEntry.BOOKMARK.TITLE.key(), metadata.get(YMarkMetadata.METADATA.TITLE));
bmk_entry.put(YMarkEntry.BOOKMARK.DESC.key(), metadata.get(YMarkMetadata.METADATA.DESCRIPTION));
}
bmk_entry.put(YMarkEntry.BOOKMARK.FOLDERS.key(), YMarkUtil.cleanFoldersString(foldersString));
final String fs = YMarkUtil.cleanFoldersString(foldersString);
if(fs.isEmpty())
bmk_entry.put(YMarkEntry.BOOKMARK.FOLDERS.key(), YMarkEntry.BOOKMARK.FOLDERS.deflt());
else
bmk_entry.put(YMarkEntry.BOOKMARK.FOLDERS.key(), fs);
final StringBuilder strb = new StringBuilder();
if(autotag) {
final String autotags = YMarkAutoTagger.autoTag(document, 3, this.worktables.bookmarks.getTags(bmk_user));

@ -36,7 +36,7 @@ import net.yacy.kelondro.data.word.Word;
public class YMarkUtil {
public final static String TAGS_SEPARATOR = ",";
public final static String FOLDERS_SEPARATOR = "/";
public final static String EMPTY_STRING = "";
public final static String EMPTY_STRING = new String();
/**
* conveniance function to generate url hashes for YMark bookmarks
@ -83,11 +83,15 @@ public class YMarkUtil {
}
return keySet;
}
public final static String cleanTagsString(final String tagsString) {
return cleanTagsString(tagsString, YMarkUtil.EMPTY_STRING);
}
public final static String cleanTagsString(final String tagsString) {
public final static String cleanTagsString(final String tagsString, final String dflt) {
StringBuilder ts = new StringBuilder(tagsString);
if(ts.length() == 0)
return YMarkUtil.EMPTY_STRING;
return dflt;
// 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)) {
@ -105,9 +109,13 @@ public class YMarkUtil {
return ts.toString();
}
public final static String cleanFoldersString(final String foldersString) {
public final static String cleanFoldersString(final String foldersString) {
return cleanFoldersString(foldersString, YMarkUtil.EMPTY_STRING);
}
public final static String cleanFoldersString(final String foldersString, final String dflt) {
if(foldersString.isEmpty())
return YMarkUtil.EMPTY_STRING;
return dflt;
StringBuilder fs = new StringBuilder(cleanTagsString(foldersString));
if(fs.length() == 0)
return YMarkEntry.BOOKMARK.FOLDERS.deflt();

Loading…
Cancel
Save