Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Enable api table page navigation with search query
luccioman86c902b85336
diff --git a/htroot/Table_API_p.html b/htroot/Table_API_p.htmlindex 8ad8f4f94..e20dcc2ac 100644--- a/htroot/Table_API_p.html+++ b/htroot/Table_API_p.html@@ -53,13 +53,13 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de<span id="resCounter" style="display: inline;">#(navigation)#::- #(left)#<img src="env/grafics/navdl.gif" alt="no previous page" />::<a href="Table_API_p.html?startRecord=#[startRecord]#&maximumRecords=#[maximumRecords]#&inline=#(inline)#false::true#(/inline)#&filter=#[filter]#" target="_self"><img src="env/grafics/navsl.gif" alt="previous page" /></a>#(/left)#+ #(left)#<img src="env/grafics/navdl.gif" alt="no previous page" />::<a href="Table_API_p.html?startRecord=#[startRecord]#&maximumRecords=#[maximumRecords]#&inline=#(inline)#false::true#(/inline)#&filter=#[filter]#&query=#[query]#" target="_self"><img src="env/grafics/navsl.gif" alt="previous page" /></a>#(/left)##[startRecord]#-#[to]# of #[of]#- #(right)#<img src="env/grafics/navdr.gif" alt="no next page" />::<a href="Table_API_p.html?startRecord=#[startRecord]#&maximumRecords=#[maximumRecords]#&inline=#(inline)#false::true#(/inline)#&filter=#[filter]#" target="_self"><img src="env/grafics/navsr.gif" alt="next page" /></a>#(/right)#+ #(right)#<img src="env/grafics/navdr.gif" alt="no next page" />::<a href="Table_API_p.html?startRecord=#[startRecord]#&maximumRecords=#[maximumRecords]#&inline=#(inline)#false::true#(/inline)#&filter=#[filter]#&query=#[query]#" target="_self"><img src="env/grafics/navsr.gif" alt="next page" /></a>#(/right)#<img src="env/grafics/nave.gif" alt="" />#(/navigation)#- <input type="hidden" name="startRecord" value="#[startRecord]#" />+ <input type="hidden" name="startRecord" value="0" /> <!-- This form is used to type a new query, so we start at record zero --><input type="hidden" name="maximumRecords" value="#[maximumRecords]#" /><input type="hidden" name="inline" value="#(inline)#false::true#(/inline)#" /><input type="hidden" name="filter" value="#[filter]#" />diff --git a/htroot/Table_API_p.java b/htroot/Table_API_p.javaindex 07f6e3a88..52cade26c 100644--- a/htroot/Table_API_p.java+++ b/htroot/Table_API_p.java@@ -47,6 +47,9 @@ import net.yacy.server.serverSwitch;public class Table_API_p {+ /** Default results page size */+ private static final int DEFAULT_MAX_RECORDS = 25;+public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {final Switchboard sb = (Switchboard) env;final serverObjects prop = new serverObjects();@@ -55,7 +58,7 @@ public class Table_API_p {prop.put("showtable", 0);int startRecord = 0;- int maximumRecords = 25;+ int maximumRecords = DEFAULT_MAX_RECORDS;Pattern query = QueryParams.catchall_pattern;if (post != null && post.containsKey("startRecord")) {startRecord = post.getInt("startRecord", 0);@@ -63,10 +66,10 @@ public class Table_API_p {if (post != null && post.containsKey("maximumRecords")) {maximumRecords = post.getInt("maximumRecords", 0);}+ String queryParam = "";if (post != null && post.containsKey("query") && !post.get("query", "").isEmpty()) {- query = Pattern.compile(".*" + post.get("query", "") + ".*");- startRecord = 0;- maximumRecords = 1000;+ queryParam = post.get("query", "");+ query = Pattern.compile(".*" + queryParam + ".*");}final boolean inline = (post != null && post.getBoolean("inline"));@@ -445,8 +448,8 @@ public class Table_API_p {prop.put("showtable_maximumRecords", maximumRecords);prop.put("showtable_inline", (inline) ? 1 : 0);prop.put("showtable_filter", typefilter.pattern());- prop.put("showtable_query", query.pattern().replaceAll("\\.\\*", ""));- if (tablesize >= maximumRecords) {+ prop.put("showtable_query", queryParam);+ if (filteredSize > maximumRecords) {prop.put("showtable_navigation", 1);prop.put("showtable_navigation_startRecord", startRecord);prop.put("showtable_navigation_to", Math.min(tablesize, startRecord + maximumRecords));@@ -456,6 +459,7 @@ public class Table_API_p {prop.put("showtable_navigation_left_maximumRecords", maximumRecords);prop.put("showtable_navigation_left_inline", (inline) ? 1 : 0);prop.put("showtable_navigation_left_filter", typefilter.pattern());+ prop.put("showtable_navigation_left_query", queryParam);prop.put("showtable_navigation_left", startRecord == 0 ? 0 : 1);prop.put("showtable_navigation_filter", typefilter.pattern());prop.put("showtable_navigation_right", startRecord + maximumRecords >= filteredSize ? 0 : 1);@@ -463,6 +467,7 @@ public class Table_API_p {prop.put("showtable_navigation_right_maximumRecords", maximumRecords);prop.put("showtable_navigation_right_inline", (inline) ? 1 : 0);prop.put("showtable_navigation_right_filter", typefilter.pattern());+ prop.put("showtable_navigation_right_query", queryParam);} else {prop.put("showtable_navigation", 0);}