akismet 3.2.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 49

Akismet for Dart

Runtime Release License Coverage Build

Prevent comment spam using the Akismet service, in Dart.

Features

  • Key verification: checks an Akismet API key and gets a value indicating whether it is valid.
  • Comment check: checks a comment and gets a value indicating whether it is spam.
  • Submit spam: submits a comment that was not marked as spam but should have been.
  • Submit ham: submits a comment that was incorrectly marked as spam but should not have been.

Requirements

The latest Dart SDK and Pub versions. If you plan to play with the sources, you will also need the latest Grinder version.

Installing via Pub

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  akismet: *

2. Install it

Install this package and its dependencies from a command prompt:

$ pub get

3. Import it

Now in your Dart code, you can use:

import 'package:akismet/akismet.dart';

Usage

Key verification

try {
  var client = new Client('your API key', 'http://your.blog.url');
  var isValid = await client.verifyKey();
  print(isValid ? 'Your API key is valid.' : 'Your API key is invalid.');
}

on Exception catch (err) {
  print('An error occurred: $err');
}

Comment check

try {
  var comment = new Comment(
    new Author('127.0.0.1', 'Mozilla/5.0'),
    content: 'A comment.',
    date: new DateTime.now()
  );

  var isSpam = await client.checkComment(comment);
  print(isSpam ? 'The comment is marked as spam.' : 'The comment is marked as ham.');
}

on Exception catch (err) {
  print('An error occurred: $err');
}

Submit spam/ham

try {
  await client.submitSpam(comment);
  print('Spam submitted.');

  await client.submitHam(comment);
  print('Ham submitted.');
}

on Exception catch (err) {
  print('An error occurred: $err');
}

Events

The Client class triggers some events during its life cycle:

  • request : emitted every time a request is made to the remote service.
  • response : emitted every time a response is received from the remote service.

These events are exposed as Stream, you can listen to them using the on<EventName> properties:

client.onRequest.listen((request) => print('Client request: ${request.url}'));
client.onResponse.listen((response) => print('Server response: ${response.statusCode}'));

Unit tests

In order to run the tests, you must set the AKISMET_API_KEY environment variable to the value of your Akismet API key:

$ export AKISMET_API_KEY="<YourAPIKey>"

Then, you can run the test script from the command prompt:

$ pub run test

See also

License

Akismet for Dart is distributed under the MIT License.

Changelog

This file contains highlights of what changes on each version of the Akismet for Dart library.

Version 3.2.0

  • Added support for browser platform.

Version 3.1.0

  • Updated the package dependencies.

Version 3.0.0

  • Breaking change: changed the signature of most class constructors.
  • Breaking change: most class properties are now final.
  • Breaking change: raised the required Dart version.
  • Breaking change: removed the toJson() and toString() methods from the Client class.
  • Breaking change: the version property is now private.
  • Added new values to the CommentType enumeration.
  • Changed licensing for the MIT License.
  • Updated the package dependencies.

Version 2.1.0

  • Updated the package dependencies.

Version 2.0.0

  • Breaking change: changed the signature of all constructors.
  • Breaking change: raised the required Dart version.
  • Breaking change: renamed the Client.serviceUrl constant to defaultEndPoint.
  • Added the Client.endPoint property.
  • Added the version constant.
  • Updated the package dependencies.

Version 1.0.0

  • Breaking change: changed the Blog.language string property for the languages list property.
  • Breaking change: dropped the dart:html client.
  • Breaking change: dropped the embedded server and the command line interface.
  • Breaking change: merged all the libraries (e.g. core, html and io) into the sole akismet one.
  • Breaking change: most of the constructors are now using optional named parameters.
  • Breaking change: removed the DEFAULT_SERVICE constant, serviceUrl property and queryService() method from the Client class.
  • Breaking change: removed the EndPoints and HttpHeaders enumerations.
  • Breaking change: removed the VERSION constant.
  • Breaking change: using lowercase for all constant names.
  • Added the Client.toJson() method.
  • Added the onRequest and onResponse event streams to the Client class.
  • The parameters of the Client constructor are now optional.
  • Added support for the Travis CI continuous integration.
  • Changed the build system for Grinder.
  • Changed the documentation system for Dartdoc.
  • Changed the licensing for the Apache License Version 2.0.
  • Dropped the development dependencies based on Node.js.
  • Removed the info suffix from the Dart version number in the Client.userAgent property.
  • Updated the package dependencies.

Version 0.6.1

  • Fixed bugs in async/await implementation.
  • Fixed bugs in JSON serialization.

Version 0.6.0

  • Added the role property to Author class.
  • Added the isTest property to Client class.
  • Added the date and postModified properties to Comment class.
  • Moved the Future API to async and await.

Version 0.5.1

Version 0.5.0

  • Breaking change: renamed Server.start method to bind.
  • Added Server.bindSecure method to support SSL protocol.
  • Updated the package dependencies.

Version 0.4.0

  • Moved most methods and properties of Client child classes to the base abstract class.
  • Added Blog class to support the latest Akismet APIs.
  • Added Server events: you can listen to onClose, onError, onListening and onRequest streams.
  • Added --silent option to server CLI.
  • Breaking change: renamed Server.stop method to close.
  • Breaking change: renamed HTTPHeaders constants by using X_ as prefix.
  • Breaking change: removed Client.useSecureRequests property.

Version 0.3.2

  • Migrated build system and tools to ShellJS.
  • Migrated documentation comments to YUIDoc.
  • Using DocGen.js to generate the API reference.

Version 0.3.1

  • Added unit tests of the HTML client.
  • The Server class and CLI now use port 3000 as default.

Version 0.3.0

  • Removed obsolete build scripts (build.dart and tool/generate_docs.dart).

Version 0.2.1

  • Added new properties and methods to Server class.
  • Added utility scripts in tool folder.
  • Changed the package layout.
  • Breaking change: renamed Server.secureRequests property to useSecureRequests.

Version 0.2.0

  • Added client implementation based on dart:html.
  • Added server implementation used to proxy requests from HTML clients to Akismet service.
  • Breaking change: Uri in constructors can no longer be specified as String.
  • Breaking change: removed Client.encoding property.

Version 0.1.1

  • Added EndPoints class providing the URLs of the Akismet service end points.

Version 0.1.0

  • Initial release: client implementation based on dart:io.

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  akismet: "^3.2.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:akismet/akismet.dart';
        
Version Uploaded Documentation Archive
3.2.0 Dec 7, 2017 Go to the documentation of akismet 3.2.0 Download akismet 3.2.0 archive
3.1.0 Nov 3, 2017 Go to the documentation of akismet 3.1.0 Download akismet 3.1.0 archive
3.0.0 Oct 4, 2017 Go to the documentation of akismet 3.0.0 Download akismet 3.0.0 archive
2.1.0 Mar 25, 2017 Go to the documentation of akismet 2.1.0 Download akismet 2.1.0 archive
2.0.0 Feb 18, 2017 Go to the documentation of akismet 2.0.0 Download akismet 2.0.0 archive
1.0.0 Jan 1, 2017 Go to the documentation of akismet 1.0.0 Download akismet 1.0.0 archive
0.6.1 Jul 2, 2015 Go to the documentation of akismet 0.6.1 Download akismet 0.6.1 archive
0.6.0 Jun 21, 2015 Go to the documentation of akismet 0.6.0 Download akismet 0.6.0 archive
0.5.1 Jan 28, 2015 Go to the documentation of akismet 0.5.1 Download akismet 0.5.1 archive
0.5.0 Sep 20, 2014 Go to the documentation of akismet 0.5.0 Download akismet 0.5.0 archive

All 18 versions...

Analysis

This feature is new.
We welcome feedback.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Dec 7, 2017
  • Dart: 2.0.0-dev.8.0
  • pana: 0.7.3+1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall score:
Weighted score of the above. [more]
49

Platforms

Detected platforms: Flutter, server

all of the above

Dependencies

Package Constraint Resolved Available
Direct dependencies
http ^0.11.3 0.11.3+16
Transitive dependencies
async 2.0.1
charcode 1.1.1
collection 1.14.3
http_parser 3.1.1
path 1.5.1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
coverage ^0.9.3
coveralls ^2.1.0
grinder ^0.8.0
test ^0.12.29