Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
add interaction for triples and selector for augmented browsing
cominch9ef5a80f4ef4
diff --git a/htroot/AugmentedBrowsingFilters_p.html b/htroot/AugmentedBrowsingFilters_p.htmlindex e135ea437..096bc8665 100644--- a/htroot/AugmentedBrowsingFilters_p.html+++ b/htroot/AugmentedBrowsingFilters_p.html@@ -51,6 +51,14 @@</p></dd>+ <dt><label for="content">Show overlay interaction buttons:</label></dt>+ <dd>+ <input type="checkbox" name="overlayInteraction" id="overlayInteraction" #(overlayInteraction_checked)#:: checked="checked"#(/overlayInteraction_checked)# />Enabled<br/>+ <p class="help">+ Show overlay interaction buttons for sciety.+ </p>+ </dd>+<!-- <dt><label for="content">Add unique IDs to every node:</label></dt><dd><input type="checkbox" name="augmentedReparseAdduniqueid" id="augmentedReparseAdduniqueid" #(augmentedReparseAdduniqueid_checked)#:: checked="checked"#(/augmentedReparseAdduniqueid_checked)# />Enabled<br/>diff --git a/htroot/AugmentedBrowsingFilters_p.java b/htroot/AugmentedBrowsingFilters_p.javaindex 39b57d1e8..0ac474f62 100644--- a/htroot/AugmentedBrowsingFilters_p.java+++ b/htroot/AugmentedBrowsingFilters_p.java@@ -23,6 +23,9 @@ public final class AugmentedBrowsingFilters_p {env.setConfig("augmentation.reparse", "on".equals(post.get("augmentedReparse")) ? true : false);+ env.setConfig("interaction.overlayinteraction.enabled", "on".equals(post+ .get("overlayInteraction")) ? true : false);+// env.setConfig("augmentation.reparse.adduniqueid", "on".equals(post// .get("augmentedReparseAdduniqueid")) ? true : false);//@@ -45,6 +48,9 @@ public final class AugmentedBrowsingFilters_p {prop.put("augmentedReparse_checked",env.getConfigBool("augmentation.reparse", true) ? "1" : "0");+ prop.put("overlayInteraction_checked",+ env.getConfigBool("interaction.overlayinteraction.enabled", true) ? "1" : "0");+// prop.put("augmentedReparseAdduniqueid_checked",// env.getConfigBool("augmentation.reparse.adduniqueid", true) ? "1" : "0");//diff --git a/htroot/interaction/OverlayInteraction.html b/htroot/interaction/OverlayInteraction.htmlindex 7bed90baf..30705b9fe 100644--- a/htroot/interaction/OverlayInteraction.html+++ b/htroot/interaction/OverlayInteraction.html@@ -7,9 +7,8 @@font: arial,helvetica,sans-serif;font-size: 10px;position: fixed;-top: 70px;right: 0;-background: #610B5E;+background: #ffffff;border:1px solid #111111;-moz-border-radius-topleft: 20px;-webkit-border-top-left-radius: 20px;@@ -55,7 +54,7 @@ border-bottom: 1px solid #ffffff;<div id="sidebar-document" class="sci_panel" style="top: 70px;">-document <img src="/currentyacypeer/env/grafics/bad.png" onclick="contribution (document.location.href, 'like source', '#[username]#'); return false">+<p>document</p> <img src="/currentyacypeer/env/grafics/bad.png" onclick="contribution (document.location.href, 'like document', '#[username]#'); return false"></div>diff --git a/htroot/interaction/Triple.java b/htroot/interaction/Triple.javanew file mode 100644index 000000000..94c584ca1--- /dev/null+++ b/htroot/interaction/Triple.java@@ -0,0 +1,90 @@+package interaction;++//ViewLog_p.java+//-----------------------+//part of the AnomicHTTPD caching proxy+//(C) by Michael Peter Christen; [email protected]+//first published on http://www.anomic.de+//Frankfurt, Germany, 2004+//+//This File is contributed by Alexander Schier+//last major change: 14.12.2004+//+//This program is free software; you can redistribute it and/or modify+//it under the terms of the GNU General Public License as published by+//the Free Software Foundation; either version 2 of the License, or+//(at your option) any later version.+//+//This program is distributed in the hope that it will be useful,+//but WITHOUT ANY WARRANTY; without even the implied warranty of+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+//GNU General Public License for more details.+//+//You should have received a copy of the GNU General Public License+//along with this program; if not, write to the Free Software+//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+++//You must compile this file with+//javac -classpath .:../classes ViewLog_p.java+//if the shell's current path is HTROOT++import net.yacy.cora.protocol.RequestHeader;+import net.yacy.interaction.Interaction;+import net.yacy.search.Switchboard;+import de.anomic.server.serverObjects;+import de.anomic.server.serverSwitch;++public class Triple {++ public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {++ final Switchboard sb = (Switchboard) env;++ final serverObjects prop = new serverObjects();++ String url = "";+ String s = "";+ String p = "";+ String o = "";+ String from = "";++ if(post != null){++ if(post.containsKey("url")){+ url = post.get("url");+ }++ if(post.containsKey("s")){+ s = post.get("s");+ }++ if(post.containsKey("p")){+ p = post.get("p");+ }++ if(post.containsKey("o")){+ o = post.get("o");+ }++ if(post.containsKey("from")){+ from = post.get("from");+ }++ }++ if (post.containsKey("comment")) {+++ Interaction.Triple(url, s, p, o, from);++ } else {++ prop.putHTML("url", url);++ }+++ return prop;+ }+}diff --git a/htroot/interaction/Triple.json b/htroot/interaction/Triple.jsonnew file mode 100644index 000000000..d9b957270--- /dev/null+++ b/htroot/interaction/Triple.json@@ -0,0 +1,4 @@+{+ "url": "#[url]#"+ "comment": "#[comment]#"+}\ No newline at end of filediff --git a/htroot/interaction/interaction.js b/htroot/interaction/interaction.jsnew file mode 100644index 000000000..8f61cd4cd--- /dev/null+++ b/htroot/interaction/interaction.js@@ -0,0 +1,34 @@+function feedback (url, comment, from) {++ $.getJSON('/currentyacypeer/interaction/Feedback.json?url='+url+'&comment='+comment+'&from='+from, function(data) {++ });++}++function suggest (url) {++ $.getJSON('/currentyacypeer/interaction/Suggest.json?url='+url, function(data) {+++ });++}++function contribution (url, comment, username) {++ $.getJSON('/currentyacypeer/interaction/Contribution.json?url='+url+'&comment='+comment+'&from='+username, function(data) {+++ });++}++function triple (url, s, p, o, username) {++ $.getJSON('/currentyacypeer/interaction/Triple.json?url='+url+'&s='+s+'&p='+p+'&o='+o+'&from='+username, function(data) {+++ });++}\ No newline at end of filediff --git a/source/net/yacy/interaction/Interaction.java b/source/net/yacy/interaction/Interaction.javanew file mode 100644index 000000000..285537b50--- /dev/null+++ b/source/net/yacy/interaction/Interaction.java@@ -0,0 +1,561 @@+package net.yacy.interaction;++import java.io.IOException;+import java.net.MalformedURLException;+import java.util.HashMap;+import java.util.Map;++import net.yacy.cora.document.UTF8;+import net.yacy.cora.protocol.http.HTTPClient;+import net.yacy.kelondro.blob.Tables;+import net.yacy.kelondro.data.meta.DigestURI;+import net.yacy.kelondro.index.RowSpaceExceededException;+import net.yacy.kelondro.logging.Log;+import net.yacy.peers.Seed;+import net.yacy.search.Switchboard;+import java.util.UUID;++import org.apache.http.entity.mime.content.ContentBody;++import com.hp.hpl.jena.rdf.model.Property;+import com.hp.hpl.jena.rdf.model.Resource;+++public class Interaction {++// public static String GetInteractionData (String url) {+//+//+// // Fetch information from external sciencenet server+//+// // TODO: Use internal database+//+// Log.logInfo("INTERACTION", "GetInteractionData: "+url);+// try {+// return (UTF8.String(new HTTPClient().GETbytes("http://sciencenet.kit.edu/GetDomainInfoJSON?DomainURL="+url)));+// } catch (IOException e) {+// // TODO Auto-generated catch block+// e.printStackTrace();+// return "";+// }+//+// }+++ public static String GetDomain (String url) {++ String domain = url;++ try {+ DigestURI uri = new DigestURI (url);++ domain = uri.getHost();+ } catch (MalformedURLException e) {+ // TODO Auto-generated catch block+ e.printStackTrace();+ }+ return domain;++ }++// public static boolean IsInBookmarks (String domain) {+//+//+// // TODO: Check if this bookmark exists+//+// Boolean result = false;+//+// DigestURI uri;+// try {+// uri = new DigestURI (domain);+//+// Bookmark b = Switchboard.getSwitchboard().bookmarksDB.getBookmark(UTF8.String(uri.hash()));+//+// if (!(b == null)) {+// result = true;+// }+//+//+// } catch (MalformedURLException e) {+// // TODO Auto-generated catch block+// e.printStackTrace();+// }+//+// return result;+//+// }++// public static boolean SaveDomainVote (String domain, String vote) {+//+//+// // TODO: Check if this bookmark exists+//+// Boolean result = false;+//+// DigestURI uri;+// try {+// uri = new DigestURI (domain);+//+// Bookmark b = Switchboard.getSwitchboard().bookmarksDB.getBookmark(UTF8.String(uri.hash()));+//+// if (!(b == null)) {+// b.addTag(vote);+// Switchboard.getSwitchboard().bookmarksDB.saveBookmark(b);+// } else {+// Bookmark b2 = Switchboard.getSwitchboard().bookmarksDB.createBookmark(domain, "admin");+//+// b2.addTag(vote);+//+// Switchboard.getSwitchboard().bookmarksDB.saveBookmark(b2);+// }+//+//+// } catch (MalformedURLException e) {+// // TODO Auto-generated catch block+// e.printStackTrace();+// }+//+// return result;+//+// }++// public static boolean DomainWhite (String domain, String username) {+//+//+// // Add userinteraction+//+// Boolean result = false;+//+//// Bookmark b = Interaction.Suggest(domain, username);+////+//// //+//+// return result;+//+// }++// public static Usercontribution DoUsercontribution(String domain, String uc,+// String username) {+//+// final Switchboard sb = Switchboard.getSwitchboard();+//+// Boolean existing = false;+//+// if (username == "") {+// username = "anonymous";+// }+//+// Usercontribution result = null;+//+// if (!existing) {+//+// Boolean reject = false;+//+//+//+//+// // count elements+// Iterator<String> it = sb.usercontributionsDB.getFeedbackitemsIterator(true);+//+// int count = 0;+// while(it.hasNext()) {+// it.next();+// count++;+// }+//+//+// if (count > 500) {+// if (username.equals("crawlbot")) {+// reject = true;+// }+//+// }+//+// if (!reject) {+//+// try {+//+// Usercontribution new_uc = Switchboard.getSwitchboard().usercontributionsDB+// .createUsercontribution(UUID.randomUUID().toString(),+// username);+// if (username.equals("anonymous")) {+// new_uc.setPublic(true);+// } else {+// new_uc.setPublic(false);+// }+//+// new_uc.setProperty(Usercontribution.feedbackitem_TITLE, username);+// new_uc.setProperty(Usercontribution.feedbackitem_DESCRIPTION, uc);+// new_uc.setProperty(Usercontribution.feedbackitem_TARGET, new DigestURI(domain).toNormalform(false, false));+//+// Switchboard.getSwitchboard().usercontributionsDB+// .saveUsercontribution(new_uc);+//+// result = new_uc;+//+// } catch (MalformedURLException e) {+//+// }+// }+//+// }+//+// return result;+//+// }++++//public static String GetURLHash (String url) {+//+//+// // TODO: Check if this bookmark exists+//+// String result = "";+//+// DigestURI uri;+// try {+// uri = new DigestURI (url);+//+// result = UTF8.String(uri.hash());+//+//+//+// } catch (MalformedURLException e) {+// // TODO Auto-generated catch block+// e.printStackTrace();+// }+//+// return result;+//+// }++ public static String Suggest (String url, String username) {++ final Switchboard sb = Switchboard.getSwitchboard();++ if (username == "") {+ username = "anonymous";+ }++ Boolean processlocal = false;++ if (!sb.getConfig("interaction.suggest.accumulationpeer", "").equals("")) {+ if (sb.getConfig("interaction.suggest.accumulationpeer", "").equals(sb.peers.myName())) {++ // Our peer is meant to process the suggestion.+ processlocal = true;+++ } else {++ // Forward suggestion to other peer+ Log.logInfo("INTERACTION", "Forwarding suggestion to "+sb.getConfig("interaction.suggest.accumulationpeer", "")+": " + url);+ try {++ Seed host = sb.peers.lookupByName(sb.getConfig("interaction.suggest.accumulationpeer", ""));++ return (UTF8.String(new HTTPClient().POSTbytes(+ "http://"+host.getPublicAddress()+"/interaction/Suggest.json"+ + "?url=" + url + "&username=" + username,+ new HashMap<String, ContentBody>(), false)));+ } catch (IOException e) {+ // TODO Auto-generated catch block+ e.printStackTrace();+ }+ }+ }++ if (processlocal) {++ final String date = String.valueOf(System.currentTimeMillis());++ final Map<String, byte[]> map = new HashMap<String, byte[]>();++ map.put("url", url.getBytes());+ map.put("username", username.getBytes());+ map.put("status", "new".getBytes());+ map.put("timestamp_creation", date.getBytes());++ try {+ sb.tables.insert("suggestion", map);+ } catch (final IOException e) {+ Log.logException(e);+ } catch (RowSpaceExceededException e) {+ // TODO Auto-generated catch block+ e.printStackTrace();+ }++ // TODO: Remove the following part for future use++ Log.logInfo("INTERACTION", "Forwarding suggestion to bk: " + url);++ try {++ String reply = (UTF8.String(new HTTPClient().POSTbytes(+ "http://hwiki.fzk.de/jss/SiteBookmark?suggestUrl=" + url+"&username="+username,+ new HashMap<String, ContentBody>(), false)));+ } catch (IOException e) {+ // TODO Auto-generated catch block+ e.printStackTrace();+ }+ }++ return "";++ }+++public static String Feedback(String url, String comment, String from, String peer) {++ final Switchboard sb = Switchboard.getSwitchboard();++ if (peer == "") {+ peer = sb.peers.myName();+ }++ Boolean processlocal = false;++ if (!sb.getConfig("interaction.feedback.accumulationpeer", "").equals("")) {+ if (sb.getConfig("interaction.feedback.accumulationpeer", "").equals(sb.peers.myName())) {++ // Our peer is meant to process the feedback.+ processlocal = true;++ } else {++ // Forward feedback to other peer+ Log.logInfo("INTERACTION", "Forwarding feedback to "+sb.getConfig("interaction.feedback.accumulationpeer", "")+": " + url + ": "+ + comment);+ try {++ Seed host = sb.peers.lookupByName(sb.getConfig("interaction.feedback.accumulationpeer", ""));++ return (UTF8.String(new HTTPClient().POSTbytes(+ "http://"+host.getPublicAddress()+"/interaction/Feedback.json"+ + "?url=" + url + "&comment=" + comment+ + "&from=" + from + "&peer=" + peer,+ new HashMap<String, ContentBody>(), false)));+ } catch (IOException e) {+ // TODO Auto-generated catch block+ e.printStackTrace();+ return "";+ }+ }+ }++ if (processlocal) {++ final String date = String.valueOf(System.currentTimeMillis());++ final Map<String, byte[]> map = new HashMap<String, byte[]>();++ map.put("url", url.getBytes());+ map.put("username", from.getBytes());+ map.put("peer", peer.getBytes());+ map.put("status", "new".getBytes());+ map.put("comment", comment.getBytes());+ map.put("timestamp_creation", date.getBytes());++ try {+ sb.tables.insert("feedback", map);+ } catch (final IOException e) {+ Log.logException(e);+ } catch (RowSpaceExceededException e) {+ // TODO Auto-generated catch block+ e.printStackTrace();+ }++ // TODO: Remove the following part for future use++ try {+ return (UTF8.String(new HTTPClient().POSTbytes(+ "http://sciencenet.kit.edu/Feedback?Url=" + url + "&Comment=" + comment+ + "&From=" + from + "&Peer=" + peer,+ new HashMap<String, ContentBody>(), false)));+ } catch (IOException e) {+ // TODO Auto-generated catch block+ e.printStackTrace();+ return "";+ }+ }++ return "";+}++public static String Contribution(String url, String comment, String from, String peer) {++ final Switchboard sb = Switchboard.getSwitchboard();++ if (peer == "") {+ peer = sb.peers.myName();+ }++ Boolean processlocal = false;++ if (!sb.getConfig("interaction.contribution.accumulationpeer", "").equals("")) {+ if (sb.getConfig("interaction.contribution.accumulationpeer", "").equals(sb.peers.myName())) {++ // Our peer is meant to process the feedback.+ processlocal = true;++ } else {++ // Forward feedback to other peer+ Log.logInfo("INTERACTION", "Forwarding contribution to "+sb.getConfig("interaction.contribution.accumulationpeer", "")+": " + url + ": "+ + comment);+ try {++ Seed host = sb.peers.lookupByName(sb.getConfig("interaction.contribution.accumulationpeer", ""));++ return (UTF8.String(new HTTPClient().POSTbytes(+ "http://"+host.getPublicAddress()+"/interaction/Contribution.json"+ + "?url=" + url + "&comment=" + comment+ + "&from=" + from + "&peer=" + peer,+ new HashMap<String, ContentBody>(), false)));+ } catch (IOException e) {+ // TODO Auto-generated catch block+ e.printStackTrace();+ return "";+ }+ }+ } else {+ // No forward defined+ processlocal = true;+ }++ if (processlocal) {++ final String date = String.valueOf(System.currentTimeMillis());++ final Map<String, byte[]> map = new HashMap<String, byte[]>();++ map.put("url", url.getBytes());+ map.put("username", from.getBytes());+ map.put("peer", peer.getBytes());+ map.put("status", "new".getBytes());+ map.put("comment", comment.getBytes());+ map.put("timestamp_creation", date.getBytes());++ try {+ sb.tables.insert("contribution", map);+ } catch (final IOException e) {+ Log.logException(e);+ } catch (RowSpaceExceededException e) {+ // TODO Auto-generated catch block+ e.printStackTrace();+ }+ }++ return "";+}++public static String Triple(String url, String s, String p, String o, String from) {++ final Switchboard sb = Switchboard.getSwitchboard();++ Resource r = TripleStore.model.getResource(s);+ Property pr = TripleStore.model.createProperty(p);++ r.addProperty(pr, o);+++ return "";+}++public static String GetContribution(String url) {++ final Switchboard sb = Switchboard.getSwitchboard();+++// Boolean processlocal = false;+//+// if (!sb.getConfig("interaction.contribution.accumulationpeer", "").equals("")) {+//+// if (sb.getConfig("interaction.contribution.accumulationpeer", "").equals(sb.peers.myName())) {+//+// // Our peer is meant to process the feedback.+// processlocal = true;+//+// } else {+//+// // Forward feedback to other peer+// Log.logInfo("INTERACTION", "Fetching contribution from "+sb.getConfig("interaction.contribution.accumulationpeer", "")+": " + url);+//+// try {+//+// Seed host = sb.peers.lookupByName(sb.getConfig("interaction.contribution.accumulationpeer", ""));+//+// return (UTF8.String(new HTTPClient().POSTbytes(+// "http://"+host.getPublicAddress()+"/interaction/Contribution.json"+// + "?url=" + url + "&comment=" + comment+// + "&from=" + from + "&peer=" + peer,+// new HashMap<String, ContentBody>(), false)));+//+// } catch (IOException e) {+// // TODO Auto-generated catch block+// e.printStackTrace();+//+// return "";+// }+// }+// } else {+// // No forward defined+// processlocal = true;+// }+//+// if (processlocal) {+//+// final String date = String.valueOf(System.currentTimeMillis());+//+// final Map<String, byte[]> map = new HashMap<String, byte[]>();+//+// map.put("url", url.getBytes());+// map.put("username", from.getBytes());+// map.put("peer", peer.getBytes());+// map.put("status", "new".getBytes());+// map.put("comment", comment.getBytes());+// map.put("timestamp_creation", date.getBytes());+//+// try {+// sb.tables.insert("contribution", map);+// } catch (final IOException e) {+// Log.logException(e);+// } catch (RowSpaceExceededException e) {+// // TODO Auto-generated catch block+// e.printStackTrace();+// }+// }++ return "";+}+++//public static void Usertracking(String url) {+//+// final Switchboard sb = Switchboard.getSwitchboard();+//+// Log.logInfo("INTERACTION", "Usertracking "+url);+//+//+// // TOUCH: HIT +1 TO THE DOMAIN ENTRY+//+// try {+// sb.addToIndex(new DigestURI(new DigestURI(url).getHost()), null, null);+// sb.addToIndex(new DigestURI(url), null, null);+// } catch (MalformedURLException e) {+// // TODO Auto-generated catch block+// e.printStackTrace();+// } catch (IOException e) {+// // TODO Auto-generated catch block+// e.printStackTrace();+// } catch (Failure e) {+// // TODO Auto-generated catch block+// e.printStackTrace();+// }+//+//}+++}+