Skip to content

Commit 9648d82

Browse files
Merge pull request #211 from plone/core-addon
Turn this into a core addon
2 parents 2c9aefe + 98aee4a commit 9648d82

37 files changed

+591
-218
lines changed

.meta.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
# See the inline comments on how to expand/tweak this configuration file
44
[meta]
55
template = "default"
6-
commit-id = "a89af8f2"
6+
commit-id = "7a017355"
77

88
[pyproject]
99
dependencies_ignores = "['Products.LinguaPlone.interfaces.ITranslatable', 'collective.akismet', 'collective.z3cform.norobots', 'plone.formwidget.captcha', 'plone.formwidget.recaptcha', 'plone.formwidget.hcaptcha', 'plone.contentrules', 'plone.app.contentrules', 'plone.stringinterp', 'plone.app.collection']"
10+
11+
[tox]
12+
constraints_file = "https://dist.plone.org/release/6.1-dev/constraints.txt"

README.rst

+14-19
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
Introduction
22
============
33

4+
plone.app.discussion is the commenting add-on for Plone.
5+
It is part of the maintained Plone core.
46

5-
plone.app.discussion is the commenting system used since Plone 4.1.
6-
It was initially developed as part of the Google Summer of Code 2009 by Timo Stollenwerk (student) and Martin Aspeli (mentor).
7+
Installation
8+
============
79

10+
If your installation depends on the `Plone <https://pypi.org/project/Plone/>`_ package, you can install it via the Plone control panel.
11+
In case you do only depend on either the `plone.volto`, `plone.classicui` or `Products.CMFPlone` package, you need to add it to your requirements file.
12+
After adding it and installing the requirement, you can install it via the Plone control panel.
813

914

10-
Add-on Products
15+
Spam protection
1116
===============
1217

13-
- `collective.autoresizetextarea
14-
<https://pypi.org/project/collective.autoresizetextarea/>`_
15-
(for auto-resizing the comment textarea while typing)
18+
These days it is essential to protect your site from commenting spam.
19+
The following add-ons can help to protect your site:
1620

1721
- `plone.formwidget.captcha
1822
<https://pypi.org/project/plone.formwidget.captcha/>`_
@@ -22,33 +26,24 @@ Add-on Products
2226
<https://pypi.org/project/plone.formwidget.recaptcha/>`_
2327
(for ReCaptcha spam protection)
2428

25-
- `collective.akismet
26-
<https://pypi.org/project/collective.akismet/>`_
27-
(for Akismet spam protection)
28-
2929
- `collective.z3cform.norobots
30-
<https://pypi.org/project/collective.z3cform.norobots/1.1/>`_
30+
<https://pypi.org/project/collective.z3cform.norobots/>`_
3131
(provides a "human" captcha widget based on a list of questions/answers)
3232

3333
- `plone.formwidget.hcaptcha
3434
<https://pypi.org/project/plone.formwidget.hcaptcha/>`_
3535
(for spam protection by `HCaptcha <https://www.hcaptcha.com/>`_ )
3636

37-
Note: not all of these may be compatible with the current version of ``plone.app.discussion`` and ``Plone`` itself.
38-
3937

4038
Documentation
4139
=============
4240

43-
There is initial `documentation <https://pythonhosted.org/plone.app.discussion/>`_ but it is outdated.
44-
You will still get a feel for how the package is structured though.
45-
41+
For further information, please refer to the `official Plone documentation <https://docs.plone.org/>`_.
4642

4743
Credits
4844
=======
4945

50-
- Timo Stollenwerk
51-
- Martin Aspeli
46+
This package was initially developed as part of the Google Summer of Code 2009 by Timo Stollenwerk (student) and Martin Aspeli (mentor).
5247

5348
Many thanks to:
5449

@@ -59,4 +54,4 @@ Many thanks to:
5954
- Hanno Schlichting (for making p.a.d work with Zope 2.12)
6055
- Alan Hoey (for providing fixes)
6156
- Maik Roeder (for providing and setting up a buildbot)
62-
57+
- Jens Klein (for ripping it out of core and making it a separate core-addon for Plone 6.1)

news/211.breaking

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Move this package in the space of Plone Core add-ons.
2+
It now depends on Products.CMFPlone and is no longer installed by default.
3+
It is still available in the default Plone distribution, but can be omitted in customizations.
4+
[jensens]

news/211.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix redirection after comment edit to main content, preventing NotFound. [@jensens]

news/222.bugfix

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Add missing icon on comments' `view` action
2+
Register contenttype icon for comments.
3+
[gforcada, maurits]

plone/app/discussion/TODO.txt

-100
This file was deleted.

plone/app/discussion/architecture.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ plone.app.discussion.
1414
content.
1515

1616
**Discussion items are subject to workflow and permission**
17-
Moderation, anonymous commenting, and auto approve/reject should be
17+
Moderation, anonymous commenting, and auto-approve/reject should be
1818
handled using workflow states, automatic and manual transitions, and
1919
permissions.
2020

21-
**Discussion items are light weight objects**
22-
Discussion item objects are as light weight as possible. Ideally, a
21+
**Discussion items are lightweight objects**
22+
Discussion item objects are as lightweight as possible. Ideally, a
2323
discussion item should be as lightweight as a catalog brain. This may mean
2424
that we forego convenience base classes and re-implement certain interfaces.
25-
Comments should not provide the full set of dublin core metadata, though
25+
Comments should not provide the full set of Dublin Core metadata, though
2626
custom indexers can be used to provide values for standard catalog indexes.
2727

2828
**Optimise for retrieval speed**
@@ -49,7 +49,7 @@ plone.app.discussion.
4949
**Discussion items are retrieved in reverse creation date order**
5050
Discussion items do not need to support explicit ordering. They should
5151
always be retrieved in reverse creation date order (most recent for).
52-
They can be stored with keys so that this is always true.
52+
They can be stored with keys so this is always true.
5353

5454
**Discussion items do not need readable ids**
5555
Ids can be based on the creation date.

plone/app/discussion/behavior.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from plone.autoform import directives
2+
from plone.autoform.interfaces import IFormFieldProvider
3+
from plone.base import PloneMessageFactory as _
4+
from plone.supermodel import model
5+
from z3c.form.interfaces import IAddForm
6+
from z3c.form.interfaces import IEditForm
7+
from zope import schema
8+
from zope.interface import provider
9+
from zope.schema.vocabulary import SimpleTerm
10+
from zope.schema.vocabulary import SimpleVocabulary
11+
12+
13+
options = SimpleVocabulary(
14+
[
15+
SimpleTerm(value=True, title=_("Yes")),
16+
SimpleTerm(value=False, title=_("No")),
17+
]
18+
)
19+
20+
21+
@provider(IFormFieldProvider)
22+
class IAllowDiscussion(model.Schema):
23+
model.fieldset(
24+
"settings",
25+
label=_("Settings"),
26+
fields=["allow_discussion"],
27+
)
28+
29+
allow_discussion = schema.Choice(
30+
title=_("Allow discussion"),
31+
description=_("Allow discussion for this content object."),
32+
vocabulary=options,
33+
required=False,
34+
default=None,
35+
)
36+
37+
directives.omitted("allow_discussion")
38+
directives.no_omit(IEditForm, "allow_discussion")
39+
directives.no_omit(IAddForm, "allow_discussion")

plone/app/discussion/behavior.zcml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<configure
2+
xmlns="http://namespaces.zope.org/zope"
3+
xmlns:plone="http://namespaces.plone.org/plone"
4+
xmlns:zcml="http://namespaces.zope.org/zcml"
5+
i18n_domain="plone"
6+
>
7+
8+
<include
9+
package="plone.behavior"
10+
file="meta.zcml"
11+
/>
12+
13+
<!--Allow discussion -->
14+
<plone:behavior
15+
name="plone.allowdiscussion"
16+
title="Allow discussion"
17+
description="Allow discussion on this item"
18+
provides=".behavior.IAllowDiscussion"
19+
name_only="yes"
20+
former_dotted_names="plone.app.dexterity.behaviors.discussion.IAllowDiscussion"
21+
/>
22+
23+
</configure>

plone/app/discussion/browser/comment.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def handle_cancel(self, action):
104104
_("comment_edit_cancel_notification", default="Edit comment cancelled"),
105105
type="info",
106106
)
107-
return self._redirect(target=self.context.absolute_url())
107+
main_content = aq_parent(aq_parent(self.context))
108+
return self._redirect(target=main_content.absolute_url())
108109

109110

110111
EditComment = wrap_form(EditCommentForm)

plone/app/discussion/configure.zcml

+17-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<include package="plone.uuid" />
1414
<include package="plone.app.uuid" />
1515

16+
<include file="behavior.zcml" />
1617
<include file="contentrules.zcml" />
1718
<include file="permissions.zcml" />
1819
<include file="notifications.zcml" />
@@ -38,11 +39,26 @@
3839
<!-- Register the installation GenericSetup extension profile -->
3940
<genericsetup:registerProfile
4041
name="default"
41-
title="Plone Discussions"
42+
title="Discussion Support"
4243
description="Commenting infrastructure for Plone"
4344
provides="Products.GenericSetup.interfaces.EXTENSION"
4445
for="plone.base.interfaces.IPloneSiteRoot"
4546
directory="profiles/default"
47+
post_handler=".setuphandlers.post_install"
48+
/>
49+
<genericsetup:registerProfile
50+
name="uninstall"
51+
title="Uninstall Discussion Support"
52+
description="Uninstall Commenting infrastructure for Plone"
53+
provides="Products.GenericSetup.interfaces.EXTENSION"
54+
for="plone.base.interfaces.IPloneSiteRoot"
55+
directory="profiles/uninstall"
56+
post_handler=".setuphandlers.post_uninstall"
57+
/>
58+
<utility
59+
factory=".setuphandlers.HiddenProfiles"
60+
provides="plone.base.interfaces.INonInstallable"
61+
name="plone.app.discussion"
4662
/>
4763
<!-- For upgrade steps see upgrades.zcml. -->
4864

0 commit comments

Comments
 (0)