Demonstration: include value from interaction in search results

Conflicts:
	htroot/interaction/OverlayInteraction.html
	htroot/yacysearchitem.java
pull/1/head
cominch 13 years ago committed by Michael Peter Christen
parent ae8adb0e58
commit c9dc6cda02

@ -63,6 +63,15 @@
<h2>Query</h2>
<form action="Triple_p.html" method="post" enctype="multipart/form-data">
<textarea name="query" cols="100" rows="10">
#[query]#
</textarea>
<input type="submit" value="Query" />
</form>
<form action="Triple_p.csv" method="post" enctype="multipart/form-data">
<textarea name="query" cols="100" rows="10">
#[query]#
</textarea>

@ -40,13 +40,13 @@ public class Triple_p {
prop.put("display", 1); // Fixed to 1
prop.putHTML("mode_output", "no query performed");
String q = "PREFIX lln: <http://virtual.liebel-lab.org/n#>\n"+
String q = "PREFIX lln: <http://virtual.x/>\n"+
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"+
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n"+
"SELECT ?resource ?pa\n"+
"WHERE {\n"+
"?resource lln:percentageofarea ?pa .\n"+
"FILTER (xsd:float (?pa) > 3.000)\n"+
"?resource lln:hasvalue ?pa .\n"+
"FILTER (xsd:float (?pa) > 21.000)\n"+
"}";
if (post != null) {
@ -106,17 +106,29 @@ public class Triple_p {
prop.putHTML("mode_rdfdump", sos.toString());
int scount = 0;
while (resultSet.hasNext()) {
QuerySolution s = resultSet.next();
prop.put("entries_"+scount+"_s", s.getResource(null).getURI());
prop.put("entries_"+scount+"_p", s.getResource(null).getURI());
prop.put("entries_"+scount+"_o", s.getResource(null).getURI());
scount ++;
}
prop.putHTML("entries", ""+scount);
for (String s: resultSet.getResultVars()) {
prop.putHTML("mode_output_"+count+"_caption", s);
count ++;
}
} catch (Exception e) {
prop.putHTML("mode_rdfdump", "error");
}
prop.putHTML("mode_output", ""+count);

@ -52,9 +52,32 @@ border-bottom: 1px solid #ffffff;
</div>
<div id="sidebar-document" class="sci_panel" style="top: 110px;">
<!-- <div id="sidebar-document" class="sci_panel" style="top: 110px;">
<p>document</p> <img src="/currentyacypeer/env/grafics/bad.png" onclick="contribution (document.location.href, 'like document', '#[username]#'); return false">
document <img src="/currentyacypeer/env/grafics/bad.png" width="16px" height="16px" onclick="contribution (document.location.href, 'like document', '#[username]#'); return false">
</div> -->
<div id="sidebar-element" class="sci_panel" style="top: 110px;">
<input id="SliderSingle" type="slider" name="price" value="20" />
<script type="text/javascript" charset="utf-8">
$("#SliderSingle").slider(
{
from: 0,
to: 100,
step: 2.5,
round: 1,
format: { format: '##.0', locale: 'de'},
dimension: '&nbsp;',
skin: 'round',
onstatechange: function(value) {
triple ('#[link]#', '#[link]#', 'http://virtual.x/hasvalue', value, '#[username]#');
}
}
);
</script>
</div>

@ -2,7 +2,7 @@
<div class="searchresults">
<h4 class="linktitle">
<img width="16" height="16" src="ViewImage.png?width=16&amp;height=16&amp;code=#[faviconCode]#" id="f#[urlhash]#" class="favicon" style="width:16px; height:16px;" alt="" />
<a href="#[link]#" target="#[target]#">#[title]#</a></h4>
<a href="#[link]#" target="#[target]#">#[title]#</a> #[value]#</h4>
<div class="urlactions">
#(heuristic)#::
<img width="16" height="9" src="/env/grafics/heuristic_redundant.gif" title="heuristic:#[name]# (redundant)" style="width:16px; height:9px;" alt="heuristic:#[name]# (redundant)"/>::

@ -34,6 +34,7 @@ import net.yacy.cora.document.Classification.ContentDomain;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.protocol.RequestHeader.FileType;
import net.yacy.interaction.Interaction;
import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.logging.Log;
import net.yacy.kelondro.util.Formatter;
@ -141,8 +142,44 @@ public class yacysearchitem {
prop.putHTML("content_title", result.title());
prop.putXML("content_title-xml", result.title());
prop.putJSON("content_title-json", result.title());
prop.putHTML("content_link", resultUrlstring);
prop.putHTML("content_showPictures_link", resultUrlstring);
//prop.putHTML("content_link", resultUrlstring);
// START interaction
String modifyURL = resultUrlstring;
if (sb.getConfigBool("proxyURL.useforresults", false)) {
// check if url is allowed to view
if (sb.getConfig("proxyURL.rewriteURLs", "all").equals("all")) {
modifyURL = "./proxy.html?url="+modifyURL;
}
// check if url is allowed to view
if (sb.getConfig("proxyURL.rewriteURLs", "all").equals("domainlist")) {
try {
if (sb.crawlStacker.urlInAcceptedDomain(new DigestURI (modifyURL)) == null) {
modifyURL = "./proxy.html?url="+modifyURL;
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (sb.getConfig("proxyURL.rewriteURLs", "all").equals("yacy")) {
try {
if ((new DigestURI (modifyURL).getHost().endsWith(".yacy"))) {
modifyURL = "./proxy.html?url="+modifyURL;
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
prop.putHTML("content_link", modifyURL);
prop.putHTML("content_value", Interaction.getTriple(result.urlstring(), "http://virtual.x/hasvalue"));
// END interaction
prop.putHTML("content_target", target);
if (faviconURL != null && fileType == FileType.HTML) sb.loader.loadIfNotExistBackground(faviconURL, 1024 * 1024 * 10);
prop.putHTML("content_faviconCode", sb.licensedURLs.aquireLicense(faviconURL)); // acquire license for favicon url loading

@ -463,6 +463,23 @@ public static String Triple(String url, String s, String p, String o, String fro
return "";
}
public static String getTriple(String s, String p) {
final Switchboard sb = Switchboard.getSwitchboard();
Resource r = TripleStore.model.getResource(s);
Property pr = TripleStore.model.getProperty(p);
StmtIterator iter = TripleStore.model.listStatements(r, pr, (Resource) null);
while (iter.hasNext()) {
return (iter.nextStatement().getObject().toString());
}
return "";
}
public static String GetContribution(String url) {
final Switchboard sb = Switchboard.getSwitchboard();

Loading…
Cancel
Save