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");
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
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);
<html>\r
<head>\r
-<link rel="STYLESHEET" type="text/css" href="file://C:\eclipse3\runtime-workbench-workspace\wikibook\wpsrc\main.css" />\r
+<link rel="STYLESHEET" type="text/css" href="$exportcss" />\r
</head>\r
<body class="ns-0">\r
<div id="column-content">\r
<html>\r
<head>\r
-<link rel="STYLESHEET" type="text/css" href="file://C:\eclipse3\runtime-workbench-workspace\wikibook\wpsrc\main.css" />\r
+<link rel="STYLESHEET" type="text/css" href="$localcss" />\r
</head>\r
<body class="ns-0">\r
<div id="column-content">\r
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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<configurations>"+
"<config name=\"Google Search\" type-id=\"HTTP Query\" url=\"http://www.google.com/search?q=$text.selection\"/>" +
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
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);
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("")) {
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();
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);
}
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;
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)
*
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;
try {
if (templateFileName == null||templateFileName.equals("")) {
if (completeHTMLPage) {
- appendHeader(buf);
+ appendHeader(buf);
}
StringWriter writer = new StringWriter();
try {
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();