From 5b5c003f4ab40e800c709126605da2b8196be194 Mon Sep 17 00:00:00 2001 From: axelcl Date: Wed, 15 Dec 2004 22:55:31 +0000 Subject: [PATCH] Add predefined Velocity and CSS templates if wiki builder is assigned to a project --- .../phpeclipse/wiki/builder/AddBuilderAction.java | 6 ++++-- .../phpeclipse/wiki/builder/CreatePageAction.java | 1 + .../sourceforge/phpeclipse/wiki/builder/export.vm | 2 +- .../sourceforge/phpeclipse/wiki/builder/main.vm | 2 +- .../phpeclipse/wiki/editor/WikiEditorPlugin.java | 5 +++-- .../wiki/preferences/Messages.properties | 2 ++ .../phpeclipse/wiki/preferences/Util.java | 14 +++++++++++--- .../wiki/preferences/WikiProjectPreferences.java | 6 ++++-- .../wiki/renderer/WikipediaContentRenderer.java | 8 ++++++-- 9 files changed, 33 insertions(+), 13 deletions(-) diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/AddBuilderAction.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/AddBuilderAction.java index e615b20..7a3b3f2 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/AddBuilderAction.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/AddBuilderAction.java @@ -100,7 +100,7 @@ public class AddBuilderAction implements IObjectActionDelegate { desc.setBuildSpec(newCommands); project.setDescription(desc, null); // add some default wiki project settings - Util.setWikiTextsPath(project); + Util.setWikiBuilderPreferences(project); createVelocityFile(project, "main.vm"); createVelocityFile(project, "export.vm"); @@ -114,6 +114,8 @@ public class AddBuilderAction implements IObjectActionDelegate { private void createVelocityFile(IProject project, String filename) throws CoreException { InputStream is = AddBuilderAction.class.getResourceAsStream(filename); final IFile file = project.getFile(new Path("wpsrc/" + filename)); - file.create(is, true, null); + if (!file.exists()) { + file.create(is, true, null); + } } } \ No newline at end of file diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/CreatePageAction.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/CreatePageAction.java index c1590a8..e2b3408 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/CreatePageAction.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/CreatePageAction.java @@ -89,6 +89,7 @@ public class CreatePageAction implements IObjectActionDelegate { public static void createPage(IFile file) { String templateFileName = Util.getLocalTemplate(file); + String cssUrl = Util.getLocalCssUrl(file); String srcBasePath = Util.getWikiTextsPath(file); String binBasePath = Util.getProjectsWikiOutputPath(file.getProject(), WikiEditorPlugin.HTML_OUTPUT_PATH); createPage(templateFileName, file, binBasePath, srcBasePath); diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/export.vm b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/export.vm index 9ca51b9..5c6cdb3 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/export.vm +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/export.vm @@ -1,6 +1,6 @@ - +
diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/main.vm b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/main.vm index 9ca51b9..f4c5fc8 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/main.vm +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/builder/main.vm @@ -1,6 +1,6 @@ - +
diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java index b49e15f..6e7669b 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java @@ -56,8 +56,9 @@ public class WikiEditorPlugin extends AbstractUIPlugin { public final static String LOCAL_TEMPLATE_FILE_NAME = "__local_template_file_name"; public final static String EXPORT_TEMPLATE_FILE_NAME = "__export_template_file_name"; - - public final static String PREF_STRING_CONFIGURATIONS ="configurations"; + public final static String LOCAL_CSS_URL = "__local_css_url"; + public final static String EXPORT_CSS_URL = "__export_css_url"; + public final static String PREF_STRING_CONFIGURATIONS = "configurations"; public final static String CONFIG_MEMENTO = "" + ""+ "" + diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/Messages.properties b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/Messages.properties index 273da4f..4815ec0 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/Messages.properties +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/Messages.properties @@ -1,7 +1,9 @@ WikiProjectPreferences.StaticWikiFolder=Projects Wikipedia to HTML output path: WikiProjectPreferences.WikiTextsFolder=Projects associated Wikipedia texts path: WikiProjectPreferences.LocalTemplateFile=Preview renderer template file name: +WikiProjectPreferences.LocalCssUrl=CSS Url for browser preview: WikiProjectPreferences.ExportTemplateFile=Export template file name: +WikiProjectPreferences.ExportCssUrl=CSS Url for exported wikis: OverlayPage.Use_Workspace_Settings=Use &workspace settings OverlayPage.Use_Project_Settings=Use pr&oject settings diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/Util.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/Util.java index b8d41f4..241867a 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/Util.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/Util.java @@ -110,7 +110,7 @@ public class Util { return "true".equals(use); } - public static void setWikiTextsPath(IProject project) { + public static void setWikiBuilderPreferences(IProject project) { String value = project.getLocation().toString(); IPreferenceStore store = WikiEditorPlugin.getDefault().getPreferenceStore(); String globalBasePath = store.getString(WikiEditorPlugin.WIKI_TEXTS_BASE_PATH); @@ -118,6 +118,8 @@ public class Util { store.setValue(WikiEditorPlugin.WIKI_TEXTS_BASE_PATH, value + "/wpsrc"); store.setValue(WikiEditorPlugin.LOCAL_TEMPLATE_FILE_NAME, value + "/wpsrc/main.vm"); store.setValue(WikiEditorPlugin.EXPORT_TEMPLATE_FILE_NAME, value + "/wpsrc/export.vm"); + store.setValue(WikiEditorPlugin.LOCAL_CSS_URL, "file://"+value+"/wpsrc/main.css"); + store.setValue(WikiEditorPlugin.EXPORT_CSS_URL, "file://"+value+"/wpsrc/main.css"); } String htmlFolder = store.getString(WikiEditorPlugin.HTML_OUTPUT_PATH); if (htmlFolder == null || htmlFolder.equals("")) { @@ -129,6 +131,8 @@ public class Util { setProperty(project, WikiProjectPreferences.PREF_ID, WikiEditorPlugin.HTML_OUTPUT_PATH, value + "/wpbin"); setProperty(project, WikiProjectPreferences.PREF_ID, WikiEditorPlugin.LOCAL_TEMPLATE_FILE_NAME, value + "/wpsrc/main.vm"); setProperty(project, WikiProjectPreferences.PREF_ID, WikiEditorPlugin.EXPORT_TEMPLATE_FILE_NAME, value + "/wpsrc/export.vm"); + setProperty(project, WikiProjectPreferences.PREF_ID, WikiEditorPlugin.LOCAL_CSS_URL, "file://"+value+"/wpsrc/main.css"); + setProperty(project, WikiProjectPreferences.PREF_ID, WikiEditorPlugin.EXPORT_CSS_URL, "file://"+value+"/wpsrc/main.css"); // IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); // IResource resource = root.findMember(project.getLocation()); NullProgressMonitor _monitor = new NullProgressMonitor(); @@ -159,11 +163,15 @@ public class Util { public static String getLocalTemplate(IResource file) { return Util.getPreferenceValue(file.getProject(), WikiEditorPlugin.LOCAL_TEMPLATE_FILE_NAME); } - + public static String getLocalCssUrl(IResource file) { + return Util.getPreferenceValue(file.getProject(), WikiEditorPlugin.LOCAL_CSS_URL); + } public static String getExportTemplate(IResource file) { return Util.getPreferenceValue(file.getProject(), WikiEditorPlugin.EXPORT_TEMPLATE_FILE_NAME); } - + public static String getExportCssUrl(IResource file) { + return Util.getPreferenceValue(file.getProject(), WikiEditorPlugin.EXPORT_CSS_URL); + } public static String getProjectsWikiTextsPath(IProject project) { return Util.getPreferenceValue(project, WikiEditorPlugin.WIKI_TEXTS_BASE_PATH); } diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/WikiProjectPreferences.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/WikiProjectPreferences.java index fd11f1b..267ba92 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/WikiProjectPreferences.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/preferences/WikiProjectPreferences.java @@ -5,6 +5,7 @@ import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin; import org.eclipse.jface.preference.DirectoryFieldEditor; import org.eclipse.jface.preference.FileFieldEditor; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; @@ -36,10 +37,11 @@ public class WikiProjectPreferences extends FieldEditorOverlayPage implements IW addField(new DirectoryFieldEditor(WikiEditorPlugin.HTML_OUTPUT_PATH, Messages.getString("WikiProjectPreferences.StaticWikiFolder"), composite)); addField(new DirectoryFieldEditor(WikiEditorPlugin.WIKI_TEXTS_BASE_PATH, Messages.getString("WikiProjectPreferences.WikiTextsFolder"), composite)); addField(new FileFieldEditor(WikiEditorPlugin.LOCAL_TEMPLATE_FILE_NAME, Messages.getString("WikiProjectPreferences.LocalTemplateFile"), composite)); + addField(new StringFieldEditor(WikiEditorPlugin.LOCAL_CSS_URL, Messages.getString("WikiProjectPreferences.LocalCssUrl"), composite)); addField(new FileFieldEditor(WikiEditorPlugin.EXPORT_TEMPLATE_FILE_NAME, Messages.getString("WikiProjectPreferences.ExportTemplateFile"), composite)); - + addField(new StringFieldEditor(WikiEditorPlugin.EXPORT_CSS_URL, Messages.getString("WikiProjectPreferences.ExportCssUrl"), composite)); } - + /* * (non-Javadoc) * diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/renderer/WikipediaContentRenderer.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/renderer/WikipediaContentRenderer.java index 9f3d428..439110e 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/renderer/WikipediaContentRenderer.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/renderer/WikipediaContentRenderer.java @@ -9,10 +9,10 @@ import java.util.Properties; import net.sourceforge.phpeclipse.wiki.builder.BuilderRenderEngine; import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin; +import net.sourceforge.phpeclipse.wiki.preferences.Util; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; import org.apache.velocity.app.VelocityEngine; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IPath; @@ -127,7 +127,7 @@ public final class WikipediaContentRenderer extends AbstractContentRenderer { try { if (templateFileName == null||templateFileName.equals("")) { if (completeHTMLPage) { - appendHeader(buf); + appendHeader(buf); } StringWriter writer = new StringWriter(); try { @@ -166,6 +166,10 @@ public final class WikipediaContentRenderer extends AbstractContentRenderer { VelocityContext velocityContext = new VelocityContext(); velocityContext.put("content", String.valueOf(writer) ); + String localCssUrl = Util.getLocalCssUrl(fProject); + velocityContext.put("localcss", localCssUrl ); + String exportCssUrl = Util.getExportCssUrl(fProject); + velocityContext.put("exportcss", exportCssUrl ); Template template = ve.getTemplate(fileName); StringWriter sw = new StringWriter(); -- 1.7.1