Skip to content

Commit

Permalink
Merge pull request #211 from plone/core-addon
Browse files Browse the repository at this point in the history
Turn this into a core addon
  • Loading branch information
mauritsvanrees authored Sep 2, 2024
2 parents 2c9aefe + 98aee4a commit 9648d82
Show file tree
Hide file tree
Showing 37 changed files with 591 additions and 218 deletions.
5 changes: 4 additions & 1 deletion .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
# See the inline comments on how to expand/tweak this configuration file
[meta]
template = "default"
commit-id = "a89af8f2"
commit-id = "7a017355"

[pyproject]
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']"

[tox]
constraints_file = "https://dist.plone.org/release/6.1-dev/constraints.txt"
33 changes: 14 additions & 19 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
Introduction
============

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

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

If your installation depends on the `Plone <https://pypi.org/project/Plone/>`_ package, you can install it via the Plone control panel.
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.
After adding it and installing the requirement, you can install it via the Plone control panel.


Add-on Products
Spam protection
===============

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

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

- `collective.akismet
<https://pypi.org/project/collective.akismet/>`_
(for Akismet spam protection)

- `collective.z3cform.norobots
<https://pypi.org/project/collective.z3cform.norobots/1.1/>`_
<https://pypi.org/project/collective.z3cform.norobots/>`_
(provides a "human" captcha widget based on a list of questions/answers)

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

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


Documentation
=============

There is initial `documentation <https://pythonhosted.org/plone.app.discussion/>`_ but it is outdated.
You will still get a feel for how the package is structured though.

For further information, please refer to the `official Plone documentation <https://docs.plone.org/>`_.

Credits
=======

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

Many thanks to:

Expand All @@ -59,4 +54,4 @@ Many thanks to:
- Hanno Schlichting (for making p.a.d work with Zope 2.12)
- Alan Hoey (for providing fixes)
- Maik Roeder (for providing and setting up a buildbot)

- Jens Klein (for ripping it out of core and making it a separate core-addon for Plone 6.1)
4 changes: 4 additions & 0 deletions news/211.breaking
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Move this package in the space of Plone Core add-ons.
It now depends on Products.CMFPlone and is no longer installed by default.
It is still available in the default Plone distribution, but can be omitted in customizations.
[jensens]
1 change: 1 addition & 0 deletions news/211.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix redirection after comment edit to main content, preventing NotFound. [@jensens]
3 changes: 3 additions & 0 deletions news/222.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add missing icon on comments' `view` action
Register contenttype icon for comments.
[gforcada, maurits]
100 changes: 0 additions & 100 deletions plone/app/discussion/TODO.txt

This file was deleted.

10 changes: 5 additions & 5 deletions plone/app/discussion/architecture.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ plone.app.discussion.
content.

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

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

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

**Discussion items do not need readable ids**
Ids can be based on the creation date.
Expand Down
39 changes: 39 additions & 0 deletions plone/app/discussion/behavior.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from plone.autoform import directives
from plone.autoform.interfaces import IFormFieldProvider
from plone.base import PloneMessageFactory as _
from plone.supermodel import model
from z3c.form.interfaces import IAddForm
from z3c.form.interfaces import IEditForm
from zope import schema
from zope.interface import provider
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary


options = SimpleVocabulary(
[
SimpleTerm(value=True, title=_("Yes")),
SimpleTerm(value=False, title=_("No")),
]
)


@provider(IFormFieldProvider)
class IAllowDiscussion(model.Schema):
model.fieldset(
"settings",
label=_("Settings"),
fields=["allow_discussion"],
)

allow_discussion = schema.Choice(
title=_("Allow discussion"),
description=_("Allow discussion for this content object."),
vocabulary=options,
required=False,
default=None,
)

directives.omitted("allow_discussion")
directives.no_omit(IEditForm, "allow_discussion")
directives.no_omit(IAddForm, "allow_discussion")
23 changes: 23 additions & 0 deletions plone/app/discussion/behavior.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:plone="http://namespaces.plone.org/plone"
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="plone"
>

<include
package="plone.behavior"
file="meta.zcml"
/>

<!--Allow discussion -->
<plone:behavior
name="plone.allowdiscussion"
title="Allow discussion"
description="Allow discussion on this item"
provides=".behavior.IAllowDiscussion"
name_only="yes"
former_dotted_names="plone.app.dexterity.behaviors.discussion.IAllowDiscussion"
/>

</configure>
3 changes: 2 additions & 1 deletion plone/app/discussion/browser/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def handle_cancel(self, action):
_("comment_edit_cancel_notification", default="Edit comment cancelled"),
type="info",
)
return self._redirect(target=self.context.absolute_url())
main_content = aq_parent(aq_parent(self.context))
return self._redirect(target=main_content.absolute_url())


EditComment = wrap_form(EditCommentForm)
18 changes: 17 additions & 1 deletion plone/app/discussion/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<include package="plone.uuid" />
<include package="plone.app.uuid" />

<include file="behavior.zcml" />
<include file="contentrules.zcml" />
<include file="permissions.zcml" />
<include file="notifications.zcml" />
Expand All @@ -38,11 +39,26 @@
<!-- Register the installation GenericSetup extension profile -->
<genericsetup:registerProfile
name="default"
title="Plone Discussions"
title="Discussion Support"
description="Commenting infrastructure for Plone"
provides="Products.GenericSetup.interfaces.EXTENSION"
for="plone.base.interfaces.IPloneSiteRoot"
directory="profiles/default"
post_handler=".setuphandlers.post_install"
/>
<genericsetup:registerProfile
name="uninstall"
title="Uninstall Discussion Support"
description="Uninstall Commenting infrastructure for Plone"
provides="Products.GenericSetup.interfaces.EXTENSION"
for="plone.base.interfaces.IPloneSiteRoot"
directory="profiles/uninstall"
post_handler=".setuphandlers.post_uninstall"
/>
<utility
factory=".setuphandlers.HiddenProfiles"
provides="plone.base.interfaces.INonInstallable"
name="plone.app.discussion"
/>
<!-- For upgrade steps see upgrades.zcml. -->

Expand Down
Loading

0 comments on commit 9648d82

Please sign in to comment.