prepare ConfigSearchPage servlet to append and remove navigator plugins,

keeping order of added nav's.
The search page preview template displays active navs. Therefore a select
and add button has been added below the preview (to keep it close to actual).
This should in future likely be done by drag&drop (html5 feature).
pull/97/head
reger 8 years ago
parent 60160877f5
commit 8acdc5443b

@ -128,30 +128,21 @@
<li><h3>Provider</h3></li>
</ul></td>
</tr>
<tr>
<td><input type="checkbox" name="search.navigation.namespace" value="true" #(search.navigation.namespace)#::checked="checked" #(/search.navigation.namespace)# /></td>
<td><ul class="nav nav-sidebar menugroup" id="sidebarNameSpace" style="padding-left:15px; padding-right:10px;">
<li><h3>Wiki Name Space</h3></li>
</ul></td>
</tr>
<tr>
<td><input type="checkbox" name="search.navigation.language" value="true" #(search.navigation.language)#::checked="checked" #(/search.navigation.language)# /></td>
<td><ul class="nav nav-sidebar menugroup" id="sidebarLanguages" style="padding-left:15px; padding-right:10px;">
<li><h3>Language</h3></li>
</ul></td>
</tr>
#{search.navigation.plugin}#
<tr>
<td><input type="checkbox" name="search.navigation.authors" value="true" #(search.navigation.authors)#::checked="checked" #(/search.navigation.authors)# /></td>
<td><ul class="nav nav-sidebar menugroup" id="sidebarAuthors" style="padding-left:15px; padding-right:10px;">
<li><h3>Author</h3></li>
</ul></td>
</tr>
<tr>
<td><input type="checkbox" name="search.navigation.collections" value="true" #(search.navigation.collections)#::checked="checked" #(/search.navigation.collections)# /></td>
<td><ul class="nav nav-sidebar menugroup" id="sidebarCollections" style="padding-left:15px; padding-right:10px;">
<li><h3>Collection</h3></li>
</ul></td>
<td><button class="btn btn-xs" name="del.nav" value="#[name]#"><span class="glyphicon glyphicon-remove" style="color: red"/></button></td>
<td><ul class="nav nav-sidebar menugroup" style="padding-left:15px; padding-right:10px;">
<li><h3>#[displayname]#</h3></li>
</ul><input type="hidden" name="search.navigation.active" value="#[name]#" />
</td>
</tr>
#{/search.navigation.plugin}#
<tr>
<td></td>
<td><ul class="nav nav-sidebar menugroup" id="vocabulary" style="padding-left:15px; padding-right:10px;">
@ -161,15 +152,13 @@
<tr>
<td></td>
<td><div id="sidebarAbout" style="padding-left:15px; padding-right:10px; margin-top: 5px;">
<h3>about#[about.headline]#</h3>
<h3>#[about.headline]#</h3>
<div>#[about.body]#</div>
</div></td>
</tr>
</table>
<label for="search.navigation.maxcount">max. items</label>
<input type="text" id="search.navigation.maxcount" name="search.navigation.maxcount" size="4" value="#[search.navigation.maxcount]#">
</fieldset>
</div>
</div>
</td>
<td valign="top">
<div style="float: left;">
@ -286,16 +275,29 @@ var solr= $.getJSON("solr/collection1/select?q=*:*&defType=edismax&start=0&rows=
</table>
</td>
</tr>
</table>
<table>
<tr>
<td>
<fieldset>
<dt>&nbsp;</dt>
<dd>
<input type="submit" name="searchpage_set" value="Save Settings" class="btn btn-primary" />&nbsp;&nbsp;
<input type="submit" name="searchpage_default" value="Set Default Values" class="btn btn-primary" />
</dd>
<fieldset><legend>Add Navigators</legend>
<label for="search.navigation.navname">append</label>
<select type="text" name="search.navigation.navname">
<option value="authors">Authors</option>
<option value="collections">Collection</option>
<option value="namespace">Wiki Name Space</option>
<option value="year">Year</option>
</select>
<button type="submit" name="add.nav" class="btn btn-xs btn-default" ><span class="glyphicon glyphicon-plus-sign" style="color: green"/></button><br>
<label for="search.navigation.maxcount">max. items</label>
<input type="text" id="search.navigation.maxcount" name="search.navigation.maxcount" size="3" value="#[search.navigation.maxcount]#">
</fieldset>
</td>
<td>
<div style="padding-left:25px;">
<input type="submit" name="searchpage_set" value="Save Settings" class="btn btn-primary" />&nbsp;&nbsp;
<input type="submit" name="searchpage_default" value="Set Default Values" class="btn btn-primary" />
</div>
</td>
</tr>
</table>
</form>

@ -30,6 +30,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Date;
import java.util.Map;
import java.util.Properties;
import net.yacy.cora.date.GenericFormatter;
import net.yacy.cora.protocol.RequestHeader;
@ -37,6 +38,8 @@ import net.yacy.cora.util.ConcurrentLog;
import net.yacy.data.WorkTables;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.search.navigator.Navigator;
import net.yacy.search.navigator.NavigatorPlugins;
import net.yacy.search.query.QueryParams;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
@ -87,20 +90,41 @@ public class ConfigSearchPage_p {
if (post.getBoolean("search.navigation.protocol")) nav += "protocol,";
if (post.getBoolean("search.navigation.hosts")) nav += "hosts,";
if (post.getBoolean("search.navigation.language")) nav += "language,";
if (post.getBoolean("search.navigation.authors")) nav += "authors,";
if (post.getBoolean("search.navigation.collections")) nav += "collections,";
if (post.getBoolean("search.navigation.namespace")) nav += "namespace,";
// if (post.getBoolean("search.navigation.authors")) nav += "authors,";
// if (post.getBoolean("search.navigation.collections")) nav += "collections,";
// if (post.getBoolean("search.navigation.namespace")) nav += "namespace,";
if (post.getBoolean("search.navigation.topics")) nav += "topics,";
if (post.getBoolean("search.navigation.date")) nav += "date,";
// append active navigator plugins
String[] navplugins = post.getAll("search.navigation.active");
for (String navname:navplugins) {
nav += navname + ",";
}
if (nav.endsWith(",")) nav = nav.substring(0, nav.length() - 1);
sb.setConfig("search.navigation", nav);
// maxcount default
// maxcount nav entries, default
int navmaxcnt = post.getInt("search.navigation.maxcount", QueryParams.FACETS_STANDARD_MAXCOUNT);
if (navmaxcnt > 5) {
sb.setConfig(SwitchboardConstants.SEARCH_NAVIGATION_MAXCOUNT, navmaxcnt);
if (navmaxcnt != QueryParams.FACETS_STANDARD_MAXCOUNT) QueryParams.FACETS_STANDARD_MAXCOUNT = navmaxcnt;
}
}
if (post.containsKey("add.nav")) { // button: add navigator plugin to ative list
String navname = post.get("search.navigation.navname");
if (navname != null) {
String naviconf = sb.getConfig("search.navigation", "");
naviconf += "," + navname;
sb.setConfig("search.navigation", naviconf);
}
} else if (post.containsKey("del.nav")) { // button: delete navigator plugin from active list
String navname = post.get("del.nav");
String naviconf = sb.getConfig("search.navigation", "");
naviconf = naviconf.replace(navname, "");
naviconf = naviconf.replace(",,", ",");
sb.setConfig("search.navigation", naviconf);
}
if (post.containsKey("searchpage_default")) {
// load defaults from defaults/yacy.init file
final Properties config = new Properties();
@ -176,11 +200,23 @@ public class ConfigSearchPage_p {
prop.put("search.navigation.protocol", sb.getConfig("search.navigation", "").indexOf("protocol",0) >= 0 ? 1 : 0);
prop.put("search.navigation.hosts", sb.getConfig("search.navigation", "").indexOf("hosts",0) >= 0 ? 1 : 0);
prop.put("search.navigation.language", sb.getConfig("search.navigation", "").indexOf("language",0) >= 0 ? 1 : 0);
prop.put("search.navigation.authors", sb.getConfig("search.navigation", "").indexOf("authors",0) >= 0 ? 1 : 0);
prop.put("search.navigation.collections", sb.getConfig("search.navigation", "").indexOf("collections",0) >= 0 ? 1 : 0);
prop.put("search.navigation.namespace", sb.getConfig("search.navigation", "").indexOf("namespace",0) >= 0 ? 1 : 0);
// prop.put("search.navigation.authors", sb.getConfig("search.navigation", "").indexOf("authors",0) >= 0 ? 1 : 0);
// prop.put("search.navigation.collections", sb.getConfig("search.navigation", "").indexOf("collections",0) >= 0 ? 1 : 0);
// prop.put("search.navigation.namespace", sb.getConfig("search.navigation", "").indexOf("namespace",0) >= 0 ? 1 : 0);
prop.put("search.navigation.topics", sb.getConfig("search.navigation", "").indexOf("topics",0) >= 0 ? 1 : 0);
prop.put("search.navigation.date", sb.getConfig("search.navigation", "").indexOf("date",0) >= 0 ? 1 : 0);
// list active navigator plugins
String naviconf = sb.getConfig("search.navigation", "");
Map<String, Navigator> navplugins = NavigatorPlugins.initFromCfgString(naviconf);
int i = 0;
for (String navname:navplugins.keySet()) {
Navigator nav = navplugins.get(navname);
prop.put("search.navigation.plugin_" + i + "_name", navname);
prop.put("search.navigation.plugin_" + i + "_displayname", nav.getDisplayName());
i++;
}
prop.put("search.navigation.plugin", i);
prop.put("search.navigation.maxcount", sb.getConfigInt(SwitchboardConstants.SEARCH_NAVIGATION_MAXCOUNT, QueryParams.FACETS_STANDARD_MAXCOUNT));
prop.put("about.headline", sb.getConfig("about.headline", "About"));

Loading…
Cancel
Save