diff --git a/product/PortalTransforms/HISTORY.txt b/product/PortalTransforms/HISTORY.txt index 1fafcb4f8b30d9134903064823610dfaad30fba7..d5c97123120b3a3bbe2a347c324635cd5c4e1a9c 100644 --- a/product/PortalTransforms/HISTORY.txt +++ b/product/PortalTransforms/HISTORY.txt @@ -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 ========================= diff --git a/product/PortalTransforms/TransformEngine.py b/product/PortalTransforms/TransformEngine.py index 04dfc2cba0eba35a550834e3f0e8d30915e5e882..fe19c6b7ab8fe310b25d8a4a75aeb7d624eca401 100644 --- a/product/PortalTransforms/TransformEngine.py +++ b/product/PortalTransforms/TransformEngine.py @@ -534,4 +534,17 @@ class TransformTool(UniqueObject, ActionProviderBase, Folder): 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) diff --git a/product/PortalTransforms/tests/input/input.textile b/product/PortalTransforms/tests/input/input.textile new file mode 100644 index 0000000000000000000000000000000000000000..432e60b066c2fc9563ee1291546e557ea02b8682 --- /dev/null +++ b/product/PortalTransforms/tests/input/input.textile @@ -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 + diff --git a/product/PortalTransforms/tests/input/markdown.txt b/product/PortalTransforms/tests/input/markdown.txt new file mode 100644 index 0000000000000000000000000000000000000000..60d087a62e9b4cfb031e03215387f39647e7bd8e --- /dev/null +++ b/product/PortalTransforms/tests/input/markdown.txt @@ -0,0 +1,3 @@ +## Testing Markdown + +`code` and _italic_ and *bold* and even a [link](http://plone.org). diff --git a/product/PortalTransforms/tests/output/markdown.html b/product/PortalTransforms/tests/output/markdown.html new file mode 100644 index 0000000000000000000000000000000000000000..bb6bd3e18921ecddc3eccdfc17daf59b6296ea8d --- /dev/null +++ b/product/PortalTransforms/tests/output/markdown.html @@ -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> + diff --git a/product/PortalTransforms/tests/output/rest2.out b/product/PortalTransforms/tests/output/rest2.out index b53ef7c8cdced50b8beb2b0483d65a4068ae5a6f..8e050c6ce3584bacbc14b529fdd8450cb81a4175 100644 --- a/product/PortalTransforms/tests/output/rest2.out +++ b/product/PortalTransforms/tests/output/rest2.out @@ -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> diff --git a/product/PortalTransforms/tests/output/rest3.out b/product/PortalTransforms/tests/output/rest3.out index 048e69e131da53b42ec87cdd2dd33132ee5d96a1..7989dee796ac70a5356417cb7a849a047ea377d6 100644 --- a/product/PortalTransforms/tests/output/rest3.out +++ b/product/PortalTransforms/tests/output/rest3.out @@ -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> diff --git a/product/PortalTransforms/tests/output/test_lynx.txt b/product/PortalTransforms/tests/output/test_lynx.txt index c6beef54bb9e14015f407a56046753d661887657..4c702b820662b4c43e8124f5cef8bc65a43c20b5 100644 --- a/product/PortalTransforms/tests/output/test_lynx.txt +++ b/product/PortalTransforms/tests/output/test_lynx.txt @@ -1,9 +1,10 @@ + Copying Docutils Author: David Goodger - Contact: goodger@users.sourceforge.net + Contact: [1]goodger@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@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 diff --git a/product/PortalTransforms/tests/output/textile.html b/product/PortalTransforms/tests/output/textile.html new file mode 100644 index 0000000000000000000000000000000000000000..96d41a2e710a7c5917eff520b2f60851db99a078 --- /dev/null +++ b/product/PortalTransforms/tests/output/textile.html @@ -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> diff --git a/product/PortalTransforms/tests/test_transforms.py b/product/PortalTransforms/tests/test_transforms.py index aa38ced1ee4ce4bb6966d3755b103f8ef7acbddd..3baa97bb95e6829d92ca3877342ea85d9cdd2eef 100644 --- a/product/PortalTransforms/tests/test_transforms.py +++ b/product/PortalTransforms/tests/test_transforms.py @@ -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 diff --git a/product/PortalTransforms/transforms/__init__.py b/product/PortalTransforms/transforms/__init__.py index 61e869952025559c4fceb73cdf1b0895b6850feb..dea926e36df06443626c99770c2f601a3fdc88c9 100644 --- a/product/PortalTransforms/transforms/__init__.py +++ b/product/PortalTransforms/transforms/__init__.py @@ -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() diff --git a/product/PortalTransforms/transforms/lynx_dump.py b/product/PortalTransforms/transforms/lynx_dump.py index 85b7055148e366db5aa8f90534ffbf98126369d3..8178c6d1247c3cd1d793fb20cb27565170957aec 100644 --- a/product/PortalTransforms/transforms/lynx_dump.py +++ b/product/PortalTransforms/transforms/lynx_dump.py @@ -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) diff --git a/product/PortalTransforms/transforms/markdown_to_html.py b/product/PortalTransforms/transforms/markdown_to_html.py new file mode 100644 index 0000000000000000000000000000000000000000..2826c4385ba3639a3c29461116c0603bcf592ad1 --- /dev/null +++ b/product/PortalTransforms/transforms/markdown_to_html.py @@ -0,0 +1,42 @@ +""" +Uses the http://www.freewisdom.org/projects/python-markdown/ module to do its handy work + +author: Tom Lazar <tom@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() diff --git a/product/PortalTransforms/transforms/textile_to_html.py b/product/PortalTransforms/transforms/textile_to_html.py new file mode 100644 index 0000000000000000000000000000000000000000..9b52cc2a0a8ba2669a34b2221d06cc56475a9afd --- /dev/null +++ b/product/PortalTransforms/transforms/textile_to_html.py @@ -0,0 +1,42 @@ +""" +Uses Roberto A. F. De Almeida's http://dealmeida.net/ module to do its handy work + +author: Tom Lazar <tom@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()