parent
9f921c27f3
commit
726e8c3ad5
@ -1,70 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>YaCy '#[clientname]#': Demo-Servlet</title>
|
||||
<script type="text/javascript" src="js/html.js"></script>
|
||||
<script src="/yacy/ui/js/jquery-1.3.2.min.js" type="text/javascript"></script>
|
||||
</head>
|
||||
|
||||
|
||||
<body id="index">
|
||||
|
||||
<div>
|
||||
Hello world!
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<div>
|
||||
Your user name: #[username]#
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>A list of all users on this system:</p>
|
||||
|
||||
#{users}#
|
||||
- #[user]#<br/>
|
||||
#{/users}#
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<div>
|
||||
Temperature: #[temperature]#
|
||||
</div>
|
||||
|
||||
<form action="DemoServlet.html" method="post">
|
||||
|
||||
<input type="text" name="textthing" value=""/>
|
||||
<input type="submit" name="submit" value="submit">
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
#{localimg}#
|
||||
|
||||
<img src="#[path]#">
|
||||
|
||||
#(checked)#no::yes::maybe#(/checked)#
|
||||
|
||||
#{/localimg}#
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<div>
|
||||
<p>Upload a file (will be stored in HTDOCS/upload/username/):</p>
|
||||
<form action="/interaction/UploadSingleFile.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
|
||||
<input type="file" name="uploadfile">
|
||||
<input type="submit">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
@ -1,61 +0,0 @@
|
||||
import net.yacy.yacy;
|
||||
import net.yacy.cora.protocol.RequestHeader;
|
||||
import net.yacy.interaction.Interaction;
|
||||
import net.yacy.server.serverObjects;
|
||||
import net.yacy.server.serverSwitch;
|
||||
|
||||
public final class DemoServlet {
|
||||
|
||||
public static serverObjects respond(final RequestHeader header,
|
||||
final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
|
||||
|
||||
// return variable that accumulates replacements
|
||||
final serverObjects prop = new serverObjects();
|
||||
|
||||
prop.put("temperature", "-10°C");
|
||||
|
||||
// Display currently logged on user
|
||||
prop.put("username", Interaction.GetLoggedOnUser(header));
|
||||
|
||||
//Generate Userlist
|
||||
int numUsers = 0;
|
||||
for (String user : Interaction.GetUsers()) {
|
||||
prop.putHTML("users_"+numUsers+"_user", user);
|
||||
numUsers++;
|
||||
}
|
||||
prop.put("users", numUsers);
|
||||
|
||||
|
||||
|
||||
if (post != null) {
|
||||
|
||||
if (post.containsKey("submit")) {
|
||||
|
||||
prop.put("temperature", post.get("textthing"));
|
||||
|
||||
String filename= post.get("textthing");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
while (counter < 10) {
|
||||
|
||||
prop.put("localimg_"+counter+"_path","/"+filename);
|
||||
|
||||
prop.put("localimg_"+counter+"_checked", "2");
|
||||
counter++;
|
||||
}
|
||||
|
||||
prop.put("localimg", counter);
|
||||
|
||||
|
||||
|
||||
prop.put("temperature", yacy.homedir+"/DATA/HTDOCS/"+filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// return rewrite properties
|
||||
return prop;
|
||||
}
|
||||
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>YaCy '#[clientname]#': Demo-Servlet</title>
|
||||
|
||||
<!-- This element contains the jQuery libraries and interaction routines -->
|
||||
#%env/templates/metas.template%#
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
<body id="index">
|
||||
|
||||
<p>
|
||||
JavaScript example: Permanent storage of value, assigned to logged in user account
|
||||
</p>
|
||||
<br/>
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
<input id="SliderSingle" type="slider" name="price" value="0" />
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var oldvalue = loadvalue_t ('http://virtual.x/document/uniquenameDemo123', 'http://virtual.x/hasvalue');
|
||||
|
||||
if (oldvalue == "") {
|
||||
oldvalue = "0";
|
||||
}
|
||||
|
||||
document.getElementById('SliderSingle').value = oldvalue;
|
||||
|
||||
$("#SliderSingle").slider(
|
||||
{
|
||||
from: 0,
|
||||
to: 100,
|
||||
step: 2.5,
|
||||
round: 1,
|
||||
format: { format: '##.0', locale: 'de'},
|
||||
dimension: ' points',
|
||||
skin: 'round',
|
||||
onstatechange: function(value) {
|
||||
|
||||
storevalue_t ('http://virtual.x/document/uniquenameDemo123', 'http://virtual.x/hasvalue', value);
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
|
||||
</p>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<p>
|
||||
JavaScript example: Load value from global RDF store
|
||||
</p>
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<p>
|
||||
|
||||
<input id="output" type="text" name="output" value="--"/>
|
||||
<input type="submit" name="sub" onclick="storevalueglobal ('http://virtual.x/global/entry1', 'http://virtual.x/global/hasvalue', document.getElementById('output').value)"/>
|
||||
|
||||
l
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
|
||||
var oldvalue = loadvalueglobal ('http://virtual.x/global/entry1', 'http://virtual.x/global/hasvalue');
|
||||
|
||||
document.getElementById('output').value = oldvalue;
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
#%env/templates/footer.template%#
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
@ -1,18 +0,0 @@
|
||||
import net.yacy.cora.protocol.RequestHeader;
|
||||
import net.yacy.server.serverObjects;
|
||||
import net.yacy.server.serverSwitch;
|
||||
|
||||
public final class DemoServletInteraction {
|
||||
|
||||
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header,
|
||||
@SuppressWarnings("unused") final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
|
||||
// return variable that accumulates replacements
|
||||
final serverObjects prop = new serverObjects();
|
||||
|
||||
prop.put("temperature", "-10°C");
|
||||
|
||||
// return rewrite properties
|
||||
return prop;
|
||||
}
|
||||
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>YaCy '#[clientname]#': Demo-Servlet</title>
|
||||
<script type="text/javascript" src="js/html.js"></script>
|
||||
<script src="/yacy/ui/js/jquery-1.3.2.min.js" type="text/javascript"></script>
|
||||
|
||||
<script src="/currentyacypeer/js/rdf/jquery.rdfquery.core-1.0.js" type="text/javascript"></script>
|
||||
|
||||
<!-- This element contains the jQuery libraries and interaction routines -->
|
||||
#%env/templates/metas.template%#
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
<body id="index">
|
||||
|
||||
<div>
|
||||
Global RDF content:
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div id="rdfxml" name="rdfxml">
|
||||
here comes the rdf data
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var rdf = $.rdf();
|
||||
|
||||
var databank = jQuery.rdf.databank();
|
||||
|
||||
rdfload (databank);
|
||||
|
||||
|
||||
$('#rdfxml').html($.rdf().databank.dump());
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
@ -1,46 +0,0 @@
|
||||
import net.yacy.cora.protocol.RequestHeader;
|
||||
import net.yacy.server.serverObjects;
|
||||
import net.yacy.server.serverSwitch;
|
||||
|
||||
public final class DemoServletRDF {
|
||||
|
||||
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header,
|
||||
final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
|
||||
// return variable that accumulates replacements
|
||||
final serverObjects prop = new serverObjects();
|
||||
|
||||
// prop.put("temperature", "-10°C");
|
||||
|
||||
if (post != null) {
|
||||
|
||||
if (post.containsKey("submit")) {
|
||||
prop.put("temperature", post.get("textthing"));
|
||||
|
||||
String filename= post.get("textthing");
|
||||
|
||||
// prop.put("imglink", filename+".jpg");
|
||||
|
||||
int counter = 0;
|
||||
|
||||
while (counter < 10) {
|
||||
|
||||
prop.put("localimg_"+counter+"_path","/"+filename);
|
||||
|
||||
prop.put("localimg_"+counter+"_checked", "2");
|
||||
counter++;
|
||||
}
|
||||
|
||||
prop.put("localimg", counter);
|
||||
|
||||
|
||||
|
||||
// prop.put("temperature",yacy.homedir+"/DATA/HTDOCS/"+filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// return rewrite properties
|
||||
return prop;
|
||||
}
|
||||
|
||||
}
|
@ -1,233 +0,0 @@
|
||||
package net.yacy.interaction;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.yacy.cora.document.encoding.UTF8;
|
||||
import net.yacy.cora.document.id.DigestURL;
|
||||
import net.yacy.cora.protocol.ClientIdentification;
|
||||
import net.yacy.cora.protocol.HeaderFramework;
|
||||
import net.yacy.cora.protocol.RequestHeader;
|
||||
import net.yacy.cora.protocol.http.HTTPClient;
|
||||
import net.yacy.cora.util.ConcurrentLog;
|
||||
import net.yacy.cora.util.SpaceExceededException;
|
||||
import net.yacy.data.UserDB;
|
||||
import net.yacy.kelondro.blob.Tables.Row;
|
||||
import net.yacy.peers.Seed;
|
||||
import net.yacy.search.Switchboard;
|
||||
|
||||
import org.apache.http.entity.mime.content.ContentBody;
|
||||
|
||||
|
||||
|
||||
public class Interaction {
|
||||
|
||||
|
||||
public static String GetLoggedOnUser (RequestHeader requestHeader) {
|
||||
|
||||
UserDB.Entry entry = null;
|
||||
|
||||
//String result = "anonymous";
|
||||
|
||||
entry = Switchboard.getSwitchboard().userDB.proxyAuth((requestHeader.get(RequestHeader.AUTHORIZATION, "xxxxxx")));
|
||||
if(entry != null){
|
||||
|
||||
}else{
|
||||
entry=Switchboard.getSwitchboard().userDB.cookieAuth(requestHeader.getHeaderCookies());
|
||||
|
||||
if(entry == null){
|
||||
entry=Switchboard.getSwitchboard().userDB.ipAuth((requestHeader.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "xxxxxx")));
|
||||
if(entry != null){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//identified via userDB
|
||||
if(entry != null){
|
||||
|
||||
return entry.getUserName();
|
||||
|
||||
}else if(Switchboard.getSwitchboard().verifyAuthentication(requestHeader)){
|
||||
return "staticadmin";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public static Set<String> GetUsers() {
|
||||
|
||||
Set<String> res = new HashSet<String>();
|
||||
|
||||
UserDB.Entry entry = null;
|
||||
|
||||
final Iterator<UserDB.Entry> it = Switchboard.getSwitchboard().userDB.iterator(true);
|
||||
|
||||
while (it.hasNext()) {
|
||||
entry = it.next();
|
||||
if (entry == null) {
|
||||
continue;
|
||||
}
|
||||
res.add (entry.getUserName());
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static String GetDomain (String url) {
|
||||
|
||||
String domain = url;
|
||||
|
||||
try {
|
||||
DigestURL uri = new DigestURL (url);
|
||||
|
||||
domain = uri.getHost();
|
||||
} catch (final MalformedURLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return domain;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static String GetURLHash (String url) {
|
||||
|
||||
String result = "";
|
||||
|
||||
DigestURL uri;
|
||||
try {
|
||||
uri = new DigestURL (url);
|
||||
|
||||
result = UTF8.String(uri.hash());
|
||||
|
||||
|
||||
|
||||
} catch (final MalformedURLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static String GetTableentry(String url, String type, String username) {
|
||||
|
||||
final Switchboard sb = Switchboard.getSwitchboard();
|
||||
|
||||
String retvalue = "";
|
||||
|
||||
try {
|
||||
Iterator<Row> it = sb.tables.iterator(username+"_contribution", "url", url.getBytes());
|
||||
|
||||
ConcurrentLog.info ("TABLE", "GET "+username+" / "+url+" - "+type+" ...");
|
||||
|
||||
it = sb.tables.orderBy(it, -1, "timestamp_creation").iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
Row r = it.next();
|
||||
|
||||
if (r.get("type", "").equals (type)) {
|
||||
|
||||
retvalue = r.get("value", "");
|
||||
}
|
||||
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ConcurrentLog.info ("TABLE", "GET "+username+" / "+url+" - "+type+" - "+retvalue);
|
||||
|
||||
return retvalue;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static String Tableentry(String url, String type, String comment, String from, String peer) {
|
||||
|
||||
final Switchboard sb = Switchboard.getSwitchboard();
|
||||
|
||||
if (peer == "") {
|
||||
peer = sb.peers.myName();
|
||||
}
|
||||
|
||||
Boolean processlocal = false;
|
||||
|
||||
ConcurrentLog.info ("TABLE", "PUT "+from+" / "+url+" - "+type+" - "+comment);
|
||||
|
||||
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
|
||||
ConcurrentLog.info("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(ClientIdentification.yacyInternetCrawlerAgent).POSTbytes(
|
||||
"http://"+host.getPublicAddress()+"/interaction/Contribution.json"
|
||||
+ "?url=" + url + "&comment=" + comment
|
||||
+ "&from=" + from + "&peer=" + peer,
|
||||
new HashMap<String, ContentBody>(), false, false)));
|
||||
} catch (final 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("type", type.getBytes());
|
||||
map.put("value", comment.getBytes());
|
||||
map.put("timestamp_creation", date.getBytes());
|
||||
|
||||
try {
|
||||
sb.tables.insert(from+"_contribution", map);
|
||||
} catch (final IOException e) {
|
||||
ConcurrentLog.logException(e);
|
||||
} catch (final SpaceExceededException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue