diff --git a/defaults/yacy.init b/defaults/yacy.init index 591790fc5..bec584163 100644 --- a/defaults/yacy.init +++ b/defaults/yacy.init @@ -162,15 +162,23 @@ htTemplatePath = htroot/env/templates htDefaultPath=htroot # individual htroot folder -# every user may publicise her/his own web pages +# every user may publicize her/his own web pages # these pages shall be placed in the path defined here # the htdocs path shares its content with the htroot path htDocsPath = DATA/HTDOCS +# alternative path for the repository path of the web server: the URL +# http://localhost:8080/repository +# points to DATA/HTDOCS/repository, but can be altered with this repository path +# hint: the repository path is the default path for intranet indexing. The easiest ways +# to do a indexing of the local storage system is to set a path here for the repository +# that points to the root path of the files that shall be indexed +repositoryPath=DATA/HTDOCS/repository + # the default files (typically index.html), if no file name is given # The complete path to this file is created by combination with the rootPath # you can set a list of defaults, separated by comma -# the first one is priorized +# the first one is preferred defaultFiles = ConfigBasic.html,index.html,index.htm,default.html,search.html,console.html,control.html,welcome.html,wiki.html,forum.html,blog.html,email.html,content.html,monitor.html,share.html,dir.html,readme.txt # locale-options: YaCy supports localization. diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.java index 1b60fe289..49ea7e677 100644 --- a/source/de/anomic/http/httpdFileHandler.java +++ b/source/de/anomic/http/httpdFileHandler.java @@ -202,35 +202,22 @@ public final class httpdFileHandler { * @param path relative from htroot * @param localeSelection language of localized file; locale.language from switchboard is used if localeSelection.equals("") */ public static File getLocalizedFile(final String path, final String localeSelection){ - if (htDefaultPath == null) htDefaultPath = switchboard.getConfigPath("htDefaultPath","htroot"); - if (htLocalePath == null) htLocalePath = switchboard.getConfigPath("locale.translated_html","DATA/LOCALE/htroot"); + //if (htDefaultPath == null) htDefaultPath = switchboard.getConfigPath("htDefaultPath", "htroot"); + //if (htLocalePath == null) htLocalePath = switchboard.getConfigPath("locale.translated_html", "DATA/LOCALE/htroot"); + //if (htDocsPath == null) htDocsPath = switchboard.getConfigPath(plasmaSwitchboardConstants.HTDOCS_PATH, plasmaSwitchboardConstants.HTDOCS_PATH_DEFAULT); + if (path.startsWith("/repository/")) + return new File(switchboard.getConfig("repositoryPath", "DATA/HTDOCS/repository"), path.substring(11)); if (!(localeSelection.equals("default"))) { final File localePath = new File(htLocalePath, localeSelection + '/' + path); - if (localePath.exists()) // avoid "NoSuchFile" troubles if the "localeSelection" is misspelled - return localePath; + if (localePath.exists()) return localePath; // avoid "NoSuchFile" troubles if the "localeSelection" is misspelled } + + File docsPath = new File(htDocsPath, path); + if (docsPath.exists()) return docsPath; return new File(htDefaultPath, path); } -// private void textMessage(OutputStream out, int retcode, String body) throws IOException { -// httpd.sendRespondHeader( -// this.connectionProperties, // the connection properties -// out, // the output stream -// "HTTP/1.1", // the http version that should be used -// retcode, // the http status code -// null, // the http status message -// "text/plain", // the mimetype -// body.length(), // the content length -// httpc.nowDate(), // the modification date -// null, // the expires date -// null, // cookies -// null, // content encoding -// null); // transfer encoding -// out.write(body.getBytes()); -// out.flush(); -// } - private static final httpResponseHeader getDefaultHeaders(final String path) { final httpResponseHeader headers = new httpResponseHeader(); String ext; @@ -412,7 +399,7 @@ public final class httpdFileHandler { File targetClass=null; // locate the file - if (!(path.startsWith("/"))) path = "/" + path; // attach leading slash + if (!path.startsWith("/") && !path.startsWith("\\")) path = "/" + path; // attach leading slash // a different language can be desired (by i.e. ConfigBasic.html) than the one stored in the locale.language String localeSelection = switchboard.getConfig("locale.language","default"); @@ -426,9 +413,9 @@ public final class httpdFileHandler { } File targetFile = getLocalizedFile(path, localeSelection); - final String targetExt = conProp.getProperty("EXT",""); + final String targetExt = conProp.getProperty("EXT",""); targetClass = rewriteClassFile(new File(htDefaultPath, path)); - if (path.endsWith("/")) { + if (path.endsWith("/") || path.endsWith("\\")) { String testpath; // attach default file name for (int i = 0; i < defaultFiles.length; i++) { @@ -440,13 +427,13 @@ public final class httpdFileHandler { break; } } + targetFile = getLocalizedFile(path, localeSelection); //no defaultfile, send a dirlisting - if (targetFile == null || !targetFile.exists()) { + if (targetFile == null || !targetFile.exists() || (targetFile.exists() && targetFile.isDirectory())) { final StringBuilder aBuffer = new StringBuilder(); aBuffer.append("\n
\n\n\n