Zon3.SpamDetector 1.4.0

dotnet add package Zon3.SpamDetector --version 1.4.0
NuGet\Install-Package Zon3.SpamDetector -Version 1.4.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Zon3.SpamDetector" Version="1.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Zon3.SpamDetector --version 1.4.0
#r "nuget: Zon3.SpamDetector, 1.4.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Zon3.SpamDetector as a Cake Addin
#addin nuget:?package=Zon3.SpamDetector&version=1.4.0

// Install Zon3.SpamDetector as a Cake Tool
#tool nuget:?package=Zon3.SpamDetector&version=1.4.0

SpamDetector

Server Status
GitHub Actions .NET Linux
GitHub Actions .NET Win
NuGet .github/workflows/nuget.yml

Description

A Piranha CMS module providing spam detection for page and post comments.

About

Project page: zon3.se/spamdetector<br> Source code: github.com/jensbrak/SpamDetector<br> <br> Piranha CMS provides a feature to allow visitors to comment posts and pages. Out of the box, there is no mechanism to prevent spamming the site with unsolicited comments. This module adds automatic spam detection functionality for submitted comments. It does so by using the free to use Akismet service for spam detection. Once configured, the module will intercept all comments before they are published. If considered spam, the comment is marked as not approved, effectively stopping it from being published. If not considered spam, the comment is marked as approved and is published.

Note

While providing working antispam functionality, the purpose of this module was primarly to explore and learn about Piranha. The documentation and samples are helpful when writing a module with one exception: Manager support. I wanted to see what it took to make a module with full Manager support, including persistance, localization (while keeping the look and feel of the internal Piranha modules). In other words: You might have use for this module even if antispam/comments are not of interest - if you just want to understand how Manager support can be added to a custom Piranha module. There's no claim that this is the right way to do it, however.

Dependencies

  • Zon3.SpamDetector.Localization
  • Microsoft.Extensions.Http version 6
  • Microsoft.Extensions.Localization version 6
  • Piranha version 10
  • Piranha.Manager version 10
  • Also: An Akismet API key

Demo

Please go ahead and try it out by posting a comment with a greeting on my blog. It runs PiranhaCMS with this module active. If your comment is directly visible it's been classified by akismet as non-spam and approved by the SpamDetector module as a valid comment. If not, stop spamming! (Or report a bug to me 😉 )

My PiranhaCMS demo site: zon3.se

Installation

See Instructions below and/or the example Startup.cs (for Piranha prior version 10.0.3) or Program.cs (for Piranha version 10.0.3 and up). The files are from the piranha.razor template with relevant code added.

Code adjustments in your Piranha project

  1. Get and add the SpamDetector module to your Piranha project, either by source or package:
    1. Using source code: Downloading the source code and add a project reference to Zon3.SpamDetector.csproj + Zon3.SpamDetector.localization.csproj OR
    2. Using NuGet package manager: Add the SpamDetector and SpamDetector.Localization packages as a NuGet dependencies
  2. Add a reference to Zon3.SpamDetector in your Piranha project startup file (Program.cs for Piranha version 10.0.3 and up, Startup.cs otherwise)
  3. In startup file add code to register SpamDetector service and middleware and attach it to the proper hook:
    1. Register SpamDetector service
    2. Register SpamDetector middleware
    3. Register a Comment validation hook and call SpamDetector.ReviewAsync(Comment c) to get validation result.
    4. Make sure the hook use the validation to set the comment status (IsApproved)

Settings

Once installed, the module is accessed and configured via Piranha Manager, under Settings in the menu. Values that are mandatory are marked with (Required). Without these properly set, the module won't work.

Module settings

These settings control the module:

  • (Required) Module enabled : use this to turn the module on or off.
  • (Required) Test mode enabled: use this while setting up and testing the module. This will advice Akismet that comments sent are for testing purposes only. Don't forget to turn off once the module is setup and testing is done.
  • (Required) API URL: the personal, site-specific API key to use to make calls to Akismet (see akismet.com/development/api).

Site settings

These settings are sent to Akismet along with the comments to help review the content submitted:

  • (Required) URL: The full URL of the frontpage of the blog/site using the SpamDetector module.
  • Language: The language(s) used by the site (ie the expected languages of the comments submitted). A comma separated list of ISO 639-1 formatted for all languages used by the site.
  • Encoding: The character encoding for the form values of submitted comments ('Your name', 'your email address', 'An (optional) URL to your website' and 'Your awesome comment').
  • User role: The user role of the user who submitted the comment (if any).

Localization

The module itself supports localization, it works similar to how Piranha is localized. Note: the support is not complete: the texts with module info does not yet support localization.

Issues and feedback

Found an issue with the module? Feedback or ideas about it?<br> Visit the GitHub page of the module and submit an issue.<br> <br> Issues: github.com/jensbrak/SpamDetector/issues

Further reading

Selected links relevant to this module:

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.0 438 4/27/2022
1.3.3 267 11/29/2021
1.3.0-beta 2,761 11/25/2021
1.2.0-rc2 183 3/18/2021
1.2.0-rc1 204 3/16/2021
1.1.0-rc1 200 3/8/2021
1.0.0-rc2 165 2/16/2021
1.0.0-rc1 171 2/13/2021