diff --git a/CHANGES.txt b/CHANGES.txt
index 9c449cb..a70a227 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,7 +4,8 @@ Changelog
1.0b7 (unreleased)
------------------
-* Plain text to HTML transformation added for comment text.
+* Plain text and intelligent text options for comment text added to preserve
+ basic text structure and to make links clickable.
[timo]
* Rewrote all tal:condition in comments.pt. The authenticated user has
diff --git a/plone/app/discussion/browser/comments.py b/plone/app/discussion/browser/comments.py
index 5860354..d643378 100644
--- a/plone/app/discussion/browser/comments.py
+++ b/plone/app/discussion/browser/comments.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from Acquisition import aq_inner
from AccessControl import getSecurityManager
@@ -213,7 +214,9 @@ class CommentsViewlet(ViewletBase):
def cook(self, text):
transforms = getToolByName(self, 'portal_transforms')
targetMimetype = 'text/html'
- mimetype = 'text/plain'
+ registry = queryUtility(IRegistry)
+ settings = registry.forInterface(IDiscussionSettings)
+ mimetype = settings.text_transform
return transforms.convertTo(targetMimetype,
text,
context=self,
diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml
index 22dcdb6..0ea1f1d 100644
--- a/plone/app/discussion/configure.zcml
+++ b/plone/app/discussion/configure.zcml
@@ -64,7 +64,13 @@
+ name="plone.app.discussion.vocabularies.CaptchaVocabulary"
+ provides="zope.schema.interfaces.IVocabularyFactory" />
+
+
+
diff --git a/plone/app/discussion/interfaces.py b/plone/app/discussion/interfaces.py
index 3da1569..c6fe4bb 100644
--- a/plone/app/discussion/interfaces.py
+++ b/plone/app/discussion/interfaces.py
@@ -46,6 +46,14 @@ class IDiscussionSettings(Interface):
required=False,
default=False)
+ text_transform = schema.Choice(
+ title=_(u"label_text_transform", default="Comment text transform"),
+ description=_(u"help_text_transform",
+ default=u""),
+ required=True,
+ default='text/plain',
+ vocabulary='plone.app.discussion.vocabularies.TextTransformVocabulary',)
+
captcha = schema.Choice(
title=_(u"label_captcha", default="Captcha"),
description=_(u"help_captcha",
diff --git a/plone/app/discussion/tests/test_controlpanel.py b/plone/app/discussion/tests/test_controlpanel.py
index f47d3bd..dd4c47b 100644
--- a/plone/app/discussion/tests/test_controlpanel.py
+++ b/plone/app/discussion/tests/test_controlpanel.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
import unittest
from zope.component import getMultiAdapter
@@ -36,8 +37,16 @@ class RegistryTest(PloneTestCase):
def test_globally_enabled(self):
# Check globally_enabled record
self.failUnless('globally_enabled' in IDiscussionSettings)
- self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.globally_enabled'], True)
+ self.assertEquals(
+ self.registry['plone.app.discussion.interfaces.IDiscussionSettings.globally_enabled'],
+ True)
+ def test_text_transform(self):
+ self.failUnless('text_transform' in IDiscussionSettings)
+ self.assertEquals(
+ self.registry['plone.app.discussion.interfaces.IDiscussionSettings.text_transform'],
+ 'text/plain')
+
def test_captcha(self):
# Check globally_enabled record
self.failUnless('captcha' in IDiscussionSettings)
diff --git a/plone/app/discussion/vocabularies.py b/plone/app/discussion/vocabularies.py
index fba4358..895c869 100644
--- a/plone/app/discussion/vocabularies.py
+++ b/plone/app/discussion/vocabularies.py
@@ -1,6 +1,9 @@
from zope import interface
import zope.schema.interfaces
-import zope.schema.vocabulary
+
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
+
+from Products.CMFCore.utils import getToolByName
from plone.app.discussion.interfaces import _
@@ -31,31 +34,45 @@ def captcha_vocabulary(context):
"""
terms = []
terms.append(
- zope.schema.vocabulary.SimpleTerm(
+ SimpleTerm(
value='disabled',
token='disabled',
title=_(u'Disabled')))
if HAS_CAPTCHA:
terms.append(
- zope.schema.vocabulary.SimpleTerm(
+ SimpleTerm(
value='captcha',
token='captcha',
title='Captcha'))
if HAS_RECAPTCHA:
terms.append(
- zope.schema.vocabulary.SimpleTerm(
+ SimpleTerm(
value='recaptcha',
token='recaptcha',
title='ReCaptcha'))
if HAS_AKISMET:
terms.append(
- zope.schema.vocabulary.SimpleTerm(
+ SimpleTerm(
value='akismet',
token='akismet',
title='Akismet'))
- return zope.schema.vocabulary.SimpleVocabulary(terms)
+ return SimpleVocabulary(terms)
-interface.alsoProvides(captcha_vocabulary,
- zope.schema.interfaces.IVocabularyFactory)
\ No newline at end of file
+
+def text_transform_vocabulary(context):
+ """Vocabulary with all available portal_transform transformations.
+ """
+ terms = []
+ terms.append(
+ SimpleTerm(
+ value='text/plain',
+ token='text/plain',
+ title='Plain text'))
+ terms.append(
+ SimpleTerm(
+ value='text/x-web-intelligent',
+ token='text/x-web-intelligent',
+ title='Intelligent text'))
+ return SimpleVocabulary(terms)