2009-09-27 00:07:40 +02:00
|
|
|
//
|
|
|
|
//$LastChangedDate$
|
|
|
|
//$LastChangedRevision$
|
|
|
|
//$LastChangedBy$
|
|
|
|
//
|
2007-05-22 17:20:50 +02:00
|
|
|
|
2012-10-15 13:17:13 +02:00
|
|
|
import java.util.Iterator;
|
|
|
|
|
2013-09-15 00:30:23 +02:00
|
|
|
import net.yacy.cora.document.id.DigestURL;
|
2010-08-23 14:32:02 +02:00
|
|
|
import net.yacy.cora.protocol.RequestHeader;
|
2012-10-15 13:17:13 +02:00
|
|
|
import net.yacy.cora.sorting.ReversibleScoreMap;
|
2012-09-21 15:48:16 +02:00
|
|
|
import net.yacy.crawler.CrawlSwitchboard;
|
|
|
|
import net.yacy.crawler.data.CrawlProfile;
|
2011-09-25 18:59:06 +02:00
|
|
|
import net.yacy.search.Switchboard;
|
2012-09-21 15:48:16 +02:00
|
|
|
import net.yacy.server.serverObjects;
|
|
|
|
import net.yacy.server.serverSwitch;
|
2007-05-22 17:20:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
public class WatchWebStructure_p {
|
2012-07-05 09:14:04 +02:00
|
|
|
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
|
2009-07-19 22:37:44 +02:00
|
|
|
final Switchboard sb = (Switchboard) env;
|
2008-08-02 14:12:04 +02:00
|
|
|
final serverObjects prop = new serverObjects();
|
2010-08-17 12:44:00 +02:00
|
|
|
|
|
|
|
String color_text = "888888";
|
|
|
|
String color_back = "FFFFFF";
|
2012-10-25 10:18:28 +02:00
|
|
|
String color_dot0 = "1111BB";
|
|
|
|
String color_dota = "11BB11";
|
2010-08-17 12:44:00 +02:00
|
|
|
String color_line = "222222";
|
|
|
|
String color_lineend = "333333";
|
2011-11-24 11:22:02 +01:00
|
|
|
|
2012-10-23 18:11:19 +02:00
|
|
|
int width = 1280;
|
|
|
|
int height = 720;
|
2007-05-24 17:28:03 +02:00
|
|
|
int depth = 3;
|
2012-10-15 13:17:13 +02:00
|
|
|
int nodes = 300; // maximum number of host nodes that are painted
|
2007-06-10 22:00:44 +02:00
|
|
|
int time = -1;
|
2007-05-24 17:28:03 +02:00
|
|
|
String host = "auto";
|
2009-06-17 14:37:31 +02:00
|
|
|
String besthost;
|
2011-11-24 11:22:02 +01:00
|
|
|
|
2007-05-24 17:28:03 +02:00
|
|
|
if (post != null) {
|
2012-10-23 18:11:19 +02:00
|
|
|
width = post.getInt("width", 1280);
|
|
|
|
height = post.getInt("height", 720);
|
2010-08-17 12:44:00 +02:00
|
|
|
depth = post.getInt("depth", 3);
|
2012-10-23 18:11:19 +02:00
|
|
|
nodes = post.getInt("nodes", width * height * 300 / width / height);
|
2010-08-17 12:44:00 +02:00
|
|
|
time = post.getInt("time", -1);
|
|
|
|
host = post.get("host", "auto");
|
|
|
|
color_text = post.get("colortext", color_text);
|
|
|
|
color_back = post.get("colorback", color_back);
|
2012-10-25 10:18:28 +02:00
|
|
|
color_dot0 = post.get("colordot0", color_dot0);
|
|
|
|
color_dota = post.get("colordota", color_dota);
|
2010-08-17 12:44:00 +02:00
|
|
|
color_line = post.get("colorline", color_line);
|
|
|
|
color_lineend = post.get("colorlineend", color_lineend);
|
2007-05-24 17:28:03 +02:00
|
|
|
}
|
2011-11-24 11:22:02 +01:00
|
|
|
|
2007-06-06 22:18:39 +02:00
|
|
|
if (host.equals("auto")) {
|
|
|
|
// try to find the host from the crawl profiles
|
2010-08-31 17:47:47 +02:00
|
|
|
CrawlProfile e;
|
2011-11-24 11:22:02 +01:00
|
|
|
for (final byte[] handle: sb.crawler.getActive()) {
|
2011-02-12 01:01:40 +01:00
|
|
|
e = sb.crawler.getActive(handle);
|
2013-07-01 13:10:09 +02:00
|
|
|
if (CrawlSwitchboard.DEFAULT_PROFILES.contains(e.name())) continue;
|
2007-06-06 22:18:39 +02:00
|
|
|
host = e.name();
|
|
|
|
break; // take the first one
|
|
|
|
}
|
|
|
|
}
|
2011-11-24 11:22:02 +01:00
|
|
|
|
2012-02-25 15:42:29 +01:00
|
|
|
// fix start point if a "www."-prefix would be better
|
|
|
|
if (host != null && !host.startsWith("www")) {
|
2013-09-15 00:30:23 +02:00
|
|
|
if (sb.webStructure.referencesCount(DigestURL.hosthash6("www." + host)) > sb.webStructure.referencesCount(DigestURL.hosthash6(host))) {
|
2012-02-25 15:42:29 +01:00
|
|
|
host = "www." + host;
|
|
|
|
}
|
|
|
|
}
|
2012-10-15 13:17:13 +02:00
|
|
|
|
|
|
|
if (post != null && post.containsKey("hosts")) {
|
|
|
|
int maxcount = 200;
|
|
|
|
ReversibleScoreMap<String> score = sb.webStructure.hostReferenceScore();
|
|
|
|
int c = 0;
|
|
|
|
Iterator<String> i = score.keys(false);
|
|
|
|
String h;
|
|
|
|
while (i.hasNext() && c < maxcount) {
|
|
|
|
h = i.next();
|
|
|
|
prop.put("hosts_list_" + c + "_host", h);
|
|
|
|
prop.put("hosts_list_" + c + "_count", score.get(h));
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
prop.put("hosts_list", c);
|
|
|
|
prop.put("hosts", 1);
|
|
|
|
}
|
2012-02-25 15:42:29 +01:00
|
|
|
|
2009-06-17 14:37:31 +02:00
|
|
|
// find start point
|
2011-05-16 00:57:31 +02:00
|
|
|
if (host == null ||
|
2012-07-10 22:59:03 +02:00
|
|
|
host.isEmpty() ||
|
2012-02-25 15:42:29 +01:00
|
|
|
host.equals("auto")
|
|
|
|
// || sb.webStructure.referencesCount(DigestURI.hosthash6(host)) == 0
|
|
|
|
) {
|
2009-06-17 14:37:31 +02:00
|
|
|
// find domain with most references
|
|
|
|
besthost = sb.webStructure.hostWithMaxReferences();
|
2011-11-24 11:29:20 +01:00
|
|
|
if (besthost == null) besthost = host;
|
2009-06-17 14:37:31 +02:00
|
|
|
} else {
|
|
|
|
besthost = host;
|
|
|
|
}
|
2011-11-24 11:22:02 +01:00
|
|
|
|
2008-09-19 13:45:11 +02:00
|
|
|
prop.putHTML("host", host);
|
2009-06-17 14:37:31 +02:00
|
|
|
prop.putHTML("besthost", besthost);
|
2007-05-24 17:28:03 +02:00
|
|
|
prop.put("depth", depth);
|
|
|
|
prop.put("depthi", Math.min(8, depth + 1));
|
|
|
|
prop.put("depthd", Math.max(0, depth - 1));
|
2007-06-08 00:56:42 +02:00
|
|
|
prop.put("nodes", nodes);
|
2007-06-10 22:25:33 +02:00
|
|
|
prop.put("nodesi", Math.min(1000, nodes + 100));
|
|
|
|
prop.put("nodesd", Math.max(100, nodes - 100));
|
2007-06-10 22:00:44 +02:00
|
|
|
prop.put("time", time);
|
2007-06-10 22:25:33 +02:00
|
|
|
prop.put("timei", (time > 9000) ? -1 : ((time < 0) ? -1 : Math.min(9999, time + 1000)));
|
|
|
|
prop.put("timed", (time < 0) ? 9000 : Math.max(1000, time - 1000));
|
|
|
|
prop.put("width", width);
|
|
|
|
prop.put("height", height);
|
2010-08-17 12:44:00 +02:00
|
|
|
|
|
|
|
prop.put("colortext", color_text);
|
|
|
|
prop.put("colorback", color_back);
|
2012-10-25 10:18:28 +02:00
|
|
|
prop.put("colordot0", color_dot0);
|
|
|
|
prop.put("colordota", color_dota);
|
2010-08-17 12:44:00 +02:00
|
|
|
prop.put("colorline", color_line);
|
|
|
|
prop.put("colorlineend", color_lineend);
|
2007-05-22 17:20:50 +02:00
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
}
|