Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
92208fd
Refactor
lukasaric Jun 12, 2019
844a442
Upgrade deps :package:
vladimyr Jun 13, 2019
e63c4d9
Refactor to ES module
vladimyr Jun 13, 2019
0c1785e
Add `.editorconfig`
vladimyr Jun 13, 2019
e11395a
Transpile code using babel :wrench:
vladimyr Jun 13, 2019
44d558d
Update readme :blue_book:
vladimyr Jun 13, 2019
7412db1
Refactor cli
lukasaric Jun 13, 2019
ab034a6
Cleanup
vladimyr Jun 13, 2019
6649708
Split library & cli (yarn workspaces) :tada:
vladimyr Jun 13, 2019
fbf0a92
Update docs
vladimyr Jun 13, 2019
77a2a3d
Rename `gravatar-cli` test suite
vladimyr Jun 13, 2019
1892911
Ensure correct yarn version (Travis CI)
vladimyr Jun 13, 2019
ac3f316
Cleanup :lipstick:
vladimyr Jun 13, 2019
17ab142
Rewrite to typescript :rocket:
vladimyr Jun 14, 2019
ea05b06
Prefer short query params
vladimyr Jun 15, 2019
8e85d89
Use `url-join` :tada:
vladimyr Jun 15, 2019
cace15e
Add missing cli deps :bug:
vladimyr Jun 15, 2019
43298cb
Refactor internals :wrench:
vladimyr Jun 16, 2019
e11886b
Fix types :bug:
vladimyr Jun 16, 2019
3e67a59
Lint ts files using ESLint :tada:
vladimyr Jun 28, 2019
c6db7e1
Add `forceDefault => forcedefault` alias
vladimyr Jun 28, 2019
06bc37e
Don't transpile `node_modules` :wrench:
vladimyr Jun 28, 2019
01b260a
Tidy-up cli :lipstick:
vladimyr Jun 30, 2019
95c4cb9
Upgrade dependencies :package:
vladimyr Jun 30, 2019
310c7a0
Update type tests
vladimyr Jun 30, 2019
c524410
Update readme :blue_book:
vladimyr Jun 30, 2019
0f7842a
Use interface definition from d.ts
vladimyr Oct 22, 2019
1c09961
Upgrade dependencies :package:
vladimyr Oct 22, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
charset = utf-8
indent_size = 2
indent_style = space
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
22 changes: 22 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
root: true,
extends: 'semistandard',
rules: {
'space-before-function-paren': ['error', {
anonymous: 'always',
named: 'never'
}]
},
overrides: [{
files: ['**/*.ts'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended'
],
rules: {
'@typescript-eslint/indent': ['error', 2]
}
}]
};
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules
*.log
.tmp_*~
*#
.#*
.vscode
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
language: node_js
node_js:
- 8
- 10
- node
- lts/*

before_install:
- npm install -g yarn

script:
- yarn workspaces run lint
- yarn workspaces run test
2 changes: 1 addition & 1 deletion Changelog.md → CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

# 1.2.0

* According to https://en.gravatar.com/site/check/ https://s.gravatar.com/avatar/ is their preferred url.
* According to https://en.gravatar.com/site/check/ https://s.gravatar.com/avatar/ is their preferred url.

# 1.1.1

Expand Down
143 changes: 81 additions & 62 deletions Readme.md → README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,113 @@
[![Build Status](https://secure.travis-ci.org/emerleite/node-gravatar.svg)](http://travis-ci.org/emerleite/node-gravatar)

Node.js Gravatar library
========================
# Node.js Gravatar library

A library to generate Gravatar URLs in Node.js
Based on gravatar specs - <http://en.gravatar.com/site/implement/hash/> and <http://en.gravatar.com/site/implement/images/>
Based on gravatar specs - <https://en.gravatar.com/site/implement/hash/> and <https://en.gravatar.com/site/implement/images/>

Dependencies
------------
## Dependencies

### Runtime
* Node 0.8.X+

- Node `>=8`

### Development/Tests
* mocha
* should.js

Installation
-----------
- mocha
- should.js

## Installation

```sh
$ npm install gravatar
```

Usage
------
## Usage

```javascript
var gravatar = require('gravatar');
import gravatar from "gravatar";

gravatar.url(email);
gravatar.url(email, options);
gravatar.url(email, options, protocol);

gravatar.profile_url(email);
gravatar.profile_url(email, options);
gravatar.profile_url(email, options, protocol);
gravatar.profileUrl(email);
gravatar.profileUrl(email, options);
gravatar.profileUrl(email, options, protocol);
```

## Where:
* `email`:
## Parameters

- `email`:
The gravatar email
* `options`:
Query string options. Ex: `size` or `s`, `default` or `d`, `rating` or `r`, `forcedefault` or `f`.
- `options`:
Query string options. Ex: `size` or `s`, `default` or `d`, `rating` or `r`, `forceDefault` or `f`.
Additional options not passed as a query string:
`protocol` (e.g. `"http"` or `"https"`) and `format` (only for `profile_url`, e.g. `"xml"`, `"qr"`,
`protocol` (e.g. `"http"` or `"https"`) and `format` (only for `profileUrl`, e.g. `"xml"`, `"qr"`,
by default it is `"json"`)
Should be passed as an object. Ex: `{s: '200', f: 'y', d: '404'}`
* `protocol`
Should be passed as an object. Ex: `{ size: 200, forceDefault: true, default: "404" }`
- `protocol`
Define if will use no protocol, http or https gravatar URL. Default is 'undefined', which generates URLs without protocol. True to force https and false to force http.
It can also be set as `protocol` in `options` - see above.

### Examples

```javascript
var gravatar = require('gravatar');

var url = gravatar.url('emerleite@gmail.com', {s: '200', r: 'pg', d: '404'});
//returns //www.gravatar.com/avatar/93e9084aa289b7f1f5e4ab6716a56c3b?s=200&r=pg&d=404

var unsecureUrl = gravatar.url('emerleite@gmail.com', {s: '100', r: 'x', d: 'retro'}, false);
//returns http://www.gravatar.com/avatar/93e9084aa289b7f1f5e4ab6716a56c3b?s=100&r=x&d=retro

var secureUrl = gravatar.url('emerleite@gmail.com', {s: '100', r: 'x', d: 'retro'}, true);
//returns https://s.gravatar.com/avatar/93e9084aa289b7f1f5e4ab6716a56c3b?s=100&r=x&d=retro

var httpUrl = gravatar.url('emerleite@gmail.com', {protocol: 'http', s: '100'});
//returns http://www.gravatar.com/avatar/93e9084aa289b7f1f5e4ab6716a56c3b?s=100

var httpsUrl = gravatar.url('emerleite@gmail.com', {protocol: 'https', s: '100'});
//returns https://s.gravatar.com/avatar/93e9084aa289b7f1f5e4ab6716a56c3b?s=100

var profile1 = gravatar.profile_url('emerleite@gmail.com', {protocol: 'https'});
//returns https://secure.gravatar.com/93e9084aa289b7f1f5e4ab6716a56c3b.json

var profile2 = gravatar.profile_url('emerleite@gmail.com', {protocol: 'http', format:'qr'});
//returns http://www.gravatar.com/93e9084aa289b7f1f5e4ab6716a56c3b.qr
import gravatar from "gravatar";

const email = "emerleite@gmail.com";

gravatar.url(email, {
size: 200,
rating: "pg",
default: "404"
});
//=> //gravatar.com/avatar/93e9084aa289b7f1f5e4ab6716a56c3b?s=200&r=pg&d=404

gravatar.url(email, {
size: 100,
rating: "x",
default: "retro"
}, false /* [protocol="http"] */);
//=> http://gravatar.com/avatar/93e9084aa289b7f1f5e4ab6716a56c3b?s=100&r=x&d=retro

gravatar.url(email, {
size: 100,
rating: "x",
default: "retro"
}, true /* [protocol="https"] */);
//=> https://gravatar.com/avatar/93e9084aa289b7f1f5e4ab6716a56c3b?s=100&r=x&d=retro

gravatar.url(email, {
protocol: "http",
size: 100
});
//=> http://gravatar.com/avatar/93e9084aa289b7f1f5e4ab6716a56c3b?s=100

gravatar.url(email, {
protocol: "https",
size: 100
});
//=> https://gravatar.com/avatar/93e9084aa289b7f1f5e4ab6716a56c3b?s=100

gravatar.profileUrl(email, {
protocol: "https"
});
//=> https://secure.gravatar.com/93e9084aa289b7f1f5e4ab6716a56c3b.json

gravatar.profileUrl(email, {
protocol: "http",
format: "qr"
});
//=> http://gravatar.com/93e9084aa289b7f1f5e4ab6716a56c3b.qr
```

CLI Usage
---------
## CLI Usage

`gravatar` includes a simple command line interface. To use it, install globally:

```sh
npm i -g gravatar
npm i -g gravatar-cli

gravatar -h
gravatar somebody@example.com
Expand All @@ -92,29 +117,23 @@ gravatar avatar somebody@example.com

gravatar profile -h
gravatar profile somebody@example.com

```

## Running tests

Running tests (3 ways)
----------------------
```sh
$ npm test
$ mocha (installed global)
$ node_modules/mocha/bin/mocha
$ yarn workspaces run test
```

To-Do
-----
* see (<https://github.com/emerleite/node-gravatar/issues>)
## To-Do

- see (<https://github.com/emerleite/node-gravatar/issues>)

Author
------
## Author

* Emerson Macedo (<http://emerleite.com/>)
- Emerson Macedo (<http://emerleite.com/>)

License:
--------
## License

(The MIT License)

Expand Down
4 changes: 4 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
presets: [['@babel/preset-env']],
plugins: ['@babel/plugin-proposal-object-rest-spread']
};
96 changes: 0 additions & 96 deletions cli.js

This file was deleted.

1 change: 0 additions & 1 deletion index.js

This file was deleted.

Loading