From 3c255c025b833b25d0c6014c2f6d3fb9504c9fc0 Mon Sep 17 00:00:00 2001
From: cominch
Date: Fri, 15 Jun 2012 10:43:05 +0200
Subject: [PATCH] Show tags in search results (if activated in
ConfigPortal_p.html)
---
defaults/yacy.init | 1 +
htroot/ConfigPortal.html | 1 +
htroot/ConfigPortal.java | 3 ++
htroot/interaction/Triple.java | 12 +++++--
htroot/interaction_elements/interaction.js | 18 ++++++++++
htroot/yacysearch.html | 1 +
htroot/yacysearchitem.html | 1 +
htroot/yacysearchitem.java | 2 ++
source/net/yacy/cora/lod/JenaTripleStore.java | 34 +++++++------------
9 files changed, 50 insertions(+), 23 deletions(-)
diff --git a/defaults/yacy.init b/defaults/yacy.init
index 0026fec69..6cdd6785f 100644
--- a/defaults/yacy.init
+++ b/defaults/yacy.init
@@ -750,6 +750,7 @@ search.result.show.parser = false
search.result.show.pictures = false
search.result.show.cache = true
search.result.show.proxy = false
+search.result.show.tags = false
# search navigators: comma-separated list of default values for search navigation.
# can be temporary different if search string is given with differen navigation values
diff --git a/htroot/ConfigPortal.html b/htroot/ConfigPortal.html
index 4f4ab4c6e..bafdd84d4 100644
--- a/htroot/ConfigPortal.html
+++ b/htroot/ConfigPortal.html
@@ -77,6 +77,7 @@
Pictures
Cache
Augmented Proxy
+ Tags
Show Navigation on Side-Bar
diff --git a/htroot/ConfigPortal.java b/htroot/ConfigPortal.java
index 7b1822334..d2a4d6b03 100644
--- a/htroot/ConfigPortal.java
+++ b/htroot/ConfigPortal.java
@@ -94,6 +94,7 @@ public class ConfigPortal {
sb.setConfig("search.result.show.pictures", post.getBoolean("search.result.show.pictures", false));
sb.setConfig("search.result.show.cache", post.getBoolean("search.result.show.cache", false));
sb.setConfig("search.result.show.proxy", post.getBoolean("search.result.show.proxy", false));
+ sb.setConfig("search.result.show.tags", post.getBoolean("search.result.show.tags", false));
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, post.get("search.verify", "ifexist"));
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, post.getBoolean("search.verify.delete", false));
@@ -140,6 +141,7 @@ public class ConfigPortal {
sb.setConfig("search.result.show.pictures", false);
sb.setConfig("search.result.show.cache", true);
sb.setConfig("search.result.show.proxy", false);
+ sb.setConfig("search.result.show.tags", false);
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, "iffresh");
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, "true");
sb.setConfig("about.headline", "");
@@ -171,6 +173,7 @@ public class ConfigPortal {
prop.put("search.result.show.pictures", sb.getConfigBool("search.result.show.pictures", false) ? 1 : 0);
prop.put("search.result.show.cache", sb.getConfigBool("search.result.show.cache", false) ? 1 : 0);
prop.put("search.result.show.proxy", sb.getConfigBool("search.result.show.proxy", false) ? 1 : 0);
+ prop.put("search.result.show.tags", sb.getConfigBool("search.result.show.tags", false) ? 1 : 0);
prop.put("search.navigation.hosts", sb.getConfig("search.navigation", "").indexOf("hosts",0) >= 0 ? 1 : 0);
prop.put("search.navigation.authors", sb.getConfig("search.navigation", "").indexOf("authors",0) >= 0 ? 1 : 0);
diff --git a/htroot/interaction/Triple.java b/htroot/interaction/Triple.java
index 67a11f9b6..7d94a0490 100644
--- a/htroot/interaction/Triple.java
+++ b/htroot/interaction/Triple.java
@@ -107,10 +107,18 @@ public class Triple {
if(post.containsKey("s")){
s = post.get("s");
}
+
+ if(post.containsKey("sp")){
+ s = post.get("sp") + "#" + s;
+ }
if(post.containsKey("p")){
p = post.get("p");
}
+
+ if(post.containsKey("pp")){
+ p = post.get("pp") + "#" + p;
+ }
if(post.containsKey("o")){
o = post.get("o");
@@ -123,9 +131,9 @@ public class Triple {
if (post.containsKey("load")) {
if (global) {
- o = JenaTripleStore.getObject(s, p).toString();
+ o = JenaTripleStore.getObject(s, p);
} else {
- o = JenaTripleStore.getObject(s, p, username).toString();
+ o = JenaTripleStore.getObject(s, p, username);
}
diff --git a/htroot/interaction_elements/interaction.js b/htroot/interaction_elements/interaction.js
index e92b992c0..90c6840a6 100644
--- a/htroot/interaction_elements/interaction.js
+++ b/htroot/interaction_elements/interaction.js
@@ -181,3 +181,21 @@ function loadvalueglobal (s, p) {
return res.result;
}
+
+
+function triple_get_prefix (sp, s, pp, p) {
+
+ var res = {result: ""};
+
+ $.ajaxSetup({async: false});
+
+ $.getJSON('/currentyacypeer/interaction/Triple.json?sep=true&global=true&sp='+sp+'&s='+s+'&pp='+pp+'&p='+p+'&load=true', function (data) {
+
+ res = data;
+
+ });
+
+
+ return res.result;
+
+}
\ No newline at end of file
diff --git a/htroot/yacysearch.html b/htroot/yacysearch.html
index d1c5fc76d..ff1bd2532 100644
--- a/htroot/yacysearch.html
+++ b/htroot/yacysearch.html
@@ -3,6 +3,7 @@
#[former]# - YaCy '#[clientname]#': Search Page
#%env/templates/metas.template%#
+ #%env/templates/interactionheader.template%#
diff --git a/htroot/yacysearchitem.html b/htroot/yacysearchitem.html
index f3b5d748d..3eb84c848 100644
--- a/htroot/yacysearchitem.html
+++ b/htroot/yacysearchitem.html
@@ -31,6 +31,7 @@
#(showPictures)#:: | Pictures#(/showPictures)#
#(showCache)#:: | Cache#(/showCache)#
#(showProxy)#:: | Augmented Proxy#(/showProxy)#
+ #(showTags)#::
#(/showTags)#
::
diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java
index 4256754f3..4bb9e50ac 100644
--- a/htroot/yacysearchitem.java
+++ b/htroot/yacysearchitem.java
@@ -130,6 +130,7 @@ public class yacysearchitem {
prop.put("content_showPictures", sb.getConfigBool("search.result.show.pictures", true) ? 1 : 0);
prop.put("content_showCache", sb.getConfigBool("search.result.show.cache", true) ? 1 : 0);
prop.put("content_showProxy", sb.getConfigBool("search.result.show.proxy", true) ? 1 : 0);
+ prop.put("content_showTags", sb.getConfigBool("search.result.show.tags", false) ? 1 : 0);
prop.put("content_authorized", authenticated ? "1" : "0");
final String urlhash = ASCII.String(result.hash());
prop.put("content_authorized_bookmark", sb.tables.bookmarks.hasBookmark("admin", urlhash) ? "0" : "1");
@@ -189,6 +190,7 @@ public class yacysearchitem {
prop.put("content_showCache_link", resultUrlstring);
prop.put("content_showProxy_link", resultUrlstring);
prop.put("content_showParser_urlhash", resulthashString);
+ prop.put("content_showTags_urlhash", resulthashString);
prop.put("content_urlhexhash", Seed.b64Hash2hexHash(resulthashString));
prop.putHTML("content_urlname", nxTools.shortenURLString(result.urlname(), MAX_URL_LENGTH));
prop.put("content_showDate_date", GenericFormatter.RFC1123_SHORT_FORMATTER.format(result.modified()));
diff --git a/source/net/yacy/cora/lod/JenaTripleStore.java b/source/net/yacy/cora/lod/JenaTripleStore.java
index 5a040b819..0be297f33 100644
--- a/source/net/yacy/cora/lod/JenaTripleStore.java
+++ b/source/net/yacy/cora/lod/JenaTripleStore.java
@@ -199,35 +199,27 @@ public class JenaTripleStore {
}
public static String getObject (final String subject, final String predicate) {
-
- Iterator iter = getObjects (subject, predicate);
-
- while (iter.hasNext()) {
-
- return (iter.next().toString());
-
- }
+
+ Log.logInfo("TRIPLESTORE", "GET " + subject + " - " + predicate + " ... ");
- return null;
+ Iterator ni = JenaTripleStore.getObjects (subject, predicate);
+ if (!ni.hasNext()) return "";
+ return ni.next().toString();
}
public static String getObject (final String subject, final String predicate, final String username) {
- Iterator iter = getObjects (subject, predicate, username);
-
- while (iter.hasNext()) {
-
- return (iter.next().toString());
-
- }
+ Log.logInfo("TRIPLESTORE", "GET " + subject + " - " + predicate + " ... ("+username+")");
- return null;
+ Iterator ni = JenaTripleStore.getObjects (subject, predicate, username);
+ if (!ni.hasNext()) return "";
+ return ni.next().toString();
}
public static Iterator getObjects(final String subject, final String predicate, final String username) {
- Log.logInfo("TRIPLESTORE", "GET " + subject + " - " + predicate + " ... ");
+
final Resource r = JenaTripleStore.getResource(subject, username);
if (privatestorage != null && privatestorage.containsKey(username)) {
@@ -238,8 +230,7 @@ public class JenaTripleStore {
return null;
}
- public static Iterator getObjects(final String subject, final String predicate) {
- Log.logInfo("TRIPLESTORE", "GET " + subject + " - " + predicate + " ... ");
+ public static Iterator getObjects(final String subject, final String predicate) {
final Resource r = JenaTripleStore.getResource(subject);
return getObjects(r, predicate);
}
@@ -250,7 +241,8 @@ public class JenaTripleStore {
public static Iterator getObjects(final Resource r, final String predicate, final Model model) {
final Property pr = JenaTripleStore.getProperty(predicate, model);
- final StmtIterator iter = model.listStatements(r, pr, (Resource) null);
+ final StmtIterator iter = model.listStatements(r, pr, (Resource) null);
+
return new Iterator() {
@Override
public boolean hasNext() {