You are here: Home Plone products intelligenttext

intelligenttext (1.0)

1
by Olha Pelishok last modified 2009-01-16
0.0
0.0
0.0
0.0
Released on 2007-12-03 by Kai Diefenbach, Maurits van Rees, Thomas Müller, Hanno Schlichting, Martin Aspeli for Plone 2.5 under GPL - GNU General Public License available for All platforms.
Software development stage: stable
This product contains a mimetype (for the mimetypes_registry) and a transform (for portal_transforms) that is capable converting plain text into HTML where line breaks and indentation is preserved, and web and email addresses are made into clickable links.

Note that there are two major versions of intelligenttext:

Products.intelligenttext

  • Found in the collective, with downloads right here in this project.
  • This should be put in the Products directory of your instance.
  • Use this on Plone 2.5 and earlier.
  • Contains a mime type and two transforms.
  • Not developed anymore, as it is superseded by plone.intelligenttext. Bug fixes can be expected though.

plone.intelligenttext

  • Found in the main plone subversion repository, with releases on the cheese shop.
  • This should be put in the lib/python directory of your instance.
  • Use this on Plone 3.0 and later. In fact, this is in core Plone, so you will automatically get it when you use Plone 3.0.
  • Note: this only contains the base python functions (converting from intelligent text to html and the other way around). The MimeTypesRegistry product registers a mime type for this and the PortalTransforms product registers two transforms using the functions defined in plone.intelligenttext.

Going from Plone 2.5 to 3.0

You have a Plone 2.5 site with intelligenttext in the Products directory? The adviced route is this:

  1. In your 2.5 site uninstall intelligenttext in the Add/Remove Products page of the Plone Control Panel.
  2. Remove intelligenttext from your Products folder.
  3. Install Plone 3.0 (follow steps in the upgrade guide). During the portal_migration the mime type and the transforms for intelligenttext will be added using the plone.intelligenttext that comes with Plone 3.0.

Oh no, I found a bug!

Please report these in the issue tracker of core plone.

So what is intelligenttext?

The mimetype, in mimetype.py, is 'text/x-web-intelligent'. The transform is called 'web_intelligent_plain_text_to_html', and can be found in transforms/web_intelligent_plain_text_to_html.py.

There is also a transform that can convert from HTML to plain text, called 'html_to_web_intelligent_plain_text'. Note that these are not commutative, so if you convert from text/x-web-intelligent to html and back, you may not end up with exactly what you started with!

 

To directly convert a value from plain text to HTML, do:

  portal_transforms = getToolByName(self, 'portal_transforms')
  data = portal_transforms.convertTo('text/html', text, 
  mimetype='text/-x-web-intelligent')
  html = data.getData()
  

To use it on an Archetypes field, do:

  TextField('text',
  widget=TextAreaWidget(
  label="Text",
  description="Enter some text",
  ),
  searchable=True,
  default_content_type="text/x-web-intelligent",
  allowable_content_types=('text/x-web-intelligent',),
  default_output_type="text/html"
  ),

Archetypes will now automatically save your text as text/x-web-intelligent

when you edit text via base_edit, and transform the text to html when you call

the accessor (i.e. getText() in this example).

Note that to ensure the mimetype is set correctly, you must pass it as a keyword

argument if you manually call the mutator:

  instance.setText('Go to http://plone.org', 
  mimetype='text/x-web-intelligent')
  
  

Credits:

 

Martin Aspeli (optilude@gmx.net) -- Development

Kai Diefenbach

Hanno Schlichting

Thomas Müller

Maurits van Rees

Document Actions
Powered by Plone