Plain text and intelligent text options for comment text added to preserve basic text structure and to make links clickable.
svn path=/plone.app.discussion/trunk/; revision=38931
This commit is contained in:
parent
35d7743b7a
commit
a2c89ed5e8
@ -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
|
||||
|
@ -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,
|
||||
|
@ -64,7 +64,13 @@
|
||||
|
||||
<!-- Captcha Vocabulary -->
|
||||
<utility component=".vocabularies.captcha_vocabulary"
|
||||
name="plone.app.discussion.vocabularies.CaptchaVocabulary" />
|
||||
name="plone.app.discussion.vocabularies.CaptchaVocabulary"
|
||||
provides="zope.schema.interfaces.IVocabularyFactory" />
|
||||
|
||||
<!-- Text Transform Vocabulary -->
|
||||
<utility component=".vocabularies.text_transform_vocabulary"
|
||||
name="plone.app.discussion.vocabularies.TextTransformVocabulary"
|
||||
provides="zope.schema.interfaces.IVocabularyFactory" />
|
||||
|
||||
<configure zcml:condition="installed plone.formwidget.captcha">
|
||||
<include package="plone.formwidget.captcha" />
|
||||
|
@ -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",
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user