diff --git a/htroot/Settings_Parser.inc b/htroot/ConfigParser.html similarity index 62% rename from htroot/Settings_Parser.inc rename to htroot/ConfigParser.html index 0a7760cb3..f018338ca 100644 --- a/htroot/Settings_Parser.inc +++ b/htroot/ConfigParser.html @@ -1,32 +1,40 @@ -
-
Content Parser Settings -

- With this settings you can activate or deactivate parsing of additional content-types based on their MIME-types.
- For a detailed description of the various MIME-types take a look at - http://www.iana.org/assignments/media-types/ -

- - - - - #{parser}# - - - #{mime}# - - - - #{/mime}# - #{/parser}# - - - - - - - -
enable/disable ParserMime-Type
#[name]#
#[mimetype]#
- - Enable all parsers
Changes take effect immediately
-
-
\ No newline at end of file + + + + YaCy '#[clientname]#': Advanced Settings + #%env/templates/metas.template%# + + + #%env/templates/header.template%# + #%env/templates/submenuConfig.template%# +

Parser Configuration

+
+
Content Parser Settings +

+ With this settings you can activate or deactivate parsing of additional content-types based on their MIME-types.
+ For a detailed description of the various MIME-types take a look at + http://www.iana.org/assignments/media-types/ +

+ + + + + #{parser}# + + + #{mime}# + + + + #{/mime}# + #{/parser}# + + + +
enable/disable ParserMime-Type
#[name]#
#[mimetype]#
+
+
+ + #%env/templates/footer.template%# + + diff --git a/htroot/ConfigParser.java b/htroot/ConfigParser.java new file mode 100644 index 000000000..7d1775a5d --- /dev/null +++ b/htroot/ConfigParser.java @@ -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; + } +} diff --git a/htroot/SettingsAck_p.html b/htroot/SettingsAck_p.html index 54ca1e30a..db013c05a 100644 --- a/htroot/SettingsAck_p.html +++ b/htroot/SettingsAck_p.html @@ -81,19 +81,7 @@

The submitted peer name is not well-formed. Please choose a different name. The Peer name has not been changed.
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: #[peerLang]#

- :: -

- The new parser settings where changed successfully.
- Parsing of the following mime-types was enabled: -

- - #{parser}# - - - - - #{/parser}# -
#[parserMode]##[enabledMime]#
+ :: ::

Seed Upload method was changed successfully. #(success)#::
You are now a principal peer.#(/success)# diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.java index 3b42b517a..c89e73b87 100644 --- a/htroot/SettingsAck_p.java +++ b/htroot/SettingsAck_p.java @@ -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")) { diff --git a/htroot/Settings_p.html b/htroot/Settings_p.html index 8be9e92ac..a10298134 100644 --- a/htroot/Settings_p.html +++ b/htroot/Settings_p.html @@ -3,22 +3,6 @@ YaCy '#[clientname]#': Advanced Settings #%env/templates/metas.template%# - - #%env/templates/header.template%# @@ -37,7 +21,6 @@