git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6207 6c8d7289-2bf4-0310-a012-ef5d649a1542pull/1/head
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;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue