moved parser configuration in separate servelet

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6207 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent 9cfe89c8fc
commit 7d493cf8cc

@ -1,32 +1,40 @@
<form id="parsersettings" action="SettingsAck_p.html" method="post" enctype="multipart/form-data">
<fieldset><legend id="parser">Content Parser Settings</legend>
<p>
With this settings you can activate or deactivate parsing of additional content-types based on their MIME-types.<br />
For a detailed description of the various MIME-types take a look at
<a href="http://www.iana.org/assignments/media-types/">http://www.iana.org/assignments/media-types/</a>
</p>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="TableHeader" valign="bottom">
<td class="small" >enable/disable Parser</td>
<td class="small" >Mime-Type</td>
</tr>#{parser}#
<tr class="TableCellDark">
<td colspan="2">#[name]#</td>
</tr>#{mime}#
<tr class="TableCellLight">
<td class="small" align="center"><input type="checkbox" name="mimename_#[mimetype]#" #(status)#::checked="checked" #(/status)#/></td>
<td class="small">#[mimetype]#</td>
</tr>#{/mime}#
#{/parser}#
<tr class="TableCellDark">
<td class="small" align="center">
<input type="checkbox" name="#[name]#.allParserEnabled" onclick="javascript: ParserCheckboxes(this);" #(allParserEnabled)#::checked="checked" #(/allParserEnabled)#/>
</td>
<td colspan="2" class="small">Enable all parsers</td>
</tr>
<tr class="TableCellDark">
<td colspan="2" class="small" ><input type="submit" name="parserSettings" value="Submit" /> Changes take effect immediately</td>
</tr>
</table>
</fieldset>
</form>
<!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]#': Advanced Settings</title>
#%env/templates/metas.template%#
</head>
<body id="Settings">
#%env/templates/header.template%#
#%env/templates/submenuConfig.template%#
<h2>Parser Configuration</h2>
<form id="parsersettings" action="ConfigParser.html" method="post" enctype="multipart/form-data">
<fieldset><legend id="parser">Content Parser Settings</legend>
<p>
With this settings you can activate or deactivate parsing of additional content-types based on their MIME-types.<br />
For a detailed description of the various MIME-types take a look at
<a href="http://www.iana.org/assignments/media-types/">http://www.iana.org/assignments/media-types/</a>
</p>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="TableHeader" valign="bottom">
<td class="small" >enable/disable Parser</td>
<td class="small" >Mime-Type</td>
</tr>#{parser}#
<tr class="TableCellDark">
<td colspan="2">#[name]#</td>
</tr>#{mime}#
<tr class="TableCellLight">
<td class="small" align="center"><input type="checkbox" name="mimename_#[mimetype]#" #(status)#::checked="checked" #(/status)#/></td>
<td class="small">#[mimetype]#</td>
</tr>#{/mime}#
#{/parser}#
<tr class="TableCellDark">
<td colspan="2" class="small" ><input type="submit" name="parserSettings" value="Submit" /></td>
</tr>
</table>
</fieldset>
</form>
#%env/templates/footer.template%#
</body>
</html>

@ -0,0 +1,79 @@
// ConfigParser.p.java
// (C) 2009 by Michael Peter Christen; mc@yacy.net
// first published on http://yacy.net
// Frankfurt, Germany, 13.07.2009
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// You must compile this file with
// javac -classpath .:../Classes Settings_p.java
// if the shell's current path is HTROOT
import de.anomic.document.Idiom;
import de.anomic.document.Parser;
import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class ConfigParser {
public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
if (post != null) {
if (!sb.verifyAuthentication(header, false)) {
// force log-in
prop.put("AUTHENTICATE", "admin log-in");
return prop;
}
if (post.containsKey("parserSettings")) {
post.remove("parserSettings");
for (Idiom parser: Parser.idioms()) {
for (String mimeType: parser.getSupportedMimeTypes().keySet()) {
Parser.grantMime(mimeType, post.get("mimename_" + mimeType, "").equals("on"));
}
}
env.setConfig(plasmaSwitchboardConstants.PARSER_MIME_DENY, Parser.getDenyMime());
}
}
int i = 0;
for (Idiom parser: Parser.idioms()) {
prop.put("parser_" + i + "_name", parser.getName());
int mimeIdx = 0;
for (String mimeType: parser.getSupportedMimeTypes().keySet()) {
prop.put("parser_" + i + "_mime_" + mimeIdx + "_mimetype", mimeType);
prop.put("parser_" + i + "_mime_" + mimeIdx + "_status", (Parser.supportsMime(mimeType)) ? 1 : 0);
mimeIdx++;
}
prop.put("parser_" + i + "_mime", mimeIdx);
i++;
}
prop.put("parser", i);
// return rewrite properties
return prop;
}
}

@ -81,19 +81,7 @@
<p><strong>The submitted peer name is not well-formed. Please choose a different name.</strong> The Peer name has not been changed.<br />
Peer names must not contain characters other than (a-z, A-Z, 0-9, '-', '_') and must not be longer than 80 characters.
Your Peer Language is: <span class="settingsValue">#[peerLang]#</span></p>
::<!-- 18 -->
<p>
The new parser settings where changed successfully.<br />
Parsing of the following mime-types was enabled:
</p>
<table>
#{parser}#
<tr>
<td class="settingsValue">#[parserMode]#</td>
<td class="settingsValue">#[enabledMime]#</td>
</tr>
#{/parser}#
</table>
::<!-- 18 Parser (removed) -->
::<!-- 19 -->
<p>Seed Upload method was changed successfully.
#(success)#::<br />You are now a principal peer.#(/success)#

@ -35,8 +35,6 @@ import java.util.StringTokenizer;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import de.anomic.document.Idiom;
import de.anomic.document.Parser;
import de.anomic.http.httpRequestHeader;
import de.anomic.http.httpRemoteProxyConfig;
import de.anomic.http.httpd;
@ -45,7 +43,6 @@ import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.order.Digest;
import de.anomic.kelondro.util.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaSwitchboardConstants;
import de.anomic.server.serverCore;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@ -452,25 +449,6 @@ public class SettingsAck_p {
return prop;
}
/*
* Parser configuration
*/
if (post.containsKey("parserSettings")) {
post.remove("parserSettings");
for (Idiom parser: Parser.idioms()) {
for (String mimeType: parser.getSupportedMimeTypes().keySet()) {
Parser.grantMime(mimeType, post.get("mimename_" + mimeType, "").equals("on"));
}
}
env.setConfig(plasmaSwitchboardConstants.PARSER_MIME_DENY, Parser.getDenyMime());
prop.put("info_parser", 0);
prop.put("info", "18");
return prop;
}
// Crawler settings
if (post.containsKey("crawlerSettings")) {

@ -3,22 +3,6 @@
<head>
<title>YaCy '#[clientname]#': Advanced Settings</title>
#%env/templates/metas.template%#
<script type="text/javascript">
/* <![CDATA[ */
function ParserCheckboxes(reference)
{
var mode = reference.name.substring(0,reference.name.indexOf("."));
for(i=0; i<document.getElementById("parsersettings").elements.length; i++)
{
if(document.getElementById("parsersettings").elements[i].type=="checkbox" && document.getElementById("parsersettings").elements[i].name.indexOf(mode) >= 0)
{
document.getElementById("parsersettings").elements[i].checked=reference.checked;
}
}
}
/* ]]> */
</script>
</head>
<body id="Settings">
#%env/templates/header.template%#
@ -37,7 +21,6 @@
<ul class="settingsMenu">
<li><a href="?page=ServerAccess">Server Access Settings</a></li>
<li><a href="?page=ProxyAccess">Proxy Access Settings</a></li>
<li><a href="?page=parser">Content Parser Settings</a></li>
<li><a href="?page=crawler">Crawler Settings</a></li>
<li><a href="?page=http">HTTP Networking</a></li>
<li><a href="?page=proxy">Remote Proxy (optional)</a></li>

@ -1,8 +1,6 @@
// Settings.p.java
// -----------------------
// part of the AnomicHTTPD caching proxy
// Settings.p.java
// (C) by Michael Peter Christen; mc@yacy.net
// first published on http://www.anomic.de
// first published on http://yacy.net
// Frankfurt, Germany, 2004
// last change: 02.05.2004
//
@ -27,8 +25,6 @@
import java.util.HashMap;
import java.util.Iterator;
import de.anomic.document.Idiom;
import de.anomic.document.Parser;
import de.anomic.http.httpHeader;
import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
@ -211,28 +207,7 @@ public final class Settings_p {
prop.put("msgForwardingEnabled",env.getConfig("msgForwardingEnabled","false").equals("true") ? "1" : "0");
prop.putHTML("msgForwardingCmd",env.getConfig("msgForwardingCmd", ""));
prop.putHTML("msgForwardingTo",env.getConfig("msgForwardingTo", ""));
/*
* Parser Configuration
*/
int parserIdx = 0;
for (Idiom parser: Parser.idioms()) {
prop.put("parser_" + parserIdx + "_name", parser.getName());
int mimeIdx = 0;
for (String mimeType: parser.getSupportedMimeTypes().keySet()) {
prop.put("parser_" + parserIdx + "_mime_" + mimeIdx + "_mimetype", mimeType);
prop.put("parser_" + parserIdx + "_mime_" + mimeIdx + "_status", (Parser.supportsMime(mimeType)) ? 1 : 0);
mimeIdx++;
}
prop.put("parser_" + parserIdx + "_mime", mimeIdx);
parserIdx++;
}
prop.put("parser", parserIdx);
// Crawler settings
prop.putHTML("crawler.clientTimeout",sb.getConfig("crawler.clientTimeout", "10000"));
prop.putHTML("crawler.http.maxFileSize",sb.getConfig("crawler.http.maxFileSize", "-1"));

@ -12,7 +12,8 @@
<ul class="SubMenu">
<li><a href="/Performance_p.html" class="MenuItemLink lock">Performance</a></li>
<li><a href="/Settings_p.html" class="MenuItemLink lock">Advanced Settings</a></li>
<li><a href="/ConfigProperties_p.html" class="MenuItemLink lock">Advanced Properties</a></li>
<li><a href="/ConfigParser.html" class="MenuItemLink lock">Parser Configuration</a></li>
<li><a href="/ConfigRobotsTxt_p.html" class="MenuItemLink lock">Local robots.txt</a></li>
<li><a href="/ConfigProperties_p.html" class="MenuItemLink lock">Advanced Properties</a></li>
</ul>
</div>
Loading…
Cancel
Save