From d087e3fdc2e752bc073dee0dcaf5c970c3f1bc7d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 17 Mar 2012 02:53:46 +0100 Subject: [PATCH] Remove file containers and edition replacements. --- src/de/todesbaum/jsite/application/FileOption.java | 93 -------- .../jsite/application/ProjectInserter.java | 117 +--------- src/de/todesbaum/jsite/gui/ProjectFilesPage.java | 251 +-------------------- src/de/todesbaum/jsite/i18n/jSite.properties | 14 -- src/de/todesbaum/jsite/i18n/jSite_de.properties | 14 -- src/de/todesbaum/jsite/i18n/jSite_fr.properties | 14 -- src/de/todesbaum/jsite/main/Configuration.java | 8 - .../todesbaum/util/io/ReplacingOutputStream.java | 83 ------- 8 files changed, 2 insertions(+), 592 deletions(-) delete mode 100644 src/de/todesbaum/util/io/ReplacingOutputStream.java diff --git a/src/de/todesbaum/jsite/application/FileOption.java b/src/de/todesbaum/jsite/application/FileOption.java index 71809c9..118eee2 100644 --- a/src/de/todesbaum/jsite/application/FileOption.java +++ b/src/de/todesbaum/jsite/application/FileOption.java @@ -37,15 +37,6 @@ public class FileOption { /** The default changed name. */ private static final String DEFAULT_CHANGED_NAME = null; - /** The default container. */ - private static final String DEFAULT_CONTAINER = ""; - - /** The default edition range. */ - private static final int DEFAULT_EDITION_RANGE = 3; - - /** The default for the replace edition state. */ - private static final boolean DEFAULT_REPLACE_EDITION = false; - /** The insert state. */ private boolean insert; @@ -64,15 +55,6 @@ public class FileOption { /** The current MIME type. */ private String mimeType; - /** The container. */ - private String container; - - /** The edition range. */ - private int editionRange; - - /** The replace edition state. */ - private boolean replaceEdition; - /** * Creates new file options. * @@ -86,9 +68,6 @@ public class FileOption { changedName = DEFAULT_CHANGED_NAME; this.defaultMimeType = defaultMimeType; mimeType = defaultMimeType; - container = DEFAULT_CONTAINER; - editionRange = DEFAULT_EDITION_RANGE; - replaceEdition = DEFAULT_REPLACE_EDITION; } /** @@ -230,69 +209,6 @@ public class FileOption { } /** - * Returns the name of the container this file should be put in. - * - * @return The name of the container - */ - public String getContainer() { - return container; - } - - /** - * Sets the name of the container this file should be put in. - * - * @param container - * The name of the container - */ - public void setContainer(String container) { - if (container == null) { - this.container = DEFAULT_CONTAINER; - } else { - this.container = container; - } - } - - /** - * Sets whether the file should have “$[EDITION+n]” tags replaced. - * - * @param replaceEdition - * true to replace tags, false not to - * replace - */ - public void setReplaceEdition(boolean replaceEdition) { - this.replaceEdition = replaceEdition; - } - - /** - * Returns whether the file should have “$[EDITION+n]” tags replaced. - * - * @return true if tags should be replaced, false - * otherwise - */ - public boolean getReplaceEdition() { - return replaceEdition; - } - - /** - * Sets the range of editions that should be replaced. - * - * @param editionRange - * The range editions to replace - */ - public void setEditionRange(int editionRange) { - this.editionRange = editionRange; - } - - /** - * Returns the range of editions that should be replaced. - * - * @return The range of editions to replace - */ - public int getEditionRange() { - return editionRange; - } - - /** * Returns whether the options for this file have been modified, i.e. are * not at their default values. * @@ -312,15 +228,6 @@ public class FileOption { if (!defaultMimeType.equals(mimeType)) { return true; } - if (!DEFAULT_CONTAINER.equals(container)) { - return true; - } - if (replaceEdition != DEFAULT_REPLACE_EDITION) { - return true; - } - if (editionRange != DEFAULT_EDITION_RANGE) { - return true; - } if (insertRedirect != DEFAULT_INSERT_REDIRECT) { return true; } diff --git a/src/de/todesbaum/jsite/application/ProjectInserter.java b/src/de/todesbaum/jsite/application/ProjectInserter.java index 6b21697..db4d514 100644 --- a/src/de/todesbaum/jsite/application/ProjectInserter.java +++ b/src/de/todesbaum/jsite/application/ProjectInserter.java @@ -18,16 +18,12 @@ package de.todesbaum.jsite.application; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -36,8 +32,6 @@ import java.util.Set; import java.util.Map.Entry; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; import de.todesbaum.jsite.gui.FileScanner; import de.todesbaum.jsite.gui.FileScannerListener; @@ -50,9 +44,6 @@ import de.todesbaum.util.freenet.fcp2.FileEntry; import de.todesbaum.util.freenet.fcp2.Message; import de.todesbaum.util.freenet.fcp2.RedirectFileEntry; import de.todesbaum.util.freenet.fcp2.Verbosity; -import de.todesbaum.util.io.Closer; -import de.todesbaum.util.io.ReplacingOutputStream; -import de.todesbaum.util.io.StreamCopier; import de.todesbaum.util.io.StreamCopier.ProgressListener; /** @@ -270,76 +261,7 @@ public class ProjectInserter implements FileScannerListener, Runnable { private InputStream createFileInputStream(String filename, FileOption fileOption, int edition, long[] length) throws IOException { File file = new File(project.getLocalPath(), filename); length[0] = file.length(); - if (!fileOption.getReplaceEdition()) { - return new FileInputStream(file); - } - ByteArrayOutputStream filteredByteOutputStream = new ByteArrayOutputStream(Math.min(Integer.MAX_VALUE, (int) length[0])); - ReplacingOutputStream outputStream = new ReplacingOutputStream(filteredByteOutputStream); - FileInputStream fileInput = new FileInputStream(file); - try { - outputStream.addReplacement("$[EDITION]", String.valueOf(edition)); - outputStream.addReplacement("$[URI]", project.getFinalRequestURI(0)); - for (int index = 1; index <= fileOption.getEditionRange(); index++) { - outputStream.addReplacement("$[URI+" + index + "]", project.getFinalRequestURI(index)); - outputStream.addReplacement("$[EDITION+" + index + "]", String.valueOf(edition + index)); - } - StreamCopier.copy(fileInput, outputStream, length[0]); - } finally { - Closer.close(fileInput); - Closer.close(outputStream); - Closer.close(filteredByteOutputStream); - } - byte[] filteredBytes = filteredByteOutputStream.toByteArray(); - length[0] = filteredBytes.length; - return new ByteArrayInputStream(filteredBytes); - } - - /** - * Creates an input stream for a container. - * - * @param containerFiles - * All container definitions - * @param containerName - * The name of the container to create - * @param edition - * The current edition - * @param containerLength - * An array containing a single long which is used to - * return the final length of the container stream, - * after all replacements - * @return The input stream for the container - * @throws IOException - * if an I/O error occurs - */ - private InputStream createContainerInputStream(Map> containerFiles, String containerName, int edition, long[] containerLength) throws IOException { - File tempFile = File.createTempFile("jsite", ".zip", (tempDirectory == null) ? null : new File(tempDirectory)); - tempFile.deleteOnExit(); - FileOutputStream fileOutputStream = new FileOutputStream(tempFile); - ZipOutputStream zipOutputStream = new ZipOutputStream(fileOutputStream); - try { - for (String filename : containerFiles.get(containerName)) { - File dataFile = new File(project.getLocalPath(), filename); - if (dataFile.exists()) { - ZipEntry zipEntry = new ZipEntry(filename); - long[] fileLength = new long[1]; - InputStream wrappedInputStream = createFileInputStream(filename, project.getFileOption(filename), edition, fileLength); - try { - zipOutputStream.putNextEntry(zipEntry); - StreamCopier.copy(wrappedInputStream, zipOutputStream, fileLength[0]); - } finally { - zipOutputStream.closeEntry(); - wrappedInputStream.close(); - } - } - } - } finally { - zipOutputStream.closeEntry(); - Closer.close(zipOutputStream); - Closer.close(fileOutputStream); - } - - containerLength[0] = tempFile.length(); - return new FileInputStream(tempFile); + return new FileInputStream(file); } /** @@ -357,8 +279,6 @@ public class ProjectInserter implements FileScannerListener, Runnable { private FileEntry createFileEntry(String filename, int edition, Map> containerFiles) { FileEntry fileEntry = null; FileOption fileOption = project.getFileOption(filename); - if (filename.startsWith("/container/:")) { - String containerName = filename.substring("/container/:".length()); try { long[] containerLength = new long[1]; InputStream containerInputStream = createContainerInputStream(containerFiles, containerName, edition, containerLength); @@ -385,33 +305,6 @@ public class ProjectInserter implements FileScannerListener, Runnable { } /** - * Creates container definitions. - * - * @param files - * The list of all files - * @param containers - * The list of all containers - * @param containerFiles - * Empty map that will be filled with container definitions - */ - private void createContainers(List files, List containers, Map> containerFiles) { - for (String filename : new ArrayList(files)) { - FileOption fileOption = project.getFileOption(filename); - String containerName = fileOption.getContainer(); - if (!containerName.equals("")) { - if (!containers.contains(containerName)) { - containers.add(containerName); - containerFiles.put(containerName, new ArrayList()); - /* hmm. looks like a hack to me. */ - files.add("/container/:" + containerName); - } - containerFiles.get(containerName).add(filename); - files.remove(filename); - } - } - } - - /** * Validates the given project. The project will be checked for any invalid * conditions, such as invalid insert or request keys, missing path names, * missing default file, and so on. @@ -438,9 +331,6 @@ public class ProjectInserter implements FileScannerListener, Runnable { } String indexFile = project.getIndexFile(); boolean hasIndexFile = (indexFile != null) && (indexFile.length() > 0); - if (hasIndexFile && !project.getFileOption(indexFile).getContainer().equals("")) { - checkReport.addIssue("warning.container-index", false); - } List allowedIndexContentTypes = Arrays.asList("text/html", "application/xhtml+xml"); if (hasIndexFile && !allowedIndexContentTypes.contains(project.getFileOption(indexFile).getMimeType())) { checkReport.addIssue("warning.index-not-html", false); @@ -508,11 +398,6 @@ public class ProjectInserter implements FileScannerListener, Runnable { Client client = new Client(connection); - /* create containers */ - final List containers = new ArrayList(); - final Map> containerFiles = new HashMap>(); - createContainers(files, containers, containerFiles); - /* collect files */ int edition = project.getEdition(); String dirURI = "USK@" + project.getInsertURI() + "/" + project.getPath() + "/" + edition + "/"; diff --git a/src/de/todesbaum/jsite/gui/ProjectFilesPage.java b/src/de/todesbaum/jsite/gui/ProjectFilesPage.java index 16bd860..2b19a72 100644 --- a/src/de/todesbaum/jsite/gui/ProjectFilesPage.java +++ b/src/de/todesbaum/jsite/gui/ProjectFilesPage.java @@ -20,7 +20,6 @@ package de.todesbaum.jsite.gui; import java.awt.BorderLayout; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; @@ -29,7 +28,6 @@ import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -37,7 +35,6 @@ import java.util.Set; import javax.swing.AbstractAction; import javax.swing.Action; -import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -47,14 +44,9 @@ import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JSpinner; import javax.swing.JTextField; import javax.swing.ListSelectionModel; -import javax.swing.SpinnerNumberModel; import javax.swing.SwingUtilities; -import javax.swing.border.EmptyBorder; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.ListSelectionEvent; @@ -76,7 +68,7 @@ import de.todesbaum.util.swing.TWizardPage; * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ -public class ProjectFilesPage extends TWizardPage implements ActionListener, ListSelectionListener, DocumentListener, FileScannerListener, ChangeListener { +public class ProjectFilesPage extends TWizardPage implements ActionListener, ListSelectionListener, DocumentListener, FileScannerListener { /** The project. */ private Project project; @@ -84,15 +76,6 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis /** The “scan files” action. */ private Action scanAction; - /** The “edit container” action. */ - private Action editContainerAction; - - /** The “add container” action. */ - private Action addContainerAction; - - /** The “delete container” action. */ - protected Action deleteContainerAction; - /** The “ignore hidden files” checkbox. */ private JCheckBox ignoreHiddenFilesCheckBox; @@ -120,18 +103,6 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis /** The “mime type” combo box. */ private JComboBox fileOptionsMIMETypeComboBox; - /** The “mime type” combo box model. */ - private DefaultComboBoxModel containerComboBoxModel; - - /** The “container” combo box. */ - private JComboBox fileOptionsContainerComboBox; - - /** The “edition replacement range” spinner. */ - private JSpinner replaceEditionRangeSpinner; - - /** The “replacement” check box. */ - private JCheckBox replacementCheckBox; - /** * Creates a new project file page. * @@ -166,48 +137,12 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis scanAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_S); scanAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.rescan.tooltip")); - addContainerAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.add-container")) { - - @SuppressWarnings("synthetic-access") - public void actionPerformed(ActionEvent actionEvent) { - actionAddContainer(); - } - }; - addContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.add-container.tooltip")); - addContainerAction.setEnabled(false); - - editContainerAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.edit-container")) { - - @SuppressWarnings("synthetic-access") - public void actionPerformed(ActionEvent actionEvent) { - actionEditContainer(); - } - }; - editContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.edit-container.tooltip")); - editContainerAction.setEnabled(false); - - deleteContainerAction = new AbstractAction(I18n.getMessage("jsite.project-files.action.delete-container")) { - - @SuppressWarnings("synthetic-access") - public void actionPerformed(ActionEvent actionEvent) { - actionDeleteContainer(); - } - }; - deleteContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.delete-container.tooltip")); - deleteContainerAction.setEnabled(false); - I18nContainer.getInstance().registerRunnable(new Runnable() { @SuppressWarnings("synthetic-access") public void run() { scanAction.putValue(Action.NAME, I18n.getMessage("jsite.project-files.action.rescan")); scanAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.rescan.tooltip")); - addContainerAction.putValue(Action.NAME, I18n.getMessage("jsite.project-files.action.add-container")); - addContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.add-container.tooltip")); - editContainerAction.putValue(Action.NAME, I18n.getMessage("jsite.project-files.action.edit-container")); - editContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.edit-container.tooltip")); - deleteContainerAction.putValue(Action.NAME, I18n.getMessage("jsite.project-files.action.delete-container")); - deleteContainerAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project-files.action.delete-container.tooltip")); } }); } @@ -339,52 +274,6 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis fileOptionsPanel.add(mimeTypeLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0)); fileOptionsPanel.add(fileOptionsMIMETypeComboBox, new GridBagConstraints(1, 7, 4, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); - containerComboBoxModel = new DefaultComboBoxModel(); - fileOptionsContainerComboBox = new JComboBox(containerComboBoxModel); - fileOptionsContainerComboBox.setToolTipText(I18n.getMessage("jsite.project-files.container.tooltip")); - fileOptionsContainerComboBox.setName("project-files.container"); - fileOptionsContainerComboBox.addActionListener(this); - fileOptionsContainerComboBox.setEnabled(false); - fileOptionsContainerComboBox.setVisible(false); - - final TLabel containerLabel = new TLabel(I18n.getMessage("jsite.project-files.container") + ":", KeyEvent.VK_C, fileOptionsContainerComboBox); - containerLabel.setVisible(false); - JButton addContainerButton = new JButton(addContainerAction); - addContainerButton.setVisible(false); - JButton editContainerButton = new JButton(editContainerAction); - editContainerButton.setVisible(false); - JButton deleteContainerButton = new JButton(deleteContainerAction); - deleteContainerButton.setVisible(false); - fileOptionsPanel.add(containerLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0)); - fileOptionsPanel.add(fileOptionsContainerComboBox, new GridBagConstraints(1, 8, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); - fileOptionsPanel.add(addContainerButton, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); - fileOptionsPanel.add(editContainerButton, new GridBagConstraints(3, 8, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); - fileOptionsPanel.add(deleteContainerButton, new GridBagConstraints(4, 8, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0)); - - JPanel fileOptionsReplacementPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 6, 6)); - fileOptionsReplacementPanel.setBorder(new EmptyBorder(-6, -6, -6, -6)); - - replacementCheckBox = new JCheckBox(I18n.getMessage("jsite.project-files.replacement")); - replacementCheckBox.setName("project-files.replace-edition"); - replacementCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.replacement.tooltip")); - replacementCheckBox.addActionListener(this); - replacementCheckBox.setEnabled(false); - replacementCheckBox.setVisible(false); - fileOptionsReplacementPanel.add(replacementCheckBox); - - replaceEditionRangeSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 99, 1)); - replaceEditionRangeSpinner.setName("project-files.replace-edition-range"); - replaceEditionRangeSpinner.setToolTipText(I18n.getMessage("jsite.project-files.replacement.edition-range.tooltip")); - replaceEditionRangeSpinner.addChangeListener(this); - replaceEditionRangeSpinner.setEnabled(false); - replaceEditionRangeSpinner.setVisible(false); - final JLabel editionRangeLabel = new JLabel(I18n.getMessage("jsite.project-files.replacement.edition-range")); - editionRangeLabel.setVisible(false); - fileOptionsReplacementPanel.add(editionRangeLabel); - fileOptionsReplacementPanel.add(replaceEditionRangeSpinner); - - fileOptionsPanel.add(fileOptionsReplacementPanel, new GridBagConstraints(0, 9, 5, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 18, 0, 0), 0, 0)); - I18nContainer.getInstance().registerRunnable(new Runnable() { @SuppressWarnings("synthetic-access") @@ -404,12 +293,6 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis fileOptionsRenameCheckBox.setToolTipText("jsite.project-files.rename.tooltip"); fileOptionsMIMETypeComboBox.setToolTipText(I18n.getMessage("jsite.project-files.mime-type.tooltip")); mimeTypeLabel.setText(I18n.getMessage("jsite.project-files.mime-type") + ":"); - fileOptionsContainerComboBox.setToolTipText(I18n.getMessage("jsite.project-files.container.tooltip")); - containerLabel.setText(I18n.getMessage("jsite.project-files.container") + ":"); - replacementCheckBox.setText(I18n.getMessage("jsite.project-files.replacement")); - replacementCheckBox.setToolTipText(I18n.getMessage("jsite.project-files.replacement.tooltip")); - replaceEditionRangeSpinner.setToolTipText(I18n.getMessage("jsite.project-files.replacement.edition-range.tooltip")); - editionRangeLabel.setText(I18n.getMessage("jsite.project-files.replacement.edition-range")); } }); @@ -449,29 +332,6 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis return files; } - /** - * Updates the container combo box model. - */ - private void rebuildContainerComboBox() { - /* scan files for containers */ - List files = getProjectFiles(); - List containers = new ArrayList(); // ComboBoxModel - // sucks. No - // contains()! - containers.add(""); - for (String filename : files) { - String container = project.getFileOption(filename).getContainer(); - if (!containers.contains(container)) { - containers.add(container); - } - } - Collections.sort(containers); - containerComboBoxModel.removeAllElements(); - for (String container : containers) { - containerComboBoxModel.addElement(container); - } - } - // // ACTIONS // @@ -493,66 +353,6 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis } /** - * Adds a container. - */ - private void actionAddContainer() { - String containerName = JOptionPane.showInputDialog(wizard, I18n.getMessage("jsite.project-files.action.add-container.message") + ":", null, JOptionPane.INFORMATION_MESSAGE); - if (containerName == null) { - return; - } - containerName = containerName.trim(); - String filename = (String) projectFileList.getSelectedValue(); - FileOption fileOption = project.getFileOption(filename); - fileOption.setContainer(containerName); - rebuildContainerComboBox(); - fileOptionsContainerComboBox.setSelectedItem(containerName); - } - - /** - * Edits the container. - */ - private void actionEditContainer() { - String selectedFilename = (String) projectFileList.getSelectedValue(); - FileOption fileOption = project.getFileOption(selectedFilename); - String oldContainerName = fileOption.getContainer(); - String containerName = JOptionPane.showInputDialog(wizard, I18n.getMessage("jsite.project-files.action.edit-container.message") + ":", oldContainerName); - if (containerName == null) { - return; - } - if (containerName.equals("")) { - fileOption.setContainer(""); - fileOptionsContainerComboBox.setSelectedItem(""); - return; - } - List files = getProjectFiles(); - for (String filename : files) { - fileOption = project.getFileOption(filename); - if (fileOption.getContainer().equals(oldContainerName)) { - fileOption.setContainer(containerName); - } - } - rebuildContainerComboBox(); - fileOptionsContainerComboBox.setSelectedItem(containerName); - } - - /** - * Deletes the container. - */ - private void actionDeleteContainer() { - if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.action.delete-container.message"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { - String containerName = (String) fileOptionsContainerComboBox.getSelectedItem(); - List files = getProjectFiles(); - for (String filename : files) { - FileOption fileOption = project.getFileOption(filename); - if (fileOption.getContainer().equals(containerName)) { - fileOption.setContainer(""); - } - } - fileOptionsContainerComboBox.setSelectedItem(""); - } - } - - /** * {@inheritDoc} *

* Updates the file list. @@ -567,7 +367,6 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis public void run() { projectFileList.setListData(files.toArray(new String[files.size()])); projectFileList.clearSelection(); - rebuildContainerComboBox(); } }); Set entriesToRemove = new HashSet(); @@ -647,9 +446,6 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis } else if ("insert".equals(checkBox.getName())) { boolean isInsert = checkBox.isSelected(); fileOption.setInsert(isInsert); - if (!isInsert) { - fileOptionsContainerComboBox.setSelectedItem(""); - } fileOptionsInsertRedirectCheckBox.setEnabled(!isInsert); } else if ("insert-redirect".equals(checkBox.getName())) { boolean isInsertRedirect = checkBox.isSelected(); @@ -659,24 +455,11 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis boolean isRenamed = checkBox.isSelected(); fileOptionsRenameTextField.setEnabled(isRenamed); fileOption.setChangedName(isRenamed ? fileOptionsRenameTextField.getText() : ""); - } else if ("project-files.replace-edition".equals(checkBox.getName())) { - boolean replaceEdition = checkBox.isSelected(); - fileOption.setReplaceEdition(replaceEdition); - replaceEditionRangeSpinner.setEnabled(replaceEdition); } } else if (source instanceof JComboBox) { JComboBox comboBox = (JComboBox) source; if ("project-files.mime-type".equals(comboBox.getName())) { fileOption.setMimeType((String) comboBox.getSelectedItem()); - } else if ("project-files.container".equals(comboBox.getName())) { - String containerName = (String) comboBox.getSelectedItem(); - fileOption.setContainer(containerName); - boolean enabled = !"".equals(containerName); - editContainerAction.setEnabled(enabled); - deleteContainerAction.setEnabled(enabled); - if (enabled) { - fileOptionsInsertCheckBox.setSelected(true); - } } } } @@ -696,11 +479,6 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis fileOptionsInsertCheckBox.setEnabled(enabled); fileOptionsRenameCheckBox.setEnabled(enabled); fileOptionsMIMETypeComboBox.setEnabled(enabled); - fileOptionsContainerComboBox.setEnabled(enabled); - addContainerAction.setEnabled(enabled); - editContainerAction.setEnabled(enabled); - deleteContainerAction.setEnabled(enabled); - replacementCheckBox.setEnabled(enabled && insert); if (filename != null) { FileOption fileOption = project.getFileOption(filename); defaultFileCheckBox.setSelected(filename.equals(project.getIndexFile())); @@ -713,10 +491,6 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis fileOptionsRenameTextField.setEnabled(fileOption.hasChangedName()); fileOptionsRenameTextField.setText(fileOption.getChangedName()); fileOptionsMIMETypeComboBox.getModel().setSelectedItem(fileOption.getMimeType()); - fileOptionsContainerComboBox.setSelectedItem(fileOption.getContainer()); - replacementCheckBox.setSelected(fileOption.getReplaceEdition()); - replaceEditionRangeSpinner.setValue(fileOption.getEditionRange()); - replaceEditionRangeSpinner.setEnabled(fileOption.getReplaceEdition()); } else { defaultFileCheckBox.setSelected(false); fileOptionsInsertCheckBox.setSelected(true); @@ -729,9 +503,6 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis fileOptionsRenameTextField.setEnabled(false); fileOptionsRenameTextField.setText(""); fileOptionsMIMETypeComboBox.getModel().setSelectedItem(DefaultMIMETypes.DEFAULT_MIME_TYPE); - fileOptionsContainerComboBox.setSelectedItem(""); - replacementCheckBox.setSelected(false); - replaceEditionRangeSpinner.setValue(0); } } @@ -782,24 +553,4 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis processDocumentUpdate(documentEvent); } - // - // INTERFACE ChangeListener - // - - /** - * {@inheritDoc} - */ - public void stateChanged(ChangeEvent changeEvent) { - String filename = (String) projectFileList.getSelectedValue(); - if (filename == null) { - return; - } - FileOption fileOption = project.getFileOption(filename); - Object source = changeEvent.getSource(); - if (source instanceof JSpinner) { - JSpinner spinner = (JSpinner) source; - fileOption.setEditionRange((Integer) spinner.getValue()); - } - } - } diff --git a/src/de/todesbaum/jsite/i18n/jSite.properties b/src/de/todesbaum/jsite/i18n/jSite.properties index f5f759e..fe5c5b7 100644 --- a/src/de/todesbaum/jsite/i18n/jSite.properties +++ b/src/de/todesbaum/jsite/i18n/jSite.properties @@ -137,15 +137,6 @@ jsite.project-files.heading=Project Files jsite.project-files.description=On this page you can specify parameters for the files within the project, such as
externally generated keys or MIME types, if the automatic detection failed. jsite.project-files.action.rescan=Re-scan jsite.project-files.action.rescan.tooltip=Re-scan the project directory for new files -jsite.project-files.action.add-container=Add -jsite.project-files.action.add-container.tooltip=Adds a new container to the project and this file to it -jsite.project-files.action.add-container.message=Enter the name of the new container -jsite.project-files.action.edit-container=Edit -jsite.project-files.action.edit-container.tooltip=Changes the name of the container -jsite.project-files.action.edit-container.message=Enter the new name of the container -jsite.project-files.action.delete-container=Delete -jsite.project-files.action.delete-container.tooltip=Deletes this container -jsite.project-files.action.delete-container.message=Do you really want to delete this container? jsite.project-files.ignore-hidden-files=Ignore hidden files jsite.project-files.ignore-hidden-files.tooltip=When selected, hidden files are not inserted jsite.project-files.file-options=File Options @@ -163,10 +154,6 @@ jsite.project-files.mime-type=MIME type jsite.project-files.mime-type.tooltip=Select the correct MIME type here if the detection failed jsite.project-files.container=Container jsite.project-files.container.tooltip=Selects a container for the current file -jsite.project-files.replacement=Replacements -jsite.project-files.replacement.tooltip=Activates replacements in file -jsite.project-files.replacement.edition-range=Range -jsite.project-files.replacement.edition-range.tooltip=Also replace $[EDITION+1], $[EDITION+2]\u2026 jsite.project-files.scan-error=Error scanning files

Either the directory of the project does not exist
or some files/directories in it are not accessible.
Please go back and select the correct directory. jsite.project-files.insert-now=Insert now jsite.project-files.invalid-default-file=Only files in the root directory may be selected as default files. @@ -189,7 +176,6 @@ jsite.key-dialog.label.public-key=Public Key jsite.key-dialog.label.actions=Actions jsite.warning.empty-index=No default file

You did not specify a default file for this project.
While it is possible to insert a project without a default
file you should specify one to ease browsing. -jsite.warning.container-index=Default file in container

Your default file was placed in a container!
This might make other people shun your page. jsite.warning.index-not-html=Default file is not HTML

Your default file does not have the MIME type "text/html"!
Loading your Freesite in a browser may give unexpected results. jsite.error.no-node-selected=No node selected

Please select a node from the menu! diff --git a/src/de/todesbaum/jsite/i18n/jSite_de.properties b/src/de/todesbaum/jsite/i18n/jSite_de.properties index b228873..07fbe76 100644 --- a/src/de/todesbaum/jsite/i18n/jSite_de.properties +++ b/src/de/todesbaum/jsite/i18n/jSite_de.properties @@ -137,15 +137,6 @@ jsite.project-files.heading=Projektdateien jsite.project-files.description=Auf dieser Seite k\u00f6nnen Parameter f\u00fcr die einzelnen Dateien dieses Projekts angegeben werden, z.B.
extern erstellte Schl\u00fcssel oder der korrekte MIME-Typ, wenn er nicht automatisch richtig erkannt wurde. jsite.project-files.action.rescan=Erneut einlesen jsite.project-files.action.rescan.tooltip=Die Liste mit Dateien dieses Projekts neu einlesen -jsite.project-files.action.add-container=Hinzuf\u00fcgen -jsite.project-files.action.add-container.tooltip=Erzeugt einen neuen Container und f\u00fcgt diese Datei hinzu -jsite.project-files.action.add-container.message=Bitte geben Sie den Namen des neuen Containers an -jsite.project-files.action.edit-container=\u00c4ndern -jsite.project-files.action.edit-container.tooltip=\u00c4ndert den Namen des Containers -jsite.project-files.action.edit-container.message=Bitte geben Sie den neuen Namen des Containers an -jsite.project-files.action.delete-container=L\u00f6schen -jsite.project-files.action.delete-container.tooltip=L\u00f6scht diesen Container -jsite.project-files.action.delete-container.message=Wollen Sie diesen Container wirklich l\u00f6schen? jsite.project-files.ignore-hidden-files=Versteckte Dateien ignorieren jsite.project-files.ignore-hidden-files.tooltip=Verhindert, dass versteckte Dateien hochgeladen werden jsite.project-files.file-options=Dateioptionen @@ -163,10 +154,6 @@ jsite.project-files.mime-type=MIME-Typ jsite.project-files.mime-type.tooltip=Den richtigen MIME-Typ hier ausw\u00e4hlen, wenn die automatische Erkennenung falsch ist jsite.project-files.container=Container jsite.project-files.container.tooltip=W\u00e4hlt einen Container f\u00fcr diese Datei aus -jsite.project-files.replacement=Ersetzungen -jsite.project-files.replacement.tooltip=Aktiviert Ersetzungen in Datei -jsite.project-files.replacement.edition-range=Reichweite -jsite.project-files.replacement.edition-range.tooltip=Ersetzt auch $[EDITION+1], $[EDITION+2], usw. jsite.project-files.scan-error=Fehler beim Einlesen der Dateien

Entweder existiert das Projektverzeichnis nicht,
oder einige Dateien und/oder Verzeichnisse sind nicht lesbar!
Bitte gehen Sie zur\u00fcck und beheben Sie den Fehler! jsite.project-files.insert-now=Jetzt einf\u00fcgen jsite.project-files.invalid-default-file=Nur Dateien im obersten Verzeichnis d\u00fcrfen als Index-Dateien ausgew\u00e4hlt werden. @@ -189,7 +176,6 @@ jsite.key-dialog.label.public-key=\u00d6ffentlicher Schl\u00fcssel jsite.key-dialog.label.actions=Aktionen jsite.warning.empty-index=Keine Index-Datei gew\u00e4hlt

Sie haben keine Index-Datei f\u00fcr das Projekt angegeben.
Obwohl es m\u00f6glich ist, das zu machen, sollten Sie doch
eine Index-Datei angeben, um das Browsen zu erleichtern. -jsite.warning.container-index=Index-Datei in Container

Ihre Index-Datei befindet sich in einem Container! Das kann
dazu f\u00fchren, dass Ihre Freesite von anderen Leuten gemieden wird. jsite.warning.index-not-html=Index-Datei ist kein HTML

Ihre Index-Datei hat nicht den MIME-Typ "text/html"!
Das kann beim Besuch Ihrer Freesite zu
unerwarteten Ergebnissen f\u00fchren. jsite.error.no-node-selected=Kein Node ausgew\u00e4hlt

Bitte w\u00e4hlen Sie einen Node aus dem Men\u00fc! diff --git a/src/de/todesbaum/jsite/i18n/jSite_fr.properties b/src/de/todesbaum/jsite/i18n/jSite_fr.properties index 87dc969..9561549 100644 --- a/src/de/todesbaum/jsite/i18n/jSite_fr.properties +++ b/src/de/todesbaum/jsite/i18n/jSite_fr.properties @@ -127,15 +127,6 @@ jsite.project-files.heading=Fichiers du projet jsite.project-files.description=Dans cette page vous pouvez sp\u00e9cifier les informations concernant la configuration des noeuds telles que:
Le type de contenu mime si l'auto d\u00e9tection \u00e0 \u00e9chou\u00e9e. jsite.project-files.action.rescan=Re-scan jsite.project-files.action.rescan.tooltip=V\u00e9rifier la pr\u00e9sence de nouveau fichiers -jsite.project-files.action.add-container=Ajouter -jsite.project-files.action.add-container.tooltip=Ajouter un nouveau container au projet -jsite.project-files.action.add-container.message=Entrez le nom du container -jsite.project-files.action.edit-container=Editer -jsite.project-files.action.edit-container.tooltip=Changer le nom du container -jsite.project-files.action.edit-container.message=Entrez le nouveau nom du container -jsite.project-files.action.delete-container=Supprimer -jsite.project-files.action.delete-container.tooltip=Supprimer ce container. -jsite.project-files.action.delete-container.message=Voulez vous r\u00e9ellement supprimer ce container? jsite.project-files.ignore-hidden-files=Ignorer les fichiers cach\u00e9s jsite.project-files.ignore-hidden-files.tooltip=Si s\u00e9lectionn\u00e9, les fichiers cach\u00e9s ne sont pas ins\u00e9r\u00e9s jsite.project-files.file-options=Option des fichiers @@ -153,10 +144,6 @@ jsite.project-files.mime-type=MIME type jsite.project-files.mime-type.tooltip=S\u00e9lectionez le type MIME du fichier si la d\u00e9tection \u00e0 \u00e9chou\u00e9e jsite.project-files.container=Container jsite.project-files.container.tooltip=S\u00e9lectionnez un container pour le fichier -jsite.project-files.replacement=Remplacer -jsite.project-files.replacement.tooltip=Activer les remplacements -jsite.project-files.replacement.edition-range=Plage -jsite.project-files.replacement.edition-range.tooltip=Remplacer de $[EDITION+1] \u00e0 $[EDITION+2] jsite.project-files.scan-error=Erreur lors du parcours des fichiers

Soit le r\u00e9pertoire du projet n'existe pas,
ou des fichiers/r\u00e9pertoires sont inaccessibles.
Veuillez revenir en arri\u00e8re et s\u00e9lectionner un autre r\u00e9pertoire. jsite.project-files.insert-now=Ins\u00e9rer @@ -178,7 +165,6 @@ jsite.key-dialog.label.public-key=Cl\u00e9 publique jsite.key-dialog.label.actions=Actions jsite.warning.empty-index=Pas de fichier par d\u00e9faut

Avez vous sp\u00e9cifi\u00e9 un fichier par d\u00e9faut pour le projet?
M\u00eame s'il est possible de ne pas en sp\u00e9cifier, c'est g\u00e9n\u00e9ralement une mauvaise id\u00e9e. -jsite.warning.container-index=Fichier principal du container

Votre fichier par d\u00e9faut \u00e0 \u00e9t\u00e9 plac\u00e9 dans un container!
Ceci peut avoir pour effet de cacher cette page aux utilisateurs. jsite.warning.index-not-html=Le fichier principal n'est pas un fichier HTML!

Votre fichier par d\u00e9faut n'est pas du type MIME "text/html"!
Chargez ce type de fichiers dans un navigateur peut \u00eatre dangereux. jsite.error.no-node-selected=Pas de noeud s\u00e9lectionn\u00e9

S\u00e9lectionnez un noeud dans le menu! diff --git a/src/de/todesbaum/jsite/main/Configuration.java b/src/de/todesbaum/jsite/main/Configuration.java index 236c8bb..6a12a65 100644 --- a/src/de/todesbaum/jsite/main/Configuration.java +++ b/src/de/todesbaum/jsite/main/Configuration.java @@ -351,11 +351,6 @@ public class Configuration { 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) { - fileOption.setReplaceEdition(Boolean.parseBoolean(fileOptionNode.getNode("replace-edition").getValue())); - fileOption.setEditionRange(Integer.parseInt(fileOptionNode.getNode("edition-range").getValue())); - } fileOptions.put(filename, fileOption); } } @@ -401,9 +396,6 @@ public class Configuration { 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())); - fileOptionNode.append("edition-range", String.valueOf(fileOption.getEditionRange())); } } } diff --git a/src/de/todesbaum/util/io/ReplacingOutputStream.java b/src/de/todesbaum/util/io/ReplacingOutputStream.java deleted file mode 100644 index 256714b..0000000 --- a/src/de/todesbaum/util/io/ReplacingOutputStream.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * todesbaum-lib - - * Copyright (C) 2006 David Roden - * - * 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. - */ - -package de.todesbaum.util.io; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - - -/** - * @author David Roden <droden@gmail.com> - * @version $Id$ - */ -public class ReplacingOutputStream extends FilterOutputStream { - - private Map replacements = new HashMap(); - private StringBuffer ringBuffer = new StringBuffer(); - - /** - * @param out - */ - public ReplacingOutputStream(OutputStream out) { - super(out); - } - - public void addReplacement(String token, String value) { - replacements.put(token, value); - } - - /** - * {@inheritDoc} - */ - @Override - public void write(int b) throws IOException { - ringBuffer.append((char) b); - Iterator> entries = replacements.entrySet().iterator(); - boolean found = false; - Entry entry = null; - while (!found && entries.hasNext()) { - entry = entries.next(); - if (entry.getKey().startsWith(ringBuffer.toString())) { - found = true; - } - } - if (!found) { - String buffer = ringBuffer.toString(); - for (int index = 0, size = buffer.length(); index < size; index++) { - super.write(buffer.charAt(index)); - } - ringBuffer.setLength(0); - } else { - if (entry.getKey().equals(ringBuffer.toString())) { - String buffer = entry.getValue(); - for (int index = 0, size = buffer.length(); index < size; index++) { - super.write(buffer.charAt(index)); - } - ringBuffer.setLength(0); - } - } - } - -} -- 2.7.4