[Yanel-commits] rev 40598 - in
public/yanel/contributions/resources/tinymce: . htdocs
htdocs/js src/build src/java/org/wyona/yanel/impl/resources
src/java/org/wyona/yanel/impl/resources/tinymce yanel-htdocs/doc
simon at wyona.com
simon at wyona.com
Mon Dec 22 01:33:54 CET 2008
Author: simon
Date: 2008-12-22 01:33:54 +0100 (Mon, 22 Dec 2008)
New Revision: 40598
Added:
public/yanel/contributions/resources/tinymce/htdocs/js/tinymceInit.js
public/yanel/contributions/resources/tinymce/htdocs/tinymce-fix.jelly
public/yanel/contributions/resources/tinymce/htdocs/tinymce-status.jelly
public/yanel/contributions/resources/tinymce/htdocs/tinymce.jelly
public/yanel/contributions/resources/tinymce/src/java/org/wyona/yanel/impl/resources/tinymce/
public/yanel/contributions/resources/tinymce/src/java/org/wyona/yanel/impl/resources/tinymce/TinyMCEResource.java
Removed:
public/yanel/contributions/resources/tinymce/src/java/org/wyona/yanel/impl/resources/TinyMCEResource.java
Modified:
public/yanel/contributions/resources/tinymce/build.xml
public/yanel/contributions/resources/tinymce/resource.xml
public/yanel/contributions/resources/tinymce/src/build/dependencies.xml
public/yanel/contributions/resources/tinymce/yanel-htdocs/doc/index.html
Log:
added wellformness checker and jtidy to fix non-wellformed content.
Modified: public/yanel/contributions/resources/tinymce/build.xml
===================================================================
--- public/yanel/contributions/resources/tinymce/build.xml 2008-12-21 10:57:14 UTC (rev 40597)
+++ public/yanel/contributions/resources/tinymce/build.xml 2008-12-22 00:33:54 UTC (rev 40598)
@@ -21,6 +21,9 @@
<property name="resource.classes.dir" value="${resource.build.dir}/classes"/>
<property name="resource.lib.dir" value="${resource.build.dir}/lib"/>
<property name="resource.java.dir" value="${resource.home.dir}/src/java"/>
+ <property name="resource.resource.xml" value="${resource.home.dir}/resource.xml"/>
+ <xmlproperty prefix="resource.resource.xml" file="${resource.resource.xml}"/>
+
</target>
<target name="compile" description="Compile Java classes" depends="init">
@@ -30,10 +33,29 @@
classpathref="classpath"
debug="true"
/>
+
+ <propertyregex property="new.resource.java.classname.fs.path"
+ input="${resource.resource.xml.resource(class)}"
+ regexp="[.]"
+ replace="/"
+ global="true"
+ casesensitive="false" />
+ <echo>${new.resource.java.classname.fs.path}</echo>
+ <propertyregex property="new.resource.java.class.fs.path"
+ input="${new.resource.java.classname.fs.path}"
+ regexp="\/[^/]*$"
+ replace=""
+ global="true"
+ casesensitive="false" />
+ <echo>hilfes${resource.classes.dir}/${new.resource.java.class.fs.path}</echo>
+ <copy todir="${resource.classes.dir}/${new.resource.java.class.fs.path}">
+ <fileset dir="${resource.home.dir}" includes="resource**,htdocs/**,yanel-htdocs/**"/>
+ </copy>
<mkdir dir="${resource.lib.dir}"/>
<jar destfile="${resource.lib.dir}/yanel-resource-${resource.name}-${resource.version}.jar"
- basedir="${resource.classes.dir}"
- />
+ basedir="${resource.classes.dir}">
+ <fileset dir="${resource.classes.dir}"/>
+ </jar>
</target>
<target name="clean" depends="init">
Added: public/yanel/contributions/resources/tinymce/htdocs/js/tinymceInit.js
===================================================================
--- public/yanel/contributions/resources/tinymce/htdocs/js/tinymceInit.js (rev 0)
+++ public/yanel/contributions/resources/tinymce/htdocs/js/tinymceInit.js 2008-12-22 00:33:54 UTC (rev 40598)
@@ -0,0 +1,9 @@
+ tinyMCE.init({
+ mode : "textareas",
+ theme : "advanced",
+ theme_advanced_layout_manager: "RowLayout",
+ theme_advanced_containers: "container1,mceEditor",
+ theme_advanced_container_container1: "bold,italic,underline,separator,bullist,separator,undo,redo,separator,link,unlink,separator,formatselect,image,code",
+ plugins : "fullpage",
+ entity_encoding : "raw"
+ });
\ No newline at end of file
Added: public/yanel/contributions/resources/tinymce/htdocs/tinymce-fix.jelly
===================================================================
--- public/yanel/contributions/resources/tinymce/htdocs/tinymce-fix.jelly (rev 0)
+++ public/yanel/contributions/resources/tinymce/htdocs/tinymce-fix.jelly 2008-12-22 00:33:54 UTC (rev 40598)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<j:jelly xmlns:j="jelly:core">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>YUI Rich Text Editor</title>
+
+ </head>
+ <body>
+ <p class="yanel-usecase-error">${resource.getErrorMessages()}</p>
+ <p>${resource.getInfoMessages()}</p>
+ <j:choose>
+ <j:when test="${resource.getEditPath() != null && !resource.getEditPath().equals('')}">
+ <div class="yui-skin-sam">
+ <form method="post" action="">
+ <input type="hidden" name="edit-path" value="${resource.getEditPath()}"/>
+ <textarea id="${resource.getEditPath()}" name="${resource.getEditPath()}" rows="15" cols="80" style="width: 100%">
+ ${resource.getEscapedContent()}
+ </textarea>
+ <br />
+ <input type="submit" id="submit" name="submit" value="Save" />
+ <input type="submit" id="submit-tidy" name="submit-tidy" value="Tidy" />
+ <input type="submit" id="submit" name="cancel" value="Cancel" />
+ </form>
+ </div>
+ </j:when>
+ <j:otherwise>
+ ${resource.getLookup()}
+ </j:otherwise>
+ </j:choose>
+
+
+ </body>
+ </html>
+</j:jelly>
\ No newline at end of file
Added: public/yanel/contributions/resources/tinymce/htdocs/tinymce-status.jelly
===================================================================
--- public/yanel/contributions/resources/tinymce/htdocs/tinymce-status.jelly (rev 0)
+++ public/yanel/contributions/resources/tinymce/htdocs/tinymce-status.jelly 2008-12-22 00:33:54 UTC (rev 40598)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<j:jelly xmlns:j="jelly:core">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>YUI Rich Text Editor</title>
+ </head>
+ <body>
+ <p class="yanel-usecase-error">${resource.getErrorMessages()}</p>
+ <p>${resource.getInfoMessages()}</p>
+ <form action="">
+ <input type="button" name="finish" value="Finish" onclick="window.location.href='${resource.getParameterAsString('continue-path')}'"/>
+ </form>
+ </body>
+ </html>
+</j:jelly>
\ No newline at end of file
Added: public/yanel/contributions/resources/tinymce/htdocs/tinymce.jelly
===================================================================
--- public/yanel/contributions/resources/tinymce/htdocs/tinymce.jelly (rev 0)
+++ public/yanel/contributions/resources/tinymce/htdocs/tinymce.jelly 2008-12-22 00:33:54 UTC (rev 40598)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<j:jelly xmlns:j="jelly:core">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Edit ${resource.getEditPath()} with tinyMCE</title>
+ <link rel="stylesheet" type="text/css" href="${yanel.back2realm}${yanel.reservedPrefix}/resource-types/http://www.wyona.org/yanel/resource/1.0::tinymce/css/tinymce-resource.css"/>
+ <script language="javascript" type="text/javascript" src="${yanel.back2realm}${yanel.reservedPrefix}/resource-types/http://www.wyona.org/yanel/resource/1.0::tinymce/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
+ <script language="javascript" type="text/javascript" src="${yanel.back2realm}${yanel.reservedPrefix}/resource-types/http://www.wyona.org/yanel/resource/1.0::tinymce/js/tinymceInit.js"></script>
+ </head>
+ <body>
+ <p class="yanel-usecase-error">${resource.getErrorMessages()}</p>
+ <p>${resource.getInfoMessages()}</p>
+ <j:choose>
+ <j:when test="${resource.getEditPath() != null && !resource.getEditPath().equals('')}">
+ <div class="yui-skin-sam">
+ <form method="post" action="">
+ <input type="hidden" name="edit-path" value="${resource.getEditPath()}"/>
+ <textarea id="${resource.getEditPath()}" name="${resource.getEditPath()}" rows="15" cols="80" style="width: 100%">
+ ${resource.getEditorFormContent()}
+ </textarea>
+ <br />
+ <input type="submit" id="submit" name="submit" value="Save" />
+ <input type="submit" id="submit" name="cancel" value="Cancel" />
+ </form>
+ </div>
+ </j:when>
+ <j:otherwise>
+ ${resource.getLookup()}
+ </j:otherwise>
+ </j:choose>
+
+
+ </body>
+ </html>
+</j:jelly>
\ No newline at end of file
Modified: public/yanel/contributions/resources/tinymce/resource.xml
===================================================================
--- public/yanel/contributions/resources/tinymce/resource.xml 2008-12-21 10:57:14 UTC (rev 40597)
+++ public/yanel/contributions/resources/tinymce/resource.xml 2008-12-22 00:33:54 UTC (rev 40598)
@@ -3,7 +3,7 @@
<resource xmlns="http://www.wyona.org/yanel/1.0"
name="tinymce"
namespace="http://www.wyona.org/yanel/resource/1.0"
- class="org.wyona.yanel.impl.resources.TinyMCEResource"
+ class="org.wyona.yanel.impl.resources.tinymce.TinyMCEResource"
>
<description>
tinyMCE to edit xhtml
Modified: public/yanel/contributions/resources/tinymce/src/build/dependencies.xml
===================================================================
--- public/yanel/contributions/resources/tinymce/src/build/dependencies.xml 2008-12-21 10:57:14 UTC (rev 40597)
+++ public/yanel/contributions/resources/tinymce/src/build/dependencies.xml 2008-12-22 00:33:54 UTC (rev 40598)
@@ -22,21 +22,20 @@
<remoteRepository refid="wyona.remote.repository"/>
<dependency groupId="wyona-org-yanel" artifactId="yanel-core" version="${yanel.source.version}"/>
<dependency groupId="wyona-org-yanel" artifactId="yanel-impl" version="${yanel.source.version}"/>
- <dependency groupId="apache-jakarta-commons" artifactId="apache-jakarta-commons-lang" version="2.1"/>
- <dependency groupId="apache-jakarta-commons" artifactId="apache-jakarta-commons-io" version="1.2"/>
<dependency groupId="javax.servlet" artifactId="servlet-api" version="2.3"/>
- <dependency groupId="spring" artifactId="spring" version="2.0"/>
</artifact:dependencies>
<artifact:dependencies pathId="maven2.resource.classpath" filesetId="maven2.resource.fileset">
<remoteRepository refid="wyona.remote.repository"/>
- <dependency groupId="avalon-framework" artifactId="avalon-framework-api" version="4.3"/>
- <dependency groupId="avalon-framework" artifactId="avalon-framework-impl" version="4.3"/>
+ <dependency groupId="apache-jakarta-commons" artifactId="apache-jakarta-commons-lang" version="2.1"/>
+ <dependency groupId="apache-jakarta-commons" artifactId="apache-jakarta-commons-io" version="1.2"/>
+ <dependency groupId="org.hibernate" artifactId="jtidy-r8" version="20060801"/>
+ <dependency groupId="xml-resolver" artifactId="xml-resolver" version="1.1"/>
</artifact:dependencies>
<property name="maven2.cp" refid="maven2.classpath"/>
<property name="maven2.resource.cp" refid="maven2.resource.classpath"/>
- <!--<echo>Maven2 classpath: ${maven2.cp}</echo>-->
+ <echo>Maven2 classpath: ${maven2.cp}</echo>
</target>
</project>
Deleted: public/yanel/contributions/resources/tinymce/src/java/org/wyona/yanel/impl/resources/TinyMCEResource.java
===================================================================
--- public/yanel/contributions/resources/tinymce/src/java/org/wyona/yanel/impl/resources/TinyMCEResource.java 2008-12-21 10:57:14 UTC (rev 40597)
+++ public/yanel/contributions/resources/tinymce/src/java/org/wyona/yanel/impl/resources/TinyMCEResource.java 2008-12-22 00:33:54 UTC (rev 40598)
@@ -1,133 +0,0 @@
-/*
- * Copyright 2006 Wyona
- */
-
-package org.wyona.yanel.impl.resources;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.util.Enumeration;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.log4j.Category;
-import org.apache.log4j.Logger;
-import org.w3c.dom.Document;
-import org.wyona.yanel.core.Resource;
-import org.wyona.yanel.core.api.attributes.CreatableV2;
-import org.wyona.yanel.core.api.attributes.ModifiableV2;
-import org.wyona.yanel.core.api.attributes.ViewableV2;
-import org.wyona.yanel.core.attributes.viewable.View;
-import org.wyona.yanel.core.navigation.Node;
-import org.wyona.yanel.core.navigation.Sitetree;
-import org.wyona.yanel.core.util.PathUtil;
-import org.wyona.yanel.core.util.ResourceAttributeHelper;
-
-import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
-import org.wyona.yanel.impl.resources.BasicXMLResource;
-import org.wyona.yanel.impl.resources.usecase.ExecutableUsecaseResource;
-import org.wyona.yanel.impl.resources.usecase.UsecaseException;
-import org.wyona.yanel.impl.resources.xml.ConfigurableViewDescriptor;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationUtil;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.commons.io.IOUtils;
-
-
-import sun.util.logging.resources.logging;
-
-/**
- *
- */
-public class TinyMCEResource extends ExecutableUsecaseResource {
-
- private static Logger log = Logger.getLogger(TinyMCEResource.class);
-
- private static String PARAMETER_EDIT_PATH = "edit-path";
- private static String PARAMETER_CONTINUE_PATH = "continue-path";
-
-
- public void execute() throws UsecaseException {
- String editPath = getEditPath();
- String content = request.getParameter(editPath);
- log.error(content);
- try {
- Resource resToEdit = getYanel().getResourceManager().getResource(getEnvironment(), getRealm(), editPath);
- if (ResourceAttributeHelper.hasAttributeImplemented(resToEdit, "Modifiable", "2")) {
- OutputStream os = ((ModifiableV2) resToEdit).getOutputStream();
- IOUtils.write(content, os);
- addInfoMessage("Successfully saved.");
- setParameter(PARAMETER_CONTINUE_PATH, PathUtil.backToRealm(getPath()) + editPath.substring(1)); // allow jelly template to show link to new event
- } else {
- addError("The resource you wanted to edit does not implement VieableV2 and is therefor not editable with this editor.");
- log.error("The resource you wanted to edit does not implement VieableV2 and is therefor not editable with this editor.");
- }
- } catch (Exception e) {
- log.error("Exception: " + e);
- throw new UsecaseException(e.getMessage(), e);
- }
- }
-
- public void cancel() throws UsecaseException {
- addInfoMessage("Cancled.");
- setParameter(PARAMETER_CONTINUE_PATH, PathUtil.backToRealm(getPath()) + getEditPath().substring(1)); // allow jelly template to show link to new event
- }
-
- public StringBuffer getEditorForm() throws UsecaseException {
- StringBuffer editableDoc = new StringBuffer();
- StringBuffer sb = new StringBuffer();
- String path;
-
- Enumeration parameters = request.getParameterNames();
- if (!parameters.hasMoreElements()) {
- sb.append("no parameter edit-path found in the request. don't know what to edit");
- return sb;
- } else {
- if (request.getParameter(PARAMETER_EDIT_PATH) == null) {
- sb.append("no parameter edit-path found in the request. don't know what to edit");
- return sb;
- } else {
- path = request.getParameter(PARAMETER_EDIT_PATH);
- }
- }
-
- try {
- Resource resToEdit = getYanel().getResourceManager().getResource(getEnvironment(), getRealm(), path);
- if (ResourceAttributeHelper.hasAttributeImplemented(resToEdit, "Modifiable", "2")) {
-
- InputStream is = ((ModifiableV2) resToEdit).getInputStream();
- BufferedReader ib = new BufferedReader(new InputStreamReader(is));
- String temp = ib.readLine();
- while (temp !=null){
- editableDoc.append (temp);
- editableDoc.append ("\n");
- temp = ib.readLine();
- }
- } else {
- log.error("The resource you wanted to edit does not implement VieableV2 and is therefor not editable with this editor.");
- sb.append("The resource you wanted to edit does not implement VieableV2 and is therefor not editable with this editor.");
- }
- } catch (Exception e) {
- log.error("Exception: " + e);
- throw new UsecaseException(e.getMessage(), e);
- }
-
- sb.append("<form method=\"post\" action=\"\">");
- sb.append("<input type=\"hidden\" name=\"" + PARAMETER_EDIT_PATH + "\" value=\"" + request.getParameter(PARAMETER_EDIT_PATH) + "\"/>");
- sb.append("<textarea id=\"" + request.getParameter(PARAMETER_EDIT_PATH) + "\" name=\"" + request.getParameter(PARAMETER_EDIT_PATH) + "\" rows=\"15\" cols=\"80\" style=\"width: 100%\">");
- sb.append(StringEscapeUtils.escapeXml(editableDoc.toString()));
- sb.append("</textarea>");
- sb.append("<br />");
- sb.append("<input type=\"submit\" name=\"submit\" value=\"Save\" />");
- sb.append("<input type=\"submit\" name=\"cancel\" value=\"Cancel\" />");
- sb.append("</form>");
- return sb;
- }
-
- private String getEditPath() {
- return request.getParameter(PARAMETER_EDIT_PATH);
- }
-}
Copied: public/yanel/contributions/resources/tinymce/src/java/org/wyona/yanel/impl/resources/tinymce/TinyMCEResource.java (from rev 32392, public/yanel/contributions/resources/tinymce/src/java/org/wyona/yanel/impl/resources/TinyMCEResource.java)
===================================================================
--- public/yanel/contributions/resources/tinymce/src/java/org/wyona/yanel/impl/resources/tinymce/TinyMCEResource.java (rev 0)
+++ public/yanel/contributions/resources/tinymce/src/java/org/wyona/yanel/impl/resources/tinymce/TinyMCEResource.java 2008-12-22 00:33:54 UTC (rev 40598)
@@ -0,0 +1,201 @@
+/*
+ * Copyright 2006 Wyona
+ */
+
+package org.wyona.yanel.impl.resources.tinymce;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+import org.w3c.tidy.Tidy;
+import org.wyona.yanel.core.Environment;
+import org.wyona.yanel.core.Resource;
+import org.wyona.yanel.core.ResourceConfiguration;
+import org.wyona.yanel.core.api.attributes.CreatableV2;
+import org.wyona.yanel.core.api.attributes.ModifiableV2;
+import org.wyona.yanel.core.api.attributes.ViewableV2;
+import org.wyona.yanel.core.attributes.viewable.View;
+import org.wyona.yanel.core.map.Realm;
+import org.wyona.yanel.core.navigation.Node;
+import org.wyona.yanel.core.navigation.Sitetree;
+import org.wyona.yanel.core.source.SourceResolver;
+import org.wyona.yanel.core.util.PathUtil;
+import org.wyona.yanel.core.util.ResourceAttributeHelper;
+
+import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
+import org.wyona.yanel.impl.resources.BasicXMLResource;
+import org.wyona.yanel.impl.resources.usecase.ExecutableUsecaseResource;
+import org.wyona.yanel.impl.resources.usecase.UsecaseException;
+import org.wyona.yanel.impl.resources.xml.ConfigurableViewDescriptor;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.xml.resolver.tools.CatalogResolver;
+
+
+import sun.util.logging.resources.logging;
+
+/**
+ *
+ */
+public class TinyMCEResource extends ExecutableUsecaseResource {
+
+ private static Logger log = Logger.getLogger(TinyMCEResource.class);
+
+ private static final String PARAMETER_EDIT_PATH = "edit-path";
+ private static final String PARAMETER_CONTINUE_PATH = "continue-path";
+ private static final String PARAM_SUBMIT_TIDY = "submit-tidy";
+
+ private static final String VIEW_FIX_WELLFORMNESS = "fix-wellformness";
+
+ private String content;
+
+ protected View processUsecase(String viewID) throws UsecaseException {
+ if (getParameter(PARAM_SUBMIT) != null) {
+ if (!isWellformed()) {
+ return generateView(VIEW_FIX_WELLFORMNESS);
+ }
+ execute();
+ return generateView(VIEW_DONE);
+ } else if (getParameter(PARAM_SUBMIT_TIDY) != null) {
+ tidy();
+ return generateView(VIEW_FIX_WELLFORMNESS);
+ } else if (getParameter(PARAM_CANCEL) != null) {
+ cancel();
+ return generateView(VIEW_CANCEL);
+ } else {
+ return generateView(viewID); // this will show the default view if the param is not set
+ }
+ }
+
+ public void execute() throws UsecaseException {
+ final String editPath = getEditPath();
+ final String content = getContent();
+
+ if (log.isDebugEnabled()) log.debug("Content while exectuing: " + content);
+
+ try {
+ Resource resToEdit = getYanel().getResourceManager().getResource(getEnvironment(), getRealm(), editPath);
+ if (ResourceAttributeHelper.hasAttributeImplemented(resToEdit, "Modifiable", "2")) {
+ OutputStream os = ((ModifiableV2) resToEdit).getOutputStream();
+ IOUtils.write(content, os);
+ addInfoMessage("Successfully saved.");
+ setParameter(PARAMETER_CONTINUE_PATH, PathUtil.backToRealm(getPath()) + editPath.substring(1)); // allow jelly template to show link to new event
+ } else {
+ addError("The resource you wanted to edit does not implement VieableV2 and is therefor not editable with this editor.");
+ }
+ } catch (Exception e) {
+ log.error("Exception: " + e);
+ throw new UsecaseException(e.getMessage(), e);
+ }
+ }
+
+ private void tidy() throws UsecaseException {
+ //TODO: tidy should be configured via an external file (e.g. in htdocs)
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ Tidy tidy = new Tidy();
+ tidy.setXHTML(true);
+ tidy.setInputEncoding("utf-8");
+ tidy.setOutputEncoding("utf-8");
+ tidy.parse(IOUtils.toInputStream(getContent()), os);
+ try {
+ content = os.toString("utf-8");
+ } catch (Exception e) {
+ throw new UsecaseException(e.getMessage(), e);
+ }
+ }
+
+ public void cancel() throws UsecaseException {
+ addInfoMessage("Cancled.");
+ setParameter(PARAMETER_CONTINUE_PATH, PathUtil.backToRealm(getPath()) + getEditPath().substring(1)); // allow jelly template to show link to new event
+ }
+
+ public boolean isWellformed() throws UsecaseException {
+ try {
+ //TODO: code borrowed from YanelServlet.java r40436. see line 902. 1. maybe there is a better way to do so. 2. this code could maybe be refactored into a some xml.util lib.
+ javax.xml.parsers.DocumentBuilderFactory dbf= javax.xml.parsers.DocumentBuilderFactory.newInstance();
+ javax.xml.parsers.DocumentBuilder parser = dbf.newDocumentBuilder();
+ // NOTE: DOCTYPE is being resolved/retrieved (e.g. xhtml schema from w3.org) also
+ // if isValidating is set to false.
+ // Hence, for performance and network reasons we use a local catalog ...
+ // Also see http://www.xml.com/pub/a/2004/03/03/catalogs.html
+ // resp. http://xml.apache.org/commons/components/resolver/
+ // TODO: What about a resolver factory?
+ parser.setEntityResolver(new CatalogResolver());
+ String content = getContent();
+ parser.parse(IOUtils.toInputStream(content));
+ return true;
+ } catch (org.xml.sax.SAXException e) {
+ addError(e.getMessage());
+ return false;
+ } catch (Exception e) {
+ addError(e.getMessage());
+ return false;
+ }
+ }
+
+ public String getEditorFormContent() throws UsecaseException {
+ try {
+ if(log.isDebugEnabled()) log.debug(getEditPath());
+ Resource resToEdit = getYanel().getResourceManager().getResource(getEnvironment(), getRealm(), getEditPath());
+ if (ResourceAttributeHelper.hasAttributeImplemented(resToEdit, "Modifiable", "2")) {
+ InputStream is = ((ModifiableV2) resToEdit).getInputStream();
+ return StringEscapeUtils.escapeXml(IOUtils.toString(is));
+ } else {
+ return"The resource you wanted to edit does not implement VieableV2 and is therefor not editable with this editor.";
+ }
+ } catch (Exception e) {
+ log.error("Exception: " + e);
+ throw new UsecaseException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * TODO: no lookup resource-type yet
+ * @return
+ * @throws UsecaseException
+ */
+ public String getLookup() throws UsecaseException {
+ try {
+ SourceResolver resolver = new SourceResolver(this);
+ Source source = resolver.resolve("yanelresource:/usecases/lookup.html", null);
+ InputStream htodoc = ((StreamSource) source).getInputStream();
+ return IOUtils.toString(htodoc);
+ } catch (Exception e) {
+ return "no parameter edit-path found in the request. don't know what to edit";
+ }
+ }
+
+ public String getEditPath() {
+ return request.getParameter(PARAMETER_EDIT_PATH);
+ }
+
+ /**
+ * @return
+ */
+ private String getContent() {
+ if(log.isDebugEnabled()) log.debug("Member field content: " + content);
+ if (content != null) {
+ if(log.isDebugEnabled()) log.debug("content is allready set.");
+ return content;
+ } else {
+ content = getEnvironment().getRequest().getParameter(getEditPath());
+ }
+ return content;
+ }
+
+ public String getEscapedContent() {
+ return StringEscapeUtils.escapeXml(getContent());
+ }
+}
Modified: public/yanel/contributions/resources/tinymce/yanel-htdocs/doc/index.html
===================================================================
--- public/yanel/contributions/resources/tinymce/yanel-htdocs/doc/index.html 2008-12-21 10:57:14 UTC (rev 40597)
+++ public/yanel/contributions/resources/tinymce/yanel-htdocs/doc/index.html 2008-12-22 00:33:54 UTC (rev 40598)
@@ -47,8 +47,10 @@
<table border="1">
<tr><th>View ID</th><th>Mime type</th><th>Type</th></tr>
<tr><td>DEFAULT</td><td>text/html</td><td>jelly</td></tr>
+ <tr><td>fix-wellformness</td><td>text/html</td><td>jelly</td></tr>
<tr><td>done</td><td>text/html</td><td>jelly</td></tr>
<tr><td>cancel</td><td>text/html</td><td>jelly</td></tr>
+ <tr><td>error</td><td>text/html</td><td>jelly</td></tr>
</table>
<h2>Request Parameter</h2>
<table border="1">
@@ -65,24 +67,33 @@
<yanel:custom-config>
<views>
<view id="default" type="jelly">
- <template>tinymce.jelly</template>
+ <template>rthtdocs:/tinymce.jelly</template>
<xslt>/xslt/global.xsl</xslt>
<mime-type>text/html</mime-type>
</view>
+ <view id="fix-wellformness" type="jelly">
+ <template>rthtdocs:/tinymce-fix.jelly</template>
+ <xslt>/xslt/global.xsl</xslt>
+ <mime-type>text/html</mime-type>
+ </view>
<view id="done" type="jelly">
- <template>tinymce-status.jelly</template>
+ <template>rthtdocs:/tinymce-status.jelly</template>
<xslt>/xslt/global.xsl</xslt>
</view>
<view id="cancel" type="jelly">
- <template>tinymce-status.jelly</template>
+ <template>rthtdocs:/tinymce-status.jelly</template>
<xslt>/xslt/global.xsl</xslt>
</view>
+ <view id="error" type="jelly">
+ <template>rthtdocs:/tinymce-status.jelly</template>
+ <xslt>/xslt/global.xsl</xslt>
+ </view>
</views>
</yanel:custom-config>
</yanel:resource-config>
</pre>
- <h3>tinymce.jelly Example</h3>
+<!-- <h3>tinymce.jelly Example</h3>
<pre>
<?xml version="1.0" encoding="utf-8"?>
<j:jelly xmlns:j="jelly:core">
@@ -127,19 +138,19 @@
</body>
</html>
</j:jelly>
-</pre>
+</pre> -->
<h2>Explanations</h2>
<p>
Once you registered the tinymce resource in yanel (add <resource-type src="$TINYMCE_RESOURCE_HOME" compile="true"/> to yanels resource-types.xml)
-<br/>and you added the above mentioned jelly files to your realms data repository (e.g. /tinymce.jelly, /tinymce.jelly) <br/>and added the above mentioned .yanel-rc to
+<!-- <br/>and you added the above mentioned jelly files to your realms data repository (e.g. /tinymce.jelly, /tinymce.jelly) --><br/>and added the above mentioned .yanel-rc to
your realms resource-config (e.g. /usecases/tinymce.yanel-rc) repository
<br/>you can access tinymce via browser e.g. https://localhost:8443/yanel/$YOUR_REALM/usecases/tinymce.html?edit-path=/de/ueber.html.
</p>
<p>you have to provide a request parameter "edith-path" in order to allow the tinymce resource to know which document to edit.</p>
-<p>you can configure the tinymce by editing the javascript tinyMCE.init in the tinymce.jelly. See: <a href="http://wiki.moxiecode.com/index.php/TinyMCE:Index">tinyMCE wiki</a></p>
+<!-- <p>you can configure the tinymce by editing the javascript tinyMCE.init in the tinymce.jelly. See: <a href="http://wiki.moxiecode.com/index.php/TinyMCE:Index">tinyMCE wiki</a></p> -->
<h3>Menu Example</h3>
<p>an example how to add this resource to the menu</p>
<pre>
@@ -171,6 +182,7 @@
<li>don't open all ModifiableV2 it could be something which tinyMCE doesn't like e.g. no html</li>
<li>maybe provide a file lookup when request parameter "edit-path" is not provided</li>
<li>integrate a lookup for inserting images and links</li>
+<li>fix line breaks/formatting</li>
</ul>
</body>
</html>
More information about the Yanel-commits
mailing list