From a3eebfdcbae494e5651c67f50fd819dacf52bb05 Mon Sep 17 00:00:00 2001 From: apfelmaennchen Date: Thu, 17 Nov 2011 23:11:27 +0000 Subject: [PATCH] YMarks: - show active/running crawls - execute crawls (works currently only if API entry is available) - various smaller fixes git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@8056 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/YMarks.html | 40 +------------- htroot/api/ymarks/get_ymark.java | 9 +++- htroot/api/ymarks/get_ymark.json | 8 +-- htroot/env/yacy-ymarks.css | 9 ++++ htroot/js/yacy-ymarks-bookmark-actions.js | 45 +++++++++++++--- htroot/js/yacy-ymarks.js | 54 +++++++++++-------- .../de/anomic/data/ymark/YMarkCrawlStart.java | 17 +++++- source/de/anomic/data/ymark/YMarkUtil.java | 2 + 8 files changed, 109 insertions(+), 75 deletions(-) diff --git a/htroot/YMarks.html b/htroot/YMarks.html index 860db8edc..cc59ee9d6 100644 --- a/htroot/YMarks.html +++ b/htroot/YMarks.html @@ -125,45 +125,7 @@
-
- -

Export file formathelp

-

- Netscape HTML
- Firefox JSON
- XBEL
- Surrogate XML
- YaCy Black/White List
-

-

- File name
-

-
-

Folder settingshelp

-

- Source folder - -

-

- Target folder - -

-
-

Include metadatahelp

-

- none -
- tags -
- ... -
- all -

-
-

- -

-
+
diff --git a/htroot/api/ymarks/get_ymark.java b/htroot/api/ymarks/get_ymark.java index b63c671e2..35cf81653 100644 --- a/htroot/api/ymarks/get_ymark.java +++ b/htroot/api/ymarks/get_ymark.java @@ -131,10 +131,17 @@ public class get_ymark { final YMarkCrawlStart crawlstart = new YMarkCrawlStart(sb.tables, bmk_row.get(YMarkEntry.BOOKMARK.URL.key(),YMarkEntry.BOOKMARK.URL.deflt())); int crawl = 0; - if (!crawlstart.isEmpty()) + if (!crawlstart.isEmpty()) { crawl = 1; + prop.put("json_"+count+"_crawlstart_info", "crawl start"); + } if (crawlstart.hasSchedule()) { crawl = 2; + prop.put("json_"+count+"_crawlstart_info", "scheduled crawl: "+YMarkDate.ISO8601(crawlstart.date_next_exec())); + } + if (crawlstart.isRunning(sb.crawler)) { + crawl = 3; + prop.put("json_"+count+"_crawlstart_info", "crawl is running"); } prop.put("json_"+count+"_crawlstart", crawl); diff --git a/htroot/api/ymarks/get_ymark.json b/htroot/api/ymarks/get_ymark.json index 4deb1e2db..751eeb6b2 100644 --- a/htroot/api/ymarks/get_ymark.json +++ b/htroot/api/ymarks/get_ymark.json @@ -12,9 +12,11 @@ #(crawlstart)# "" :: -"crawl start" +"#[info]#" :: -"scheduled crawl" +"#[info]#" +:: +"#[info]#" #(/crawlstart)#, "

#[title]#

#[desc]#

#[url]#", "

#[tags]#

", @@ -22,7 +24,7 @@ "

#[date_added]#

", "

#[date_modified]#

", "

#[date_visited]#

", -"#[apicall_pk]#", +"

#[apicall_pk]#

", "

#[date_recording]#

", "

#[date_next_exec]#

", "

#[date_last_exec]#

" diff --git a/htroot/env/yacy-ymarks.css b/htroot/env/yacy-ymarks.css index 64fb95b24..29620069b 100644 --- a/htroot/env/yacy-ymarks.css +++ b/htroot/env/yacy-ymarks.css @@ -179,6 +179,15 @@ img.help { .flexigrid div.fbutton .log-new { background: url(../../yacy/ui/img-2/new.png) no-repeat center left; } +.flexigrid div.fbutton .clock { + background: url(../../yacy/ui/img-2/clock.png) no-repeat center left; +} +.flexigrid div.fbutton .calendar { + background: url(../../yacy/ui/img-2/calendar.png) no-repeat center left; +} +.flexigrid div.fbutton .refresh { + background: url(../../yacy/ui/img/flexigrid/load.png) no-repeat center left; +} .flexigrid div.fbutton .log-more { /* background: url(../img/flexigrid/uup.png) no-repeat center left; */ margin-left: -20px; diff --git a/htroot/js/yacy-ymarks-bookmark-actions.js b/htroot/js/yacy-ymarks-bookmark-actions.js index 81748d7d4..ca4b20049 100644 --- a/htroot/js/yacy-ymarks-bookmark-actions.js +++ b/htroot/js/yacy-ymarks-bookmark-actions.js @@ -11,6 +11,7 @@ function bm_action(com,grid) { dataType: 'xml', success: function(xml) { $('#ymarks_flexigrid').flexReload(); + loadTreeView(); } }); // close $.ajax( }); //close each( @@ -36,14 +37,12 @@ function bm_action(com,grid) { $(autotags).find('tag').each(function(){ tags = tags + "," + $(this).attr('name'); }); - $("input[name='bm_tags']").setValue(tags); + $("input[name='bm_tags']").setValue(tags); } }); - }); $("#ymarks_add_dialog").dialog('open'); - } - else if (com=='Edit') { + } else if (com=='Edit') { if ($('.trSelected',grid).length > 1) { alert("Editing of more than one selected bookmark is currently not supportet!"); return false; @@ -55,9 +54,40 @@ function bm_action(com,grid) { $("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')); - $("#ymarks_add_dialog").dialog('open'); - } - else { + $("#ymarks_add_dialog").dialog('open'); + } else if (com=='Crawl') { + var param = []; + var count = 0; + var i = 0; + var err = ""; + var succ = ""; + var msg = ""; + $('.trSelected',grid).each(function() { + var pk = $(this).find('.apicall_pk').text(); + if (pk == "") { + count++; + err = err + "\n" + $(this).find('.url').text(); + } + succ = succ + "\n" + $(this).find('.url').text(); + var item = {name : 'item_'+count, value : "mark_"+pk}; + param[i] = item; + i++; + }); + if(i-count > 0) + msg = msg + "Success:"+succ; + if(count > 0) + msg = msg + "\n\nError: No entry in API Table found:"+err; + alert(msg); + param[param.length] = { name : 'execrows', value : 'true' }; + $.ajax({ + type: "POST", + data: param, + url: "Table_API_p.html", + dataType: "html", + success: function() { + } + }); + } else { alert("Sorry, the function you have requested is not yet available!"); return false; } @@ -90,6 +120,7 @@ function bm_dialog() { $("#bm_url").unbind('blur'); $("#ymarks_add_dialog").dialog("close"); $('#ymarks_flexigrid').flexReload(); + loadTreeView(); return false; } }); diff --git a/htroot/js/yacy-ymarks.js b/htroot/js/yacy-ymarks.js index 5c555d3f8..16cdf11cb 100644 --- a/htroot/js/yacy-ymarks.js +++ b/htroot/js/yacy-ymarks.js @@ -16,7 +16,7 @@ $(document).ready(function() { colModel: [ {display: 'Hash', name : 'hash', width : 85, sortable : false, align: 'left', hide: true}, {display: 'Public', name : 'public', width : 20, sortable : true, align: 'center'}, - {display: 'Crawl start', name : 'crawl_start', width : 20, sortable : true, align: 'center'}, + {display: 'Crawl start', name : 'crawl_start', width : 20, sortable : false, align: 'center'}, {display: 'Title', name : 'title', width : 400, sortable : true, align: 'left'}, {display: 'Tags', name : 'tags', width : 160, sortable : false, align: 'left'}, {display: 'Folders', name : 'folders', width : 160, sortable : true, align: 'left', hide: true}, @@ -24,12 +24,12 @@ $(document).ready(function() { {display: 'Date modified', name : 'date_modified', width : 100, sortable : true, align: 'left'}, {display: 'Date visited', name : 'date_visited', width : 100, sortable : true, align: 'left', hide: true}, {display: 'API PK', name : 'apicall_pk', width : 85, sortable : true, align: 'left', hide: true}, - {display: 'Date recording', name : 'date_recording', width : 100, sortable : true, align: 'left', hide: true}, - {display: 'Date next exec', name : 'date_next_exec', width : 100, sortable : true, align: 'left', hide: true}, - {display: 'Date last exec', name : 'date_last_exec', width : 100, sortable : true, align: 'left', hide: true} + {display: 'Date recording', name : 'date_recording', width : 100, sortable : false, align: 'left', hide: true}, + {display: 'Date next exec', name : 'date_next_exec', width : 100, sortable : false, align: 'left', hide: true}, + {display: 'Date last exec', name : 'date_last_exec', width : 100, sortable : false, align: 'left', hide: true} ], buttons: [ - {name: '...', bclass: 'burst', onpress: function() { + {name: '...', bclass: 'refresh', onpress: function() { $('#ymarks_flexigrid').flexOptions({ sortname: "title", sortorder: "asc", @@ -37,6 +37,8 @@ $(document).ready(function() { qtype: "title" }); $('#ymarks_flexigrid').flexReload(); + loadTreeView(); + }}, {separator: true}, {name: 'Add', bclass: 'bookmark', onpress: bm_action}, @@ -44,6 +46,7 @@ $(document).ready(function() { {name: 'Delete', bclass: 'delete', onpress: bm_action}, {separator: true}, {name: 'Crawl', bclass: 'crawl', onpress: bm_action}, + {name: 'Schedule', bclass: 'calendar', onpress: bm_action}, {separator: true}, {name: 'Add', bclass: 'addTag', onpress: tag_action}, {name: 'Rename', bclass: 'editTag', onpress: tag_action}, @@ -91,24 +94,7 @@ $(document).ready(function() { return true; }); - $("#ymarks_treeview").treeview({ - url: "/api/ymarks/get_treeview.json?bmtype=href", - unique: true, - persist: "location" - }); - - $("#ymarks_treeview").bind("click", function(event) { - if ($(event.target).is("li") || $(event.target).parents("li").length) { - var folder = $(event.target).parents("li").filter(":first").attr("id"); - $('#ymarks_flexigrid').flexOptions({ - query: folder, - qtype: "_folder", - newp: 1 - }); - $('#ymarks_flexigrid').flexReload(); - return false; - } - }); + loadTreeView(); $('input[name=importer]').change(function() { if ($("input[name=importer]:checked").val() == 'crawls') { @@ -160,3 +146,25 @@ function loadTagCloud() { } }); //close $.ajax( }; + +function loadTreeView() { + $("#ymarks_treeview").empty(); + $("#ymarks_treeview").treeview({ + url: "/api/ymarks/get_treeview.json?bmtype=href", + unique: true, + persist: "location" + }); + + $("#ymarks_treeview").bind("click", function(event) { + if ($(event.target).is("li") || $(event.target).parents("li").length) { + var folder = $(event.target).parents("li").filter(":first").attr("id"); + $('#ymarks_flexigrid').flexOptions({ + query: folder, + qtype: "_folder", + newp: 1 + }); + $('#ymarks_flexigrid').flexReload(); + return false; + } + }); +} diff --git a/source/de/anomic/data/ymark/YMarkCrawlStart.java b/source/de/anomic/data/ymark/YMarkCrawlStart.java index c83013a45..650918f3a 100644 --- a/source/de/anomic/data/ymark/YMarkCrawlStart.java +++ b/source/de/anomic/data/ymark/YMarkCrawlStart.java @@ -34,6 +34,8 @@ import java.util.regex.Pattern; import net.yacy.cora.document.UTF8; import net.yacy.kelondro.blob.Tables; +import de.anomic.crawler.CrawlProfile; +import de.anomic.crawler.CrawlSwitchboard; import de.anomic.data.WorkTables; public class YMarkCrawlStart extends HashMap{ @@ -45,8 +47,7 @@ public class YMarkCrawlStart extends HashMap{ private Date date_recording; private String apicall_pk; private String url; - - + public YMarkCrawlStart(final WorkTables worktables) { super(); this.date_recording = new Date(0); @@ -87,6 +88,18 @@ public class YMarkCrawlStart extends HashMap{ return false; } + public boolean isRunning(final CrawlSwitchboard crawler) { + final Iterator iter = crawler.getActive().iterator(); + while(iter.hasNext()) { + final byte[] key = iter.next(); + final CrawlProfile crawl = crawler.getActive(key); + if (crawl.startURL().equals(this.url)) { + return true; + } + } + return false; + } + public Date date_recording() { return this.date_recording; } diff --git a/source/de/anomic/data/ymark/YMarkUtil.java b/source/de/anomic/data/ymark/YMarkUtil.java index bd61978b5..3b4dbe862 100644 --- a/source/de/anomic/data/ymark/YMarkUtil.java +++ b/source/de/anomic/data/ymark/YMarkUtil.java @@ -105,6 +105,8 @@ public class YMarkUtil { } public final static String cleanFoldersString(final String foldersString) { + if(foldersString.isEmpty()) + return YMarkEntry.BOOKMARK.FOLDERS.deflt(); StringBuilder fs = new StringBuilder(cleanTagsString(foldersString)); if(fs.length() == 0) return YMarkEntry.BOOKMARK.FOLDERS.deflt();