dictapi 0.1.2

  • README.md
  • Installing
  • Versions
  • 0

DICT.dart #

This package provides APIs to communicate with DICT servers.

From server-side applications it's possible to communicate directly with DICT servers via a dart:io socket, but it's also possible to use XHR to receive translations from a client-side application via the included HTTP server.

Because of the HTTP interface provided by this package you are not required to use dart. Any programming language which allows you to create HTTP requests and parse the JSON responses can be used.

Installation #

Simply add the dictapi package as a dependency to the pubspec.yaml file of your application and run the pub get command.

  dictapi: ^0.1.2

If you only want to set up the HTTP server, you can skip the step above and activate the dictapi package instead.

pub global activate dictapi

Usage #

Server-side #

If your code runs in the dart virtual machine, add the following import directive:

import 'package:dictapi/vm.dart';

Then you can connect to the DICT server using the DictConnection.connect method. The first argument is an URI pointing to the DICT server. The method returns a future which will complete with the instance of DictConnection once a connection has been established. If the optional named clientInfo argument is passed, the CLIENT command will be send first.

var uri = Uri.parse('dict://example.com:2628');
var dict = await DictConnection.connect(uri, clientInfo: 'My Dictionary');

Client-side #

If your code runs in the browser, add the following import directive:

import 'package:dictapi/web.dart';

Then create an instance of the DictXhr class and pass the base URI of the HTTP server to the constructor.

var uri = Uri.parse('http://example.com:8080');
var dict = new DictXhr(uri);

Common API #

The DictConnection and DictXhr classes both implement the DictApi interface. The components of your application which work independently of the target platform can import the following library

import 'package:dictapi/dictapi.dart';

to communicate with DICT servers.

HTTP interface #

To run the HTTP server change into your package directory and run the pub run dictapi serve command. If you've activated the dictapi package, run the pub global run dictapi serve instead.

By default the HTTP server listens for incoming requests on port 8080 and connects to the local DICT server on port 2628. You can pass command line arguments to change this behavior. Type pub [global] run dictapi serve --help to see a list of all available options.

When open a browser and and navigate to localhost on the configured port, e.g. http://localhost:8080. The server should respond with a list of available routes.

License #

DICT.dart is licensed under the MIT license agreement. See the LICENSE file for details.

Changelog #

0.1.2 / 2016-21-03 #

  • Uri encode words before XHR query.

0.1.1 / 2016-21-03 #

  • Fix home route.

0.1.0 / 2016-21-03 #

  • Initial version.

Use this package as a library

1. Depend on it

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

  dictapi: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:dictapi/dictapi.dart';
Version Uploaded Documentation Archive
0.1.2 Jul 25, 2016 Go to the documentation of dictapi 0.1.2 Download dictapi 0.1.2 archive
0.1.1 Mar 21, 2016 Go to the documentation of dictapi 0.1.1 Download dictapi 0.1.1 archive
0.1.0 Mar 21, 2016 Go to the documentation of dictapi 0.1.0 Download dictapi 0.1.0 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.13.0 <2.0.0