[Erp5-report] r41724 jm - in /erp5/trunk/products/PortalTransforms: ./ tests/ tests/input/ ...

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Dec 23 17:36:57 CET 2010


Author: jm
Date: Thu Dec 23 17:36:56 2010
New Revision: 41724

URL: http://svn.erp5.org?rev=41724&view=rev
Log:
PortalTransforms: merge upstream 1.6.0-a1

Conflicts:
	transforms/safe_html.py

Added:
    erp5/trunk/products/PortalTransforms/tests/input/input.textile
    erp5/trunk/products/PortalTransforms/tests/input/markdown.txt
    erp5/trunk/products/PortalTransforms/tests/output/markdown.html
    erp5/trunk/products/PortalTransforms/tests/output/textile.html
    erp5/trunk/products/PortalTransforms/transforms/markdown_to_html.py
    erp5/trunk/products/PortalTransforms/transforms/textile_to_html.py
Modified:
    erp5/trunk/products/PortalTransforms/HISTORY.txt
    erp5/trunk/products/PortalTransforms/TransformEngine.py
    erp5/trunk/products/PortalTransforms/tests/output/rest2.out
    erp5/trunk/products/PortalTransforms/tests/output/rest3.out
    erp5/trunk/products/PortalTransforms/tests/output/test_lynx.txt
    erp5/trunk/products/PortalTransforms/tests/test_transforms.py
    erp5/trunk/products/PortalTransforms/transforms/__init__.py
    erp5/trunk/products/PortalTransforms/transforms/lynx_dump.py

Modified: erp5/trunk/products/PortalTransforms/HISTORY.txt
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/HISTORY.txt?rev=41724&r1=41723&r2=41724&view=diff
==============================================================================
--- erp5/trunk/products/PortalTransforms/HISTORY.txt [utf8] (original)
+++ erp5/trunk/products/PortalTransforms/HISTORY.txt [utf8] Thu Dec 23 17:36:56 2010
@@ -3,6 +3,7 @@
 
   * Use ImageMagick's 'convert' program instead of PIL to handle CMYK
     images well.
+  * Merge upstream 1.6.0-a1
 
 1.4.1-nexedi - 2009-03-03
 =========================

Modified: erp5/trunk/products/PortalTransforms/TransformEngine.py
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/TransformEngine.py?rev=41724&r1=41723&r2=41724&view=diff
==============================================================================
--- erp5/trunk/products/PortalTransforms/TransformEngine.py [utf8] (original)
+++ erp5/trunk/products/PortalTransforms/TransformEngine.py [utf8] Thu Dec 23 17:36:56 2010
@@ -534,4 +534,17 @@ class TransformTool(UniqueObject, Action
             log('objectItems: catched MissingBinary exception')
             return []
 
+    # available mimetypes ####################################################
+    def listAvailableTextInputs(self):
+        """ Returns a list of mimetypes that can be used as input for textfields
+            by building a list of the inputs beginning with "text/" of all transforms.
+        """
+        available_types = []
+        candidate_transforms = [object[1] for object in self.objectItems()]
+        for candidate in candidate_transforms:
+            for input in candidate.inputs:
+                if input.startswith("text/") and input not in available_types:
+                    available_types.append(input)
+        return available_types
+
 InitializeClass(TransformTool)

Added: erp5/trunk/products/PortalTransforms/tests/input/input.textile
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/tests/input/input.textile?rev=41724&view=auto
==============================================================================
--- erp5/trunk/products/PortalTransforms/tests/input/input.textile (added)
+++ erp5/trunk/products/PortalTransforms/tests/input/input.textile [utf8] Thu Dec 23 17:36:56 2010
@@ -0,0 +1,16 @@
+h1. Textile test text
+
+_This_ is quite *boring*, but it needs to be "done":http://plone.org, right?
+
+h2. Cheeses
+
+# Gouda
+# Roquefort
+# Emmentaler
+
+h2. Episodes
+
+* Bicycle Repairman
+* Spanish Inquisition
+* Fishslapping Dance
+

Added: erp5/trunk/products/PortalTransforms/tests/input/markdown.txt
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/tests/input/markdown.txt?rev=41724&view=auto
==============================================================================
--- erp5/trunk/products/PortalTransforms/tests/input/markdown.txt (added)
+++ erp5/trunk/products/PortalTransforms/tests/input/markdown.txt [utf8] Thu Dec 23 17:36:56 2010
@@ -0,0 +1,3 @@
+## Testing Markdown 
+
+`code` and _italic_ and *bold* and even a [link](http://plone.org).

Added: erp5/trunk/products/PortalTransforms/tests/output/markdown.html
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/tests/output/markdown.html?rev=41724&view=auto
==============================================================================
--- erp5/trunk/products/PortalTransforms/tests/output/markdown.html (added)
+++ erp5/trunk/products/PortalTransforms/tests/output/markdown.html [utf8] Thu Dec 23 17:36:56 2010
@@ -0,0 +1,6 @@
+
+
+<h2> Testing Markdown </h2>
+<p> <code>code</code> and <em>italic</em> and <em>bold</em> and even a <a href="http://plone.org">link</a>.
+</p>
+

Modified: erp5/trunk/products/PortalTransforms/tests/output/rest2.out
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/tests/output/rest2.out?rev=41724&r1=41723&r2=41724&view=diff
==============================================================================
--- erp5/trunk/products/PortalTransforms/tests/output/rest2.out [utf8] (original)
+++ erp5/trunk/products/PortalTransforms/tests/output/rest2.out [utf8] Thu Dec 23 17:36:56 2010
@@ -1,6 +1,6 @@
 <h2 class="title">Heading 1</h2>
 <p>Some text.</p>
-<div class="section">
-<h3><a id="heading-2" name="heading-2">Heading 2</a></h3>
+<div class="section" id="heading-2">
+<h3><a name="heading-2">Heading 2</a></h3>
 <p>Some text, bla ble bli blo blu. Yes, i know this is <a class="reference" href="http://www.example.com">Stupid</a>.</p>
 </div>

Modified: erp5/trunk/products/PortalTransforms/tests/output/rest3.out
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/tests/output/rest3.out?rev=41724&r1=41723&r2=41724&view=diff
==============================================================================
--- erp5/trunk/products/PortalTransforms/tests/output/rest3.out [utf8] (original)
+++ erp5/trunk/products/PortalTransforms/tests/output/rest3.out [utf8] Thu Dec 23 17:36:56 2010
@@ -1,11 +1,11 @@
 <h2 class="title">Title</h2>
 <h3 class="subtitle">Subtitle</h3>
 <p>This is a test document to make sure subtitle gets the right heading.</p>
-<div class="section">
-<h3><a id="now-the-real-heading" name="now-the-real-heading">Now the real heading</a></h3>
+<div class="section" id="now-the-real-heading">
+<h3><a name="now-the-real-heading">Now the real heading</a></h3>
 <p>The brown fox jumped over the lazy dog.</p>
-<div class="section">
-<h4><a id="with-a-subheading" name="with-a-subheading">With a subheading</a></h4>
+<div class="section" id="with-a-subheading">
+<h4><a name="with-a-subheading">With a subheading</a></h4>
 <p>Some text, bla ble bli blo blu. Yes, i know this is <a class="reference" href="http://www.example.com">Stupid</a>.</p>
 </div>
 </div>

Modified: erp5/trunk/products/PortalTransforms/tests/output/test_lynx.txt
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/tests/output/test_lynx.txt?rev=41724&r1=41723&r2=41724&view=diff
==============================================================================
--- erp5/trunk/products/PortalTransforms/tests/output/test_lynx.txt [utf8] (original)
+++ erp5/trunk/products/PortalTransforms/tests/output/test_lynx.txt [utf8] Thu Dec 23 17:36:56 2010
@@ -1,9 +1,10 @@
+
 Copying Docutils
 
     Author:  David Goodger
-   Contact:  goodger at users.sourceforge.net
+   Contact:  [1]goodger at users.sourceforge.net
      Date:   2002-10-03
-   Web site: http://docutils.sourceforge.net/
+   Web site: [2]http://docutils.sourceforge.net/
 
    Most of the files included in this project are in the public domain,
    and therefore have no license requirement and no restrictions on
@@ -12,22 +13,34 @@ Copying Docutils
        BSD-style license (which can be found in the module's source
        code).
      * docutils/roman.py, copyright by Mark Pilgrim, released under the
-       Python 2.1.1 license.
+       [3]Python 2.1.1 license.
      * test/difflib.py, copyright by the Python Software Foundation,
-       released under the Python 2.2 license. This file is included for
-       compatibility with Python versions less than 2.2; if you have
+       released under the [4]Python 2.2 license. This file is included
+       for compatibility with Python versions less than 2.2; if you have
        Python 2.2 or higher, difflib.py is not needed and may be removed.
        (It's only used to report test failures anyhow; it isn't installed
        anywhere. The included file is a pre-generator version of the
        difflib.py module included in Python 2.2.)
 
    (Disclaimer: I am not a lawyer.) Both the BSD license and the Python
-   license are OSI-approved and GPL-compatible. Although complicated by
-   multiple owners and lots of legalese, the Python license basically
-   lets you copy, use, modify, and redistribute files as long as you keep
-   the copyright attribution intact, note any changes you make, and don't
-   use the owner's name in vain. The BSD license is similar.
+   license are [5]OSI-approved and [6]GPL-compatible. Although
+   complicated by multiple owners and lots of legalese, the Python
+   license basically lets you copy, use, modify, and redistribute files
+   as long as you keep the copyright attribution intact, note any changes
+   you make, and don't use the owner's name in vain. The BSD license is
+   similar.
      _________________________________________________________________
 
-   Generated on: 2003-04-19 15:32 UTC. Generated by Docutils from
-   reStructuredText source.
+   Generated on: 2003-04-19 15:32 UTC. Generated by [7]Docutils from
+   [8]reStructuredText source.
+
+References
+
+   1. mailto:goodger at users.sourceforge.net
+   2. http://docutils.sourceforge.net/
+   3. http://www.python.org/2.1.1/license.html
+   4. http://www.python.org/2.2/license.html
+   5. http://opensource.org/licenses/
+   6. http://www.gnu.org/philosophy/license-list.html
+   7. http://docutils.sourceforge.net/
+   8. http://docutils.sourceforge.net/rst.html

Added: erp5/trunk/products/PortalTransforms/tests/output/textile.html
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/tests/output/textile.html?rev=41724&view=auto
==============================================================================
--- erp5/trunk/products/PortalTransforms/tests/output/textile.html (added)
+++ erp5/trunk/products/PortalTransforms/tests/output/textile.html [utf8] Thu Dec 23 17:36:56 2010
@@ -0,0 +1,24 @@
+<h1>Textile test text</h1>
+
+
+	<p><em>This</em> is quite <strong>boring</strong>, but it needs to be <a href="http://plone.org">done</a>, right?</p>
+
+
+	<h2>Cheeses</h2>
+
+
+	<ol>
+	<li>Gouda</li>
+		<li>Roquefort</li>
+		<li>Emmentaler</li>
+	</ol>
+
+
+	<h2>Episodes</h2>
+
+
+	<ul>
+	<li>Bicycle Repairman</li>
+		<li>Spanish Inquisition</li>
+		<li>Fishslapping Dance</li>
+	</ul>

Modified: erp5/trunk/products/PortalTransforms/tests/test_transforms.py
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/tests/test_transforms.py?rev=41724&r1=41723&r2=41724&view=diff
==============================================================================
--- erp5/trunk/products/PortalTransforms/tests/test_transforms.py [utf8] (original)
+++ erp5/trunk/products/PortalTransforms/tests/test_transforms.py [utf8] Thu Dec 23 17:36:56 2010
@@ -179,7 +179,13 @@ TRANSFORMS_TESTINFO = (
     ('Products.PortalTransforms.transforms.image_to_pcx',
      "logo.png", "logo.pcx", None, 0
      ),
-    )
+    ('Products.PortalTransforms.transforms.markdown_to_html',
+     "markdown.txt", "markdown.html", None, 0
+     ),
+    ('Products.PortalTransforms.transforms.textile_to_html',
+     "input.textile", "textile.html", None, 0
+    ), 
+   )
 
 def initialise(transform, normalize, pattern):
     global TRANSFORMS_TESTINFO

Modified: erp5/trunk/products/PortalTransforms/transforms/__init__.py
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/transforms/__init__.py?rev=41724&r1=41723&r2=41724&view=diff
==============================================================================
--- erp5/trunk/products/PortalTransforms/transforms/__init__.py [utf8] (original)
+++ erp5/trunk/products/PortalTransforms/transforms/__init__.py [utf8] Thu Dec 23 17:36:56 2010
@@ -41,6 +41,8 @@ modules = [
     'w3m_dump',
     'python',         # python source files, no dependancies
     'identity',       # identity transform, no dependancies
+    'markdown_to_html', # markdown, depends on http://surfnet.dl.sourceforge.net/sourceforge/python-markdown/markdown-1-5.py
+    'textile_to_html',# textile, depends on PyTextile http://dom.eav.free.fr/python/textile-mirror-2.0.10.tar.gz 
     ]
 
 g = globals()

Modified: erp5/trunk/products/PortalTransforms/transforms/lynx_dump.py
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/transforms/lynx_dump.py?rev=41724&r1=41723&r2=41724&view=diff
==============================================================================
--- erp5/trunk/products/PortalTransforms/transforms/lynx_dump.py [utf8] (original)
+++ erp5/trunk/products/PortalTransforms/transforms/lynx_dump.py [utf8] Thu Dec 23 17:36:56 2010
@@ -18,13 +18,9 @@ class lynx_dump(popentransform):
 
     binaryName = "lynx"
     # XXX does -stdin work on windows?
-    binaryArgs = "-dump -stdin"
+    binaryArgs = "-dump -stdin -force_html"
     useStdin = True
     
-    def getData(self, couterr):
-        lines = [ line for line in couterr.readlines() ]
-        return ''.join(lines)
-
 class old_lynx_dump(commandtransform):
     implements(itransform)
 

Added: erp5/trunk/products/PortalTransforms/transforms/markdown_to_html.py
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/transforms/markdown_to_html.py?rev=41724&view=auto
==============================================================================
--- erp5/trunk/products/PortalTransforms/transforms/markdown_to_html.py (added)
+++ erp5/trunk/products/PortalTransforms/transforms/markdown_to_html.py [utf8] Thu Dec 23 17:36:56 2010
@@ -0,0 +1,42 @@
+"""
+Uses the http://www.freewisdom.org/projects/python-markdown/ module to do its handy work
+
+author: Tom Lazar <tom at tomster.org> at the archipelago sprint 2006
+
+"""
+
+from Products.PortalTransforms.interfaces import itransform
+from Products.PortalTransforms.libtransforms.utils import bin_search, sansext
+from Products.PortalTransforms.libtransforms.commandtransform import commandtransform
+from Products.CMFDefault.utils import bodyfinder
+import os
+from zope.interface import implements
+
+try:
+    import markdown as markdown_transformer
+except ImportError:
+    HAS_MARKDOWN = False
+else:
+    HAS_MARKDOWN = True
+    
+
+class markdown:
+    implements(itransform)
+
+    __name__ = "markdown_to_html"
+    inputs  = ("text/x-web-markdown",)
+    output = "text/html"
+
+    def name(self):
+        return self.__name__
+
+    def convert(self, orig, data, **kwargs):
+        if HAS_MARKDOWN:
+            html = markdown_transformer.markdown(orig)
+        else:
+            html = orig
+        data.setData(html)
+        return data
+
+def register():
+    return markdown()

Added: erp5/trunk/products/PortalTransforms/transforms/textile_to_html.py
URL: http://svn.erp5.org/erp5/trunk/products/PortalTransforms/transforms/textile_to_html.py?rev=41724&view=auto
==============================================================================
--- erp5/trunk/products/PortalTransforms/transforms/textile_to_html.py (added)
+++ erp5/trunk/products/PortalTransforms/transforms/textile_to_html.py [utf8] Thu Dec 23 17:36:56 2010
@@ -0,0 +1,42 @@
+"""
+Uses Roberto A. F. De Almeida's http://dealmeida.net/ module to do its handy work
+
+author: Tom Lazar <tom at tomster.org> at the archipelago sprint 2006
+
+"""
+
+from Products.PortalTransforms.interfaces import itransform
+from Products.PortalTransforms.libtransforms.utils import bin_search, sansext
+from Products.PortalTransforms.libtransforms.commandtransform import commandtransform
+from Products.CMFDefault.utils import bodyfinder
+import os
+from zope.interface import implements
+
+try:
+    import textile as textile_transformer
+except ImportError:
+    HAS_TEXTILE = False
+else:
+    HAS_TEXTILE = True
+    
+
+class textile:
+    implements(itransform)
+
+    __name__ = "textile_to_html"
+    inputs  = ("text/x-web-textile",)
+    output = "text/html"
+
+    def name(self):
+        return self.__name__
+
+    def convert(self, orig, data, **kwargs):
+        if HAS_TEXTILE:
+            html = textile_transformer.textile(orig, encoding='utf-8', output='utf-8')
+        else:
+            html = orig
+        data.setData(html)
+        return data
+
+def register():
+    return textile()



More information about the Erp5-report mailing list