Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Node.js module to output text in lots of ways

branch: master

fix email options

latest commit e864631103
Peter Graham authored December 11, 2011
Octocat-spinner-32 lib no default email subject December 11, 2011
Octocat-spinner-32 test use Gmail by default December 11, 2011
Octocat-spinner-32 .gitignore twitter support with ntwitter December 11, 2011
Octocat-spinner-32 LICENSE mit license December 11, 2011
Octocat-spinner-32 README.md fix email options December 11, 2011
Octocat-spinner-32 index.js woops - fix module.exports December 11, 2011
Octocat-spinner-32 package.json bump version December 11, 2011
README.md

putt is a node.js module that lets you easily output text in lots of fun ways. It wraps a bunch of other libraries to make this as simple as possible.

var putt = require("putt");
putt().speak("This is spoken aloud by your computer");
putt().desktop_notify("This appears as a desktop notification");

Supported output formats:

Install

First, install Node.JS and NPM. Then, cd into your project folder and run:

npm install putt

For speak to work on Linux, install Festival and see what voices you have available (e.g. voice_rab_diphone).

For desktop_notify to work, install:

  • Mac: growl, including the growlnotify extra
  • Linux: notify-send with sudo apt-get install libnotify-bin or equivalent

Usage

All output types take an options hash (optional), e.g.:

putt().speak("I am talking", {voice: "Bruce"});

All output types also have two optional callbacks that can be chained:

  • done() is called when the output finishes outputting
  • error(reason) is called when an error is encountered during output

For example:

putt().speak("I am talking").done(function() {
    console.log("Finished talking");
}).error(function(reason) {
    console.log("Something went wrong:", reason);
});

Note that you can chain these method calls in any order:

putt().done(function() {
    console.log("Finished talking");
}).speak("I am talking");

Speech

putt().speak("This is spoken");

Options:

  • voice the voice to use when speaking.

See say.js docs for a full list of voices

Desktop notification

putt().desktop_notify("This is a desktop notification");

Options:

  • title the title of the notification window
  • name the name of the application
  • priority (integer) the priority of the notification (default is 0)
  • sticky (boolean) if notification should fade away or not
  • image custom image to show along with notification

See node-growl docs for more details

POST request

putt().post({param1: "value1", param2: "value2"}, {url: 'http://example.com/whatever'});

Options:

  • url (required) the URL to POST to
  • headers a hash of HTTP headers to be sent

See restler docs for more details

Email

By default, email assumes that the sender is a Gmail user.

putt({
    user: 'sender@gmail.com',
    pass: 'sender_password'
}).email("Body of email", {to: 'recipient@example.com', subject: 'yo'});

Options:

  • to (required) the recipient email address
  • subject the subject for the email

Config:

  • user username (email address) used for authentication
  • pass password used for authentication
  • host the SMTP host
  • port (integer) the SMTP port
  • ssl (boolean) whether or not to use SSL

See nodemailer docs for more details

Tweet

First, create a new Twitter application, and under the "Settings" tab, you will also want to give your app "Read and write" permissions so that we can write a tweet. Then, click the button at the bottom of the "Details" tab to generate an access token and secret.

Next, provide those keys and secrets to putt when you call it:

putt({
    consumer_key: "your consumer key",
    consumer_secret: "your consumer secret",
    access_token: "your access token",
    access_token_secret: "your access token secret"
}).tweet("This text will be tweeted by your account");
Something went wrong with that request. Please try again.