2010-12-16 00:52:56 +01:00
|
|
|
from plone.app.discussion.interfaces import _
|
2015-05-03 08:16:39 +02:00
|
|
|
from zope.schema.vocabulary import SimpleTerm
|
|
|
|
from zope.schema.vocabulary import SimpleVocabulary
|
|
|
|
|
2010-01-24 14:47:39 +01:00
|
|
|
|
2010-06-10 15:11:33 +02:00
|
|
|
HAS_CAPTCHA = False
|
2009-08-11 11:45:34 +02:00
|
|
|
try:
|
2013-04-18 15:51:57 +02:00
|
|
|
import plone.formwidget.captcha # noqa
|
2022-05-01 23:14:09 +02:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
HAS_CAPTCHA = True # pragma: no cover
|
2009-08-11 11:45:34 +02:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2010-06-10 15:11:33 +02:00
|
|
|
HAS_RECAPTCHA = False
|
2009-08-11 11:45:34 +02:00
|
|
|
try:
|
2013-04-18 15:51:57 +02:00
|
|
|
import plone.formwidget.recaptcha # noqa
|
2022-05-01 23:14:09 +02:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
HAS_RECAPTCHA = True # pragma: no cover
|
2009-08-11 11:45:34 +02:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2010-06-10 15:11:33 +02:00
|
|
|
HAS_AKISMET = False
|
|
|
|
try:
|
2013-04-18 15:51:57 +02:00
|
|
|
import collective.akismet # noqa
|
2022-05-01 23:14:09 +02:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
HAS_AKISMET = True # pragma: no cover
|
2010-06-10 15:11:33 +02:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2010-09-10 15:02:56 +02:00
|
|
|
HAS_NOROBOTS = False
|
|
|
|
try:
|
2013-04-18 15:51:57 +02:00
|
|
|
import collective.z3cform.norobots # noqa
|
2022-05-01 23:14:09 +02:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
HAS_NOROBOTS = True # pragma: no cover
|
2010-09-10 15:02:56 +02:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2010-06-10 15:11:33 +02:00
|
|
|
|
2009-08-11 11:45:34 +02:00
|
|
|
def captcha_vocabulary(context):
|
2022-05-01 23:14:09 +02:00
|
|
|
"""Vocabulary with all available captcha implementations."""
|
2009-08-11 11:45:34 +02:00
|
|
|
terms = []
|
2022-05-01 23:14:41 +02:00
|
|
|
terms.append(SimpleTerm(value="disabled", token="disabled", title=_("Disabled")))
|
2009-08-11 11:45:34 +02:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
if HAS_CAPTCHA: # pragma: no cover
|
2022-05-01 23:14:09 +02:00
|
|
|
terms.append(SimpleTerm(value="captcha", token="captcha", title="Captcha"))
|
2010-09-20 12:03:38 +02:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
if HAS_RECAPTCHA: # pragma: no cover
|
2009-08-11 11:45:34 +02:00
|
|
|
terms.append(
|
2022-05-01 23:14:09 +02:00
|
|
|
SimpleTerm(value="recaptcha", token="recaptcha", title="ReCaptcha")
|
|
|
|
)
|
2010-12-16 00:52:56 +01:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
if HAS_AKISMET: # pragma: no cover
|
2022-05-01 23:14:09 +02:00
|
|
|
terms.append(SimpleTerm(value="akismet", token="akismet", title="Akismet"))
|
2010-12-16 00:52:56 +01:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
if HAS_NOROBOTS: # pragma: no cover
|
2022-05-01 23:14:09 +02:00
|
|
|
terms.append(SimpleTerm(value="norobots", token="norobots", title="Norobots"))
|
2010-08-25 16:03:29 +02:00
|
|
|
return SimpleVocabulary(terms)
|
2009-08-11 11:45:34 +02:00
|
|
|
|
2012-01-14 07:47:07 +01:00
|
|
|
|
2010-08-25 16:03:29 +02:00
|
|
|
def text_transform_vocabulary(context):
|
2022-05-01 23:14:09 +02:00
|
|
|
"""Vocabulary with all available portal_transform transformations."""
|
2010-08-25 16:03:29 +02:00
|
|
|
terms = []
|
2022-05-01 23:14:09 +02:00
|
|
|
terms.append(SimpleTerm(value="text/plain", token="text/plain", title="Plain text"))
|
|
|
|
terms.append(SimpleTerm(value="text/html", token="text/html", title="HTML"))
|
2010-08-25 16:03:29 +02:00
|
|
|
terms.append(
|
|
|
|
SimpleTerm(
|
2022-05-01 23:14:09 +02:00
|
|
|
value="text/x-web-markdown", token="text/x-web-markdown", title="Markdown"
|
|
|
|
)
|
|
|
|
)
|
2010-08-25 16:03:29 +02:00
|
|
|
terms.append(
|
|
|
|
SimpleTerm(
|
2022-05-01 23:14:09 +02:00
|
|
|
value="text/x-web-intelligent",
|
|
|
|
token="text/x-web-intelligent",
|
|
|
|
title="Intelligent text",
|
|
|
|
)
|
|
|
|
)
|
2010-08-25 16:03:29 +02:00
|
|
|
return SimpleVocabulary(terms)
|