diff --git a/htroot/ConfigParser.html b/htroot/ConfigParser.html index 11c39bfb3..2b00b4e40 100644 --- a/htroot/ConfigParser.html +++ b/htroot/ConfigParser.html @@ -3,6 +3,16 @@ YaCy '#[clientname]#': Advanced Settings #%env/templates/metas.template%# + #%env/templates/header.template%# @@ -18,14 +28,21 @@

- + + #{parser}# - #{mime}# + #{ext}# + + + + + #{/ext}##{mime}# + #{/mime}# #{/parser}# diff --git a/htroot/ConfigParser.java b/htroot/ConfigParser.java index 86182ec96..a861da556 100644 --- a/htroot/ConfigParser.java +++ b/htroot/ConfigParser.java @@ -53,6 +53,9 @@ public class ConfigParser { post.remove("parserSettings"); for (final Parser parser: TextParser.parsers()) { + for (final String ext: parser.supportedExtensions()) { + TextParser.grantExtension(ext, "on".equals(post.get("extension_" + ext, ""))); + } for (final String mimeType: parser.supportedMimeTypes()) { TextParser.grantMime(mimeType, "on".equals(post.get("mimename_" + mimeType, ""))); } @@ -65,6 +68,14 @@ public class ConfigParser { for (final Parser parser: TextParser.parsers()) { prop.put("parser_" + i + "_name", parser.getName()); + int extIdx = 0; + for (final String ext: parser.supportedExtensions()) { + prop.put("parser_" + i + "_ext_" + extIdx + "_extension", ext); + prop.put("parser_" + i + "_ext_" + extIdx + "_status", (TextParser.supportsExtension(ext) == null) ? 1 : 0); + extIdx++; + } + prop.put("parser_" + i + "_ext", extIdx); + int mimeIdx = 0; for (final String mimeType: parser.supportedMimeTypes()) { prop.put("parser_" + i + "_mime_" + mimeIdx + "_mimetype", mimeType); diff --git a/source/net/yacy/document/TextParser.java b/source/net/yacy/document/TextParser.java index cd5cd2ca7..850a7a433 100644 --- a/source/net/yacy/document/TextParser.java +++ b/source/net/yacy/document/TextParser.java @@ -380,6 +380,13 @@ public final class TextParser { return idioms; } + + /** + * checks if the parser supports the given mime type. It is not only checked if the parser can parse such types, + * it is also checked if the mime type is not included in the mimetype-deny list. + * @param mimeType + * @return an error if the mime type is not supported, null otherwise + */ public static String supportsMime(String mimeType) { if (mimeType == null) return null; mimeType = normalizeMimeType(mimeType); @@ -388,8 +395,13 @@ public final class TextParser { return null; } - public static String supportsExtension(final MultiProtocolURI url) { - final String ext = url.getFileExtension().toLowerCase(); + /** + * checks if the parser supports the given extension. It is not only checked if the parser can parse such files, + * it is also checked if the extension is not included in the extension-deny list. + * @param extention + * @return an error if the extension is not supported, null otherwise + */ + public static String supportsExtension(final String ext) { if (ext == null || ext.length() == 0) return null; if (denyExtensionx.containsKey(ext)) return "file extension '" + ext + "' is denied (2)"; final String mimeType = ext2mime.get(ext); @@ -400,6 +412,16 @@ public final class TextParser { return null; } + /** + * checks if the parser supports the given extension. It is not only checked if the parser can parse such files, + * it is also checked if the extension is not included in the extension-deny list. + * @param extention + * @return an error if the extension is not supported, null otherwise + */ + public static String supportsExtension(final MultiProtocolURI url) { + return supportsExtension(url.getFileExtension().toLowerCase()); + } + public static String mimeOf(final MultiProtocolURI url) { return mimeOf(url.getFileExtension()); }
enable/disable Parser enable/disableExtension Mime-Type
#[name]#
#[extension]#
#[mimetype]#