Skip to content

Commit

Permalink
removed debug lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Orbiter committed Dec 21, 2014
1 parent d141146 commit 85773eb
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 14 deletions.
32 changes: 26 additions & 6 deletions htroot/ConfigParser.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ <h2>Parser Configuration</h2>
</p>
<table border="0">
<tr class="TableHeader" valign="bottom">
<td class="small" ><input type="checkbox" id="allswitch" onclick="checkAll(this.form.id, this.checked);" /> enable/disable</td>
<td class="small" >Extension</td>
<td class="small" >Mime-Type</td>
<td class="small" width="30" align="center"><input type="checkbox" id="allswitch" onclick="checkAll(this.form.id, this.checked);"/></td>
<td class="small" width="60">Extension</td>
<td class="small" width="300">Mime-Type</td>
</tr>#{parser}#
<tr class="TableCellDark">
<td colspan="2">#[name]#</td>
<td colspan="3">#[name]#</td>
</tr>#{ext}#
<tr id="#[name]#" class="TableCellLight">
<td class="small" align="center"><input type="checkbox" name="extension_#[extension]#" #(status)#::checked="checked" #(/status)#/></td>
Expand All @@ -47,12 +47,32 @@ <h2>Parser Configuration</h2>
</tr>#{/mime}#
#{/parser}#
<tr class="TableCellDark">
<td colspan="2" class="small" ><input type="submit" name="parserSettings" value="Submit" class="btn btn-primary"/></td>
<td colspan="3" class="small" ><input type="submit" name="parserSettings" value="Submit" class="btn btn-primary"/></td>
</tr>
</table>
</fieldset>
<fieldset><legend id="parser">PDF Parser Attributes</legend>
<p>
This is an experimental setting which makes it possible to split PDF documents into individual index entries.
Every page will become a single index hit and the url is artifically extended with a post/get attribute value containing
the page number as value. When such an url is displayed within a search result, then the post/get attribute is transformed into an anchor hash link.
This makes it possible to view the individual page directly in the pdf.js viewer built-in into firefox,
for reference see https://github.com/mozilla/pdf.js/wiki/Viewer-options
</p>
<table border="0">
<tr class="TableCellLight">
<td class="small" align="right" width="90">Split PDF</td>
<td class="small" align="left" width="300"><input type="checkbox" name="individualPages" #(individualPages)#::checked="checked" #(/individualPages)#/></td>
</tr>
<tr class="TableCellLight">
<td class="small" align="right">Property Name</td>
<td class="small" align="left"><input type="text" name="individualPagePropertyname" value="#[individualPagePropertyname]#"/></td>
</tr>
<tr class="TableCellDark">
<td colspan="3" class="small" ><input type="submit" name="pdfSettings" value="Submit" class="btn btn-primary"/></td>
</tr>
</table>
</form>

#%env/templates/footer.template%#
</body>
</html>
11 changes: 11 additions & 0 deletions htroot/ConfigParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.document.Parser;
import net.yacy.document.TextParser;
import net.yacy.document.parser.pdfParser;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverObjects;
Expand Down Expand Up @@ -63,6 +64,13 @@ public static serverObjects respond(final RequestHeader header, final serverObje
env.setConfig(SwitchboardConstants.PARSER_MIME_DENY, TextParser.getDenyMime());
env.setConfig(SwitchboardConstants.PARSER_EXTENSIONS_DENY, TextParser.getDenyExtension());
}

if (post.containsKey("pdfSettings")) {
env.setConfig(SwitchboardConstants.PARSER_PDF_INDIVIDUALPAGES, post.getBoolean("individualPages"));
env.setConfig(SwitchboardConstants.PARSER_PDF_INDIVIDUALPAGES_KEY, post.get("individualPagePropertyname", "page"));
pdfParser.individualPages = sb.getConfigBool(SwitchboardConstants.PARSER_PDF_INDIVIDUALPAGES, false);
pdfParser.individualPagePropertyname = sb.getConfig(SwitchboardConstants.PARSER_PDF_INDIVIDUALPAGES_KEY, "page");
}
}

int i = 0;
Expand All @@ -89,6 +97,9 @@ public static serverObjects respond(final RequestHeader header, final serverObje

prop.put("parser", i);

prop.put("individualPages", sb.getConfigBool(SwitchboardConstants.PARSER_PDF_INDIVIDUALPAGES, false));
prop.put("individualPagePropertyname", sb.getConfig(SwitchboardConstants.PARSER_PDF_INDIVIDUALPAGES_KEY, "page"));

// return rewrite properties
return prop;
}
Expand Down
15 changes: 7 additions & 8 deletions htroot/yacy/hello.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.peers.Network;
import net.yacy.peers.DHTSelection;
import net.yacy.peers.Protocol;
Expand All @@ -59,7 +58,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
final long start = System.currentTimeMillis();
prop.put("message", "none");
final String clientip = header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "<unknown>"); // read an artificial header addendum
ConcurrentLog.info("**hello-DEBUG**", "client request from = " + clientip);
//ConcurrentLog.info("**hello-DEBUG**", "client request from = " + clientip);
final InetAddress ias = Domains.dnsResolve(clientip);
long time = System.currentTimeMillis();
final long time_dnsResolve = System.currentTimeMillis() - time;
Expand Down Expand Up @@ -152,21 +151,21 @@ public static serverObjects respond(final RequestHeader header, final serverObje
reportedips.add(ias.getHostAddress());
}
final int connectedBefore = sb.peers.sizeConnected();
ConcurrentLog.info("**hello-DEBUG**", "peer " + remoteSeed.getName() + " challenged us with IPs " + reportedips);
//ConcurrentLog.info("**hello-DEBUG**", "peer " + remoteSeed.getName() + " challenged us with IPs " + reportedips);
int callbackRemain = Math.min(5, reportedips.size());
long callbackStart = System.currentTimeMillis();
if (callbackRemain > 0 && reportedips.size() > 0) {
for (String reportedip: reportedips) {
int partialtimeout = ((int) (callbackStart + 6500 - System.currentTimeMillis())) / callbackRemain; // bad hack until a concurrent version is implemented
if (partialtimeout <= 0) break;
ConcurrentLog.info("**hello-DEBUG**", "reportedip = " + reportedip + " is handled");
//ConcurrentLog.info("**hello-DEBUG**", "reportedip = " + reportedip + " is handled");
if (Seed.isProperIP(reportedip)) {
ConcurrentLog.info("**hello-DEBUG**", "starting callback to reportedip = " + reportedip + ", timeout = " + partialtimeout);
//ConcurrentLog.info("**hello-DEBUG**", "starting callback to reportedip = " + reportedip + ", timeout = " + partialtimeout);
prop.put("yourip", reportedip);
remoteSeed.setIP(reportedip);
time = System.currentTimeMillis();
callback = Protocol.queryRWICount(remoteSeed.getPublicAddress(reportedip), remoteSeed.hash, partialtimeout);
ConcurrentLog.info("**hello-DEBUG**", "reportedip = " + reportedip + " returns callback " + (callback == null ? "NULL" : callback[0]));
//ConcurrentLog.info("**hello-DEBUG**", "reportedip = " + reportedip + " returns callback " + (callback == null ? "NULL" : callback[0]));
time_backping = System.currentTimeMillis() - time;
backping_method = "reportedip=" + reportedip;
if (callback[0] >= 0) { success = true; break; }
Expand All @@ -175,7 +174,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
}
}
if (success) {
ConcurrentLog.info("**hello-DEBUG**", "success for IP(s) " + remoteSeed.getIPs() + ", port " + remoteSeed.getPort());
//ConcurrentLog.info("**hello-DEBUG**", "success for IP(s) " + remoteSeed.getIPs() + ", port " + remoteSeed.getPort());
if (remoteSeed.get(Seed.PEERTYPE, Seed.PEERTYPE_SENIOR) == null) {
prop.put(Seed.YOURTYPE, Seed.PEERTYPE_SENIOR);
remoteSeed.put(Seed.PEERTYPE, Seed.PEERTYPE_SENIOR);
Expand All @@ -189,7 +188,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
Network.log.info("hello/server: responded remote " + reportedPeerType + " peer '" + remoteSeed.getName() + "' from " + reportedips + ", time_dnsResolve=" + time_dnsResolve + ", time_backping=" + time_backping + ", method=" + backping_method + ", urls=" + callback[0]);
sb.peers.peerActions.peerArrival(remoteSeed, true);
} else {
ConcurrentLog.info("**hello-DEBUG**", "fail for IP(s) " + remoteSeed.getIPs() + ", port " + remoteSeed.getPort());
//ConcurrentLog.info("**hello-DEBUG**", "fail for IP(s) " + remoteSeed.getIPs() + ", port " + remoteSeed.getPort());
prop.put("yourip", ias.getHostAddress());
remoteSeed.setIP(ias.getHostAddress());
prop.put(Seed.YOURTYPE, Seed.PEERTYPE_JUNIOR);
Expand Down

0 comments on commit 85773eb

Please sign in to comment.