Hi Asiri,
I don't like this "core" package. It's very artificial IMO. The core
should be the main package.
Also, I'd put the HTMLFilter interface in the filters package.
Re the plural "filters" vs "filter" we need to decide. In the
rendering module we've decided to use the singular form everywhere. In
xwiki-core the majority is also singular. So I'd propose the use
always the singular form. WDYT?
Thanks
-Vincent
On Oct 28, 2008, at 5:50 PM, asiri (SVN) wrote:
Author: asiri
Date: 2008-10-28 17:50:32 +0100 (Tue, 28 Oct 2008)
New Revision: 13873
Added:
sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/core/
sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/core/HTMLFilter.java
sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/
Removed:
sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filter/
sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/HTMLFilter.java
Modified:
sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/OfficeImporterPlugin.java
sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/EmptyLinkFilter.java
sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/ImageTagFilter.java
sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/PinLiFilter.java
sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/TagRemoveFilter.java
sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/UnderlineLinkFilter.java
sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/XWikiSyntaxEscapeFilter.java
sandbox/xwiki-plugin-officeimporter/src/test/java/com/xpn/xwiki/
plugin/officeconverter/CleanHTMLTest.java
Log:
Introduced a new package for core interfaces of the plugin. Renames
the .filter package to .filters
Modified: sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/
xwiki/plugin/officeimporter/OfficeImporterPlugin.java
===================================================================
--- sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/OfficeImporterPlugin.java 2008-10-28 16:46:15
UTC (rev 13872)
+++ sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/OfficeImporterPlugin.java 2008-10-28 16:50:32
UTC (rev 13873)
@@ -57,12 +57,12 @@
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.plugin.XWikiDefaultPlugin;
import com.xpn.xwiki.plugin.XWikiPluginInterface;
-import com.xpn.xwiki.plugin.officeimporter.filter.EmptyLinkFilter;
-import com.xpn.xwiki.plugin.officeimporter.filter.ImageTagFilter;
-import com.xpn.xwiki.plugin.officeimporter.filter.PinLiFilter;
-import com.xpn.xwiki.plugin.officeimporter.filter.TagRemoveFilter;
-import
com.xpn.xwiki.plugin.officeimporter.filter.UnderlineLinkFilter;
-import
com.xpn.xwiki.plugin.officeimporter.filter.XWikiSyntaxEscapeFilter;
+import com.xpn.xwiki.plugin.officeimporter.filters.EmptyLinkFilter;
+import com.xpn.xwiki.plugin.officeimporter.filters.ImageTagFilter;
+import com.xpn.xwiki.plugin.officeimporter.filters.PinLiFilter;
+import com.xpn.xwiki.plugin.officeimporter.filters.TagRemoveFilter;
+import
com.xpn.xwiki.plugin.officeimporter.filters.UnderlineLinkFilter;
+import
com.xpn.xwiki.plugin.officeimporter.filters.XWikiSyntaxEscapeFilter;
import com.xpn.xwiki.plugin.officeimporter.utils.ImporterException;
import com.xpn.xwiki.plugin.officeimporter.utils.DocumentType;
import com.xpn.xwiki.web.Utils;
@@ -500,12 +500,12 @@
}
Document document = htmlCleaner.clean(new
StringReader(inputHTML));
- new TagRemoveFilter().filter(document);
+ new TagRemoveFilter().doFilter(document);
new UnderlineLinkFilter().filter(document);
- new XWikiSyntaxEscapeFilter().filter(document);
- new ImageTagFilter().filter(document);
- new PinLiFilter().filter(document);
- new EmptyLinkFilter().filter(document);
+ new XWikiSyntaxEscapeFilter().doFilter(document);
+ new ImageTagFilter().doFilter(document);
+ new PinLiFilter().doFilter(document);
+ new EmptyLinkFilter().doFilter(document);
XMLUtils.stripHTMLEnvelope(document);
String cleanedHTML = XMLUtils.toString(document);
Copied: sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/
xwiki/plugin/officeimporter/core/HTMLFilter.java (from rev 13871,
sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filter/HTMLFilter.java)
===================================================================
--- sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/core/HTMLFilter.java
(rev 0)
+++ sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/core/HTMLFilter.java 2008-10-28 16:50:32 UTC
(rev 13873)
@@ -0,0 +1,38 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package com.xpn.xwiki.plugin.officeimporter.core;
+
+import org.w3c.dom.Document;
+
+/**
+ * The filter to clean the html. This Filter only can handle the
{@link Document}.
+ *
+ * @version $Id$
+ * @since 1.6M1
+ */
+public interface HTMLFilter
+{
+ /**
+ * Do some clean action to the html code stored in {@link
Document}.
+ *
+ * @param element the {@link Document} with html code
+ */
+ void doFilter(Document document);
+}
Property changes on: sandbox/xwiki-plugin-officeimporter/src/main/
java/com/xpn/xwiki/plugin/officeimporter/core/HTMLFilter.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Copied: sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/
xwiki/plugin/officeimporter/filters (from rev 13871, sandbox/xwiki-
plugin-officeimporter/src/main/java/com/xpn/xwiki/plugin/
officeimporter/filter)
Modified: sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/
xwiki/plugin/officeimporter/filters/EmptyLinkFilter.java
===================================================================
--- sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filter/EmptyLinkFilter.java 2008-10-28
16:45:05 UTC (rev 13871)
+++ sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/EmptyLinkFilter.java 2008-10-28
16:50:32 UTC (rev 13873)
@@ -17,13 +17,15 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-package com.xpn.xwiki.plugin.officeimporter.filter;
+package com.xpn.xwiki.plugin.officeimporter.filters;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import com.xpn.xwiki.plugin.officeimporter.core.HTMLFilter;
+
/**
* Only for convert2html.<br/> As the xwiki 1.0 xhtml render now
don't handle the empty link very well, so need to
* remove the empty link from the html. <br/> If a label of the link
is empty, it's a empty link, {@code <a />} or
@@ -36,7 +38,7 @@
public class EmptyLinkFilter implements HTMLFilter
{
- public void filter(Document document)
+ public void doFilter(Document document)
{
Element root = document.getDocumentElement();
NodeList links = root.getElementsByTagName("a");
Deleted: sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/
xwiki/plugin/officeimporter/filters/HTMLFilter.java
===================================================================
--- sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filter/HTMLFilter.java 2008-10-28 16:45:05 UTC
(rev 13871)
+++ sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/HTMLFilter.java 2008-10-28 16:50:32
UTC (rev 13873)
@@ -1,38 +0,0 @@
-/*
- * See the NOTICE file distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package com.xpn.xwiki.plugin.officeimporter.filter;
-
-import org.w3c.dom.Document;
-
-/**
- * The filter to clean the html. This Filter only can handle the
{@link Document}.
- *
- * @version $Id$
- * @since 1.6M1
- */
-public interface HTMLFilter
-{
- /**
- * Do some clean action to the html code stored in {@link
Document}.
- *
- * @param element the {@link Document} with html code
- */
- void filter(Document document);
-}
Modified: sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/
xwiki/plugin/officeimporter/filters/ImageTagFilter.java
===================================================================
--- sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filter/ImageTagFilter.java 2008-10-28 16:45:05
UTC (rev 13871)
+++ sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/ImageTagFilter.java 2008-10-28
16:50:32 UTC (rev 13873)
@@ -17,7 +17,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-package com.xpn.xwiki.plugin.officeimporter.filter;
+package com.xpn.xwiki.plugin.officeimporter.filters;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -26,6 +26,8 @@
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
+import com.xpn.xwiki.plugin.officeimporter.core.HTMLFilter;
+
/**
* Only for convert2html<br/> This is only for the html rendering in
xwiki syntax 1.0, as it can't find the image's src
* in img tag. Replace the {@code <img>} tag to {image}. Handled
attribute: src, width, height, alt, align.
@@ -36,7 +38,7 @@
public class ImageTagFilter implements HTMLFilter
{
- public void filter(Document document)
+ public void doFilter(Document document)
{
Element root = document.getDocumentElement();
NodeList imgs = root.getElementsByTagName("img");
Modified: sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/
xwiki/plugin/officeimporter/filters/PinLiFilter.java
===================================================================
--- sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filter/PinLiFilter.java 2008-10-28 16:45:05
UTC (rev 13871)
+++ sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/PinLiFilter.java 2008-10-28 16:50:32
UTC (rev 13873)
@@ -17,13 +17,15 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-package com.xpn.xwiki.plugin.officeimporter.filter;
+package com.xpn.xwiki.plugin.officeimporter.filters;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import com.xpn.xwiki.plugin.officeimporter.core.HTMLFilter;
+
/**
* Only for convert2html<br/>As the xwiki 1.0 xhtml render don't
display the first p tag just followed to list tag
* appropriately, need to remove the first {@code <p>} tag in the
{@code <li>} tag.
@@ -34,7 +36,7 @@
public class PinLiFilter implements HTMLFilter
{
- public void filter(Document document)
+ public void doFilter(Document document)
{
Element root = document.getDocumentElement();
NodeList lists = root.getElementsByTagName("li");
Modified: sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/
xwiki/plugin/officeimporter/filters/TagRemoveFilter.java
===================================================================
--- sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filter/TagRemoveFilter.java 2008-10-28
16:45:05 UTC (rev 13871)
+++ sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/TagRemoveFilter.java 2008-10-28
16:50:32 UTC (rev 13873)
@@ -17,13 +17,15 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-package com.xpn.xwiki.plugin.officeimporter.filter;
+package com.xpn.xwiki.plugin.officeimporter.filters;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import com.xpn.xwiki.plugin.officeimporter.core.HTMLFilter;
+
/**
* Remove some tag from html, such as style, script. The tag and all
the contents under the tag will be removed.
*
@@ -34,7 +36,7 @@
{
private final String[] toRemovedTags = {"style", "script"};
- public void filter(Document document)
+ public void doFilter(Document document)
{
Element root = document.getDocumentElement();
for (String tag : toRemovedTags) {
Modified: sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/
xwiki/plugin/officeimporter/filters/UnderlineLinkFilter.java
===================================================================
--- sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filter/UnderlineLinkFilter.java 2008-10-28
16:45:05 UTC (rev 13871)
+++ sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/UnderlineLinkFilter.java 2008-10-28
16:50:32 UTC (rev 13873)
@@ -17,7 +17,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-package com.xpn.xwiki.plugin.officeimporter.filter;
+package com.xpn.xwiki.plugin.officeimporter.filters;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Modified: sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/
xwiki/plugin/officeimporter/filters/XWikiSyntaxEscapeFilter.java
===================================================================
--- sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filter/XWikiSyntaxEscapeFilter.java 2008-10-28
16:45:05 UTC (rev 13871)
+++ sandbox/xwiki-plugin-officeimporter/src/main/java/com/xpn/xwiki/
plugin/officeimporter/filters/XWikiSyntaxEscapeFilter.java
2008-10-28 16:50:32 UTC (rev 13873)
@@ -17,7 +17,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
-package com.xpn.xwiki.plugin.officeimporter.filter;
+package com.xpn.xwiki.plugin.officeimporter.filters;
import java.util.ArrayList;
import java.util.List;
@@ -28,6 +28,8 @@
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
+import com.xpn.xwiki.plugin.officeimporter.core.HTMLFilter;
+
/**
* Only for convert2html<br/> Change the html content conflicting
with xwiki syntax to escape. Such as replace {@code [}
* to {@code \]}
@@ -66,7 +68,7 @@
// escapeChars.add("k");
}
- public void filter(Document document)
+ public void doFilter(Document document)
{
Element root = document.getDocumentElement();
cleanNode(root);
Modified: sandbox/xwiki-plugin-officeimporter/src/test/java/com/xpn/
xwiki/plugin/officeconverter/CleanHTMLTest.java
===================================================================
--- sandbox/xwiki-plugin-officeimporter/src/test/java/com/xpn/xwiki/
plugin/officeconverter/CleanHTMLTest.java 2008-10-28 16:46:15 UTC
(rev 13872)
+++ sandbox/xwiki-plugin-officeimporter/src/test/java/com/xpn/xwiki/
plugin/officeconverter/CleanHTMLTest.java 2008-10-28 16:50:32 UTC
(rev 13873)
@@ -27,13 +27,13 @@
import org.xwiki.xml.XMLUtils;
import org.xwiki.xml.html.HTMLCleaner;
-import com.xpn.xwiki.plugin.officeimporter.filter.EmptyLinkFilter;
-import com.xpn.xwiki.plugin.officeimporter.filter.HTMLFilter;
-import com.xpn.xwiki.plugin.officeimporter.filter.ImageTagFilter;
-import com.xpn.xwiki.plugin.officeimporter.filter.PinLiFilter;
-import com.xpn.xwiki.plugin.officeimporter.filter.TagRemoveFilter;
-import
com.xpn.xwiki.plugin.officeimporter.filter.UnderlineLinkFilter;
-import
com.xpn.xwiki.plugin.officeimporter.filter.XWikiSyntaxEscapeFilter;
+import com.xpn.xwiki.plugin.officeimporter.core.HTMLFilter;
+import com.xpn.xwiki.plugin.officeimporter.filters.EmptyLinkFilter;
+import com.xpn.xwiki.plugin.officeimporter.filters.ImageTagFilter;
+import com.xpn.xwiki.plugin.officeimporter.filters.PinLiFilter;
+import com.xpn.xwiki.plugin.officeimporter.filters.TagRemoveFilter;
+import
com.xpn.xwiki.plugin.officeimporter.filters.UnderlineLinkFilter;
+import
com.xpn.xwiki.plugin.officeimporter.filters.XWikiSyntaxEscapeFilter;
import com.xpn.xwiki.plugin.officeimporter.utils.ImporterException;
import com.xpn.xwiki.test.AbstractXWikiComponentTestCase;
@@ -122,12 +122,12 @@
{
Document document = cleaner.clean(new StringReader(input));
- new TagRemoveFilter().filter(document);
+ new TagRemoveFilter().doFilter(document);
new UnderlineLinkFilter().filter(document);
- new XWikiSyntaxEscapeFilter().filter(document);
- new ImageTagFilter().filter(document);
- new PinLiFilter().filter(document);
- new EmptyLinkFilter().filter(document);
+ new XWikiSyntaxEscapeFilter().doFilter(document);
+ new ImageTagFilter().doFilter(document);
+ new PinLiFilter().doFilter(document);
+ new EmptyLinkFilter().doFilter(document);
XMLUtils.stripHTMLEnvelope(document);
String actual = XMLUtils.toString(document);
_______________________________________________
notifications mailing list
notifications(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications