Skip to content

Comments 0.1.0: Threaded comments for any record in a PhoenixKit app

Comments 0.1.0 is the first release of the PhoenixKit comments module, taken out of PhoenixKit core into its own package. It gives a Phoenix site threaded comments on any kind of record, with likes and dislikes, optional moderation and an admin page to manage them.

Comments on anything

A comment is attached to a record by a resource type and a uuid, such as "post" and the post’s uuid. There is no foreign key to the record, so any module or app table can have comments without a schema change. A page shows a thread by embedding PhoenixKitComments.Web.CommentsComponent with the resource type and uuid.

Replies nest under their parent, with a maximum depth the admin sets. Each person can like or dislike a comment once, and the counts are kept on the comment. A deleted comment is soft-deleted, so the replies under it keep their place in the thread.

Moderation

Comments have four statuses: pending, published, hidden and deleted. With Require Moderation on, new comments start as pending until someone approves them. The admin page lists all comments with search, filters by status and resource type, and pagination. Each comment can be approved, hidden or deleted on its own or in bulk.

The settings page has Enable Comments, Require Moderation, Max Thread Depth and Max Comment Length. It also holds link patterns per resource type, so a comment in the admin list can link to the page of the record it belongs to.

For developers

PhoenixKit finds the module at startup through its PhoenixKit.Module behaviour, with no extra config. A module whose records get comments can register a resource handler to hear about new and deleted comments through on_comment_created/3 and on_comment_deleted/3, and to supply titles and links for its records.

Upgrading

Add {:phoenix_kit_comments, "~> 0.1.0"} to your dependencies and run mix deps.get. It needs phoenix_kit 1.7. Then turn comments on with Enable Comments in the admin settings and embed the component where you want a thread.

 

 


Comments 0.1.0. Install or update: {:phoenix_kit_comments, "~> 0.1"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.