X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fmain%2FConfiguration.java;h=bffea23139776bdd0b971f59251b75e45dd4f3fd;hb=0e6e082a6cb587f93cd364d08bea23bde9191c82;hp=3bbce38059a77079db47823be779ba4bc09d21a8;hpb=b65274cafa2434a4ab471e34d0bc5452b561c71c;p=jSite.git diff --git a/src/de/todesbaum/jsite/main/Configuration.java b/src/de/todesbaum/jsite/main/Configuration.java index 3bbce38..bffea23 100644 --- a/src/de/todesbaum/jsite/main/Configuration.java +++ b/src/de/todesbaum/jsite/main/Configuration.java @@ -49,6 +49,27 @@ import de.todesbaum.util.xml.XML; */ public class Configuration { + /** + * The location of the configuration directory. + * + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> + */ + public enum ConfigurationDirectory { + + /** The configuration is in the same directory as the JAR file. */ + NEXT_TO_JAR_FILE, + + /** + * The configuration is in the user’s home directory. This is the + * pre-0.9.3 default. + */ + HOME_DIRECTORY; + + } + + /** The configuration directory. */ + private ConfigurationDirectory configurationDirectory = ConfigurationDirectory.HOME_DIRECTORY; + /** The name of the file the configuration is stored to. */ private String filename; @@ -332,7 +353,11 @@ public class Configuration { Project project = new Project(); projects.add(project); project.setDescription(projectNode.getNode("description").getValue("")); - project.setIndexFile(projectNode.getNode("index-file").getValue("")); + String indexFile = projectNode.getNode("index-file").getValue(""); + if (indexFile.indexOf('/') > -1) { + indexFile = ""; + } + project.setIndexFile(indexFile); project.setLastInsertionTime(Long.parseLong(projectNode.getNode("last-insertion-time").getValue("0"))); project.setLocalPath(projectNode.getNode("local-path").getValue("")); project.setName(projectNode.getNode("name").getValue("")); @@ -356,7 +381,13 @@ public class Configuration { String filename = fileOptionNode.getNode("filename").getValue(); FileOption fileOption = project.getFileOption(filename); fileOption.setInsert(Boolean.parseBoolean(fileOptionNode.getNode("insert").getValue())); + if (fileOptionNode.getNode("insert-redirect") != null) { + fileOption.setInsertRedirect(Boolean.parseBoolean(fileOptionNode.getNode("insert-redirect").getValue())); + } fileOption.setCustomKey(fileOptionNode.getNode("custom-key").getValue("")); + if (fileOptionNode.getNode("changed-name") != null) { + fileOption.setChangedName(fileOptionNode.getNode("changed-name").getValue()); + } fileOption.setMimeType(fileOptionNode.getNode("mime-type").getValue("")); fileOption.setContainer(fileOptionNode.getNode("container").getValue()); if (fileOptionNode.getNode("replace-edition") != null) { @@ -404,7 +435,9 @@ public class Configuration { SimpleXML fileOptionNode = fileOptionsNode.append("file-option"); fileOptionNode.append("filename", entry.getKey()); fileOptionNode.append("insert", String.valueOf(fileOption.isInsert())); + fileOptionNode.append("insert-redirect", String.valueOf(fileOption.isInsertRedirect())); fileOptionNode.append("custom-key", fileOption.getCustomKey()); + fileOptionNode.append("changed-name", fileOption.getChangedName()); fileOptionNode.append("mime-type", fileOption.getMimeType()); fileOptionNode.append("container", fileOption.getContainer()); fileOptionNode.append("replace-edition", String.valueOf(fileOption.getReplaceEdition()));