Simple Gravatar Node.js package, do you want more info? http://en.gravatar.com/
Simple Node.js module for build https (Snowden teach us) URL for Gravatar pictures. Your Gravatar is an image that follows you from site to site appearing beside your name when you do things like comment or post on a blog. Avatars help identify your posts on blogs and web forums, so why not on any site? You need more info ? Check the official Gravatar page.
Main changes by version (if the first number change, old code you have written is not supported, for example between version 1.x.x to version 2.x.x (I apologize for that):
- 1.1.0 First Version (hunting the bugs)
- 1.1.3 minor text changes
- Node.js > 1.14
To test the index.js main file, type on the root folder :
$ npm test
Like all the Node.js module can't be more easy :
npm install gravatar-img// install and save in package.jsonnpm install gravatar-img --save// global installationnpm install -g gravatar-img
Install the package with npm, import with the require statement in the app, and start to use the apis. Yes of course you need to have the gravatar active on the gravatar(wordpress) environment, so take a look at the gravatar link. After that keep in mind
var g = ;// set the size of the gravatar to get the link (min 1, MAX 2048) (optional)g;// set the rating for the gravatar to get link ('g', 'pg', 'r', x) (optional)// g: suitable for display on all websites with any audience type.// pg: may contain rude gestures, swear words, or mild violence.// r: may contain such things as harsh profanity, violence, nudity, drug use.// x: may contain hardcore sexual imagery or extremely disturbing violence.g;// set the default image in case of miss the retrieve by email (URL) (optional)g;
If no options will be set, the default values are used :
- size : 80x80
- rating : 'g'
- default-img : default gravatar miss image
// get the HTTPS link to gravatar img// eg.// eg. ... ca?s=250&r=g&d=g;// get the URL link to gravatar img// eg. www.gravatar.com/avatar/a5ce16777a0e53b502649c1a08fd5bca// eg. www.gravatar.com/avatar/a5c... 8fd5bca?s=250&r=g&d=g;
The module give you the access to other methods, most of them not commonly used :
// reset all the size, rating, default-img to the default value (80px, 'g', gravatar-img)g;// return a object with the properties size, rating, defaultImgg;// return the email cleaned (trim() + inside space removed + toLowerCase + email REGEX check)// a possible email not valid error can be returnedg;// get the MD5 hash cypher of the trim(emailPassed) - email won't be validateg;
Use the callback to check if an error is raised during the path building operations :
The package is tested with mocha and chai. You can find the test file in the /test folder. If you need to use more tests on the library, open an issue on the github repo (THANKS).