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)
|
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]
|
[timo]
|
||||||
|
|
||||||
* Rewrote all tal:condition in comments.pt. The authenticated user has
|
* Rewrote all tal:condition in comments.pt. The authenticated user has
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
from Acquisition import aq_inner
|
from Acquisition import aq_inner
|
||||||
|
|
||||||
from AccessControl import getSecurityManager
|
from AccessControl import getSecurityManager
|
||||||
@ -213,7 +214,9 @@ class CommentsViewlet(ViewletBase):
|
|||||||
def cook(self, text):
|
def cook(self, text):
|
||||||
transforms = getToolByName(self, 'portal_transforms')
|
transforms = getToolByName(self, 'portal_transforms')
|
||||||
targetMimetype = 'text/html'
|
targetMimetype = 'text/html'
|
||||||
mimetype = 'text/plain'
|
registry = queryUtility(IRegistry)
|
||||||
|
settings = registry.forInterface(IDiscussionSettings)
|
||||||
|
mimetype = settings.text_transform
|
||||||
return transforms.convertTo(targetMimetype,
|
return transforms.convertTo(targetMimetype,
|
||||||
text,
|
text,
|
||||||
context=self,
|
context=self,
|
||||||
|
@ -64,7 +64,13 @@
|
|||||||
|
|
||||||
<!-- Captcha Vocabulary -->
|
<!-- Captcha Vocabulary -->
|
||||||
<utility component=".vocabularies.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">
|
<configure zcml:condition="installed plone.formwidget.captcha">
|
||||||
<include package="plone.formwidget.captcha" />
|
<include package="plone.formwidget.captcha" />
|
||||||
|
@ -46,6 +46,14 @@ class IDiscussionSettings(Interface):
|
|||||||
required=False,
|
required=False,
|
||||||
default=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(
|
captcha = schema.Choice(
|
||||||
title=_(u"label_captcha", default="Captcha"),
|
title=_(u"label_captcha", default="Captcha"),
|
||||||
description=_(u"help_captcha",
|
description=_(u"help_captcha",
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from zope.component import getMultiAdapter
|
from zope.component import getMultiAdapter
|
||||||
@ -36,8 +37,16 @@ class RegistryTest(PloneTestCase):
|
|||||||
def test_globally_enabled(self):
|
def test_globally_enabled(self):
|
||||||
# Check globally_enabled record
|
# Check globally_enabled record
|
||||||
self.failUnless('globally_enabled' in IDiscussionSettings)
|
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):
|
def test_captcha(self):
|
||||||
# Check globally_enabled record
|
# Check globally_enabled record
|
||||||
self.failUnless('captcha' in IDiscussionSettings)
|
self.failUnless('captcha' in IDiscussionSettings)
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
from zope import interface
|
from zope import interface
|
||||||
import zope.schema.interfaces
|
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 _
|
from plone.app.discussion.interfaces import _
|
||||||
|
|
||||||
@ -31,31 +34,45 @@ def captcha_vocabulary(context):
|
|||||||
"""
|
"""
|
||||||
terms = []
|
terms = []
|
||||||
terms.append(
|
terms.append(
|
||||||
zope.schema.vocabulary.SimpleTerm(
|
SimpleTerm(
|
||||||
value='disabled',
|
value='disabled',
|
||||||
token='disabled',
|
token='disabled',
|
||||||
title=_(u'Disabled')))
|
title=_(u'Disabled')))
|
||||||
|
|
||||||
if HAS_CAPTCHA:
|
if HAS_CAPTCHA:
|
||||||
terms.append(
|
terms.append(
|
||||||
zope.schema.vocabulary.SimpleTerm(
|
SimpleTerm(
|
||||||
value='captcha',
|
value='captcha',
|
||||||
token='captcha',
|
token='captcha',
|
||||||
title='Captcha'))
|
title='Captcha'))
|
||||||
if HAS_RECAPTCHA:
|
if HAS_RECAPTCHA:
|
||||||
terms.append(
|
terms.append(
|
||||||
zope.schema.vocabulary.SimpleTerm(
|
SimpleTerm(
|
||||||
value='recaptcha',
|
value='recaptcha',
|
||||||
token='recaptcha',
|
token='recaptcha',
|
||||||
title='ReCaptcha'))
|
title='ReCaptcha'))
|
||||||
if HAS_AKISMET:
|
if HAS_AKISMET:
|
||||||
terms.append(
|
terms.append(
|
||||||
zope.schema.vocabulary.SimpleTerm(
|
SimpleTerm(
|
||||||
value='akismet',
|
value='akismet',
|
||||||
token='akismet',
|
token='akismet',
|
||||||
title='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