Skip to content

Commit

Permalink
feat: add alt text to emoji (#42)
Browse files Browse the repository at this point in the history
* Add alt text (description) on all emoji

Using markdown its possible to attach an alt text (really the title
attribute) on a link, where the value of the link is the the emoji. As
for the actual href, using #xxxxx lets you not mess with the navigation
assuming you have unique keys. In my example, I'm simply using the
emoji's key and github user name (i.e., `<emoji-username>`).

All emojis are links even if they don't have any real url attached.

For example, `[:eyes:](#eyes-kevinjalbert "Reviewed Pull Requests")`

* Add kevinjalbert to all-contributorsrc
  • Loading branch information
kevinjalbert authored and jfmengels committed Apr 15, 2017
1 parent 77a014f commit f99b470
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 29 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@
"contributions": [
"code"
]
},
{
"login": "kevinjalbert",
"name": "Kevin Jalbert",
"avatar_url": "https://avatars1.githubusercontent.com/u/574871?v=3",
"profile": "https://github.com/kevinjalbert",
"contributions": [
"code"
]
}
]
}
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# all-contributors-cli

[![version](https://img.shields.io/npm/v/all-contributors-cli.svg)](http://npm.im/all-contributors-cli)
[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors)

This is a tool to help automate adding contributor acknowledgements according to the [all-contributors](https://github.com/kentcdodds/all-contributors) specification.

Expand Down Expand Up @@ -93,8 +93,9 @@ These are the keys you can specify:
Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<img src="https://avatars.githubusercontent.com/u/3869412?v=3" width="100px;"/><br /><sub>Jeroen Engels</sub>](https://github.com/jfmengels)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) [⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) | [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com/)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) | [<img src="https://avatars.githubusercontent.com/u/14871650?v=3" width="100px;"/><br /><sub>João Guimarães</sub>](https://github.com/jccguimaraes)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jccguimaraes) | [<img src="https://avatars.githubusercontent.com/u/1282980?v=3" width="100px;"/><br /><sub>Ben Briggs</sub>](http://beneb.info)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=ben-eb) | [<img src="https://avatars.githubusercontent.com/u/22768990?v=3" width="100px;"/><br /><sub>Itai Steinherz</sub>](https://github.com/itaisteinherz)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=itaisteinherz) [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=itaisteinherz) | [<img src="https://avatars.githubusercontent.com/u/5701162?v=3" width="100px;"/><br /><sub>Alex Jover</sub>](https://github.com/alexjoverm)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=alexjoverm) [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=alexjoverm) | [<img src="https://avatars3.githubusercontent.com/u/8212?v=3" width="100px;"/><br /><sub>Jerod Santo</sub>](https://jerodsanto.net)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jerodsanto) |
| [<img src="https://avatars.githubusercontent.com/u/3869412?v=3" width="100px;"/><br /><sub>Jeroen Engels</sub>](https://github.com/jfmengels)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels "Code") [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels "Documentation") [⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels "Tests") | [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com/)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds "Documentation") [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds "Code") | [<img src="https://avatars.githubusercontent.com/u/14871650?v=3" width="100px;"/><br /><sub>João Guimarães</sub>](https://github.com/jccguimaraes)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jccguimaraes "Code") | [<img src="https://avatars.githubusercontent.com/u/1282980?v=3" width="100px;"/><br /><sub>Ben Briggs</sub>](http://beneb.info)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=ben-eb "Code") | [<img src="https://avatars.githubusercontent.com/u/22768990?v=3" width="100px;"/><br /><sub>Itai Steinherz</sub>](https://github.com/itaisteinherz)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=itaisteinherz "Documentation") [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=itaisteinherz "Code") | [<img src="https://avatars.githubusercontent.com/u/5701162?v=3" width="100px;"/><br /><sub>Alex Jover</sub>](https://github.com/alexjoverm)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=alexjoverm "Code") [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=alexjoverm "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/8212?v=3" width="100px;"/><br /><sub>Jerod Santo</sub>](https://jerodsanto.net)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jerodsanto "Code") |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [<img src="https://avatars1.githubusercontent.com/u/574871?v=3" width="100px;"/><br /><sub>Kevin Jalbert</sub>](https://github.com/kevinjalbert)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=kevinjalbert "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification.
Expand Down
16 changes: 9 additions & 7 deletions lib/generate/format-contribution-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var _ = require('lodash/fp');
var util = require('../util');

var linkTemplate = _.template('[<%= symbol %>](<%= url %>)');
var linkTemplate = _.template('[<%= symbol %>](<%= url %> "<%= description %>")');

function getType(options, contribution) {
var types = util.contributionTypes(options);
Expand All @@ -19,15 +19,17 @@ module.exports = function formatContribution(options, contributor, contribution)

var templateData = {
symbol: type.symbol,
description: type.description,
contributor: contributor,
options: options
};

var url = `#${contribution}-${contributor.login}`;
if (contribution.url) {
return linkTemplate(_.assign({url: contribution.url}, templateData));
}
if (type.link) {
var url = _.template(type.link)(templateData);
return linkTemplate(_.assign({url: url}, templateData));
url = contribution.url;
} else if (type.link) {
url = _.template(type.link)(templateData);
}
return type.symbol;

return linkTemplate(_.assign({url: url}, templateData));
};
32 changes: 16 additions & 16 deletions lib/generate/format-contribution-type.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ test('should return corresponding symbol', t => {
const contributor = contributors.kentcdodds;
const {options} = fixtures();

t.is(formatContributionType(options, contributor, 'tool'), '🔧');
t.is(formatContributionType(options, contributor, 'question'), '💬');
t.is(formatContributionType(options, contributor, 'tool'), '[🔧](#tool-kentcdodds "Tools")');
t.is(formatContributionType(options, contributor, 'question'), '[💬](#question-kentcdodds "Answering Questions")');
});

test('should return link to commits', t => {
const contributor = contributors.kentcdodds;
const {options} = fixtures();
const expectedLink = '(https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds)';
const expectedLink = 'https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds';

t.is(formatContributionType(options, contributor, 'code'), '[💻]' + expectedLink);
t.is(formatContributionType(options, contributor, 'doc'), '[📖]' + expectedLink);
t.is(formatContributionType(options, contributor, 'test'), '[⚠️]' + expectedLink);
t.is(formatContributionType(options, contributor, 'code'), '[💻](' + expectedLink + ' "Code")');
t.is(formatContributionType(options, contributor, 'doc'), '[📖](' + expectedLink + ' "Documentation")');
t.is(formatContributionType(options, contributor, 'test'), '[⚠️](' + expectedLink + ' "Tests")');
});

test('should return link to issues', t => {
const contributor = contributors.kentcdodds;
const {options} = fixtures();
const expected = '[🐛](https://github.com/jfmengels/all-contributors-cli/issues?q=author%3Akentcdodds)';
const expected = '[🐛](https://github.com/jfmengels/all-contributors-cli/issues?q=author%3Akentcdodds "Bug reports")';

t.is(formatContributionType(options, contributor, 'bug'), expected);
});
Expand All @@ -45,7 +45,7 @@ test('should make any symbol into a link if contribution is an object', t => {
url: 'www.foo.bar'
};

t.is(formatContributionType(options, contributor, contribution), '[🔧](www.foo.bar)');
t.is(formatContributionType(options, contributor, contribution), '[🔧](www.foo.bar "Tools")');
});

test('should override url for given types', t => {
Expand All @@ -56,7 +56,7 @@ test('should override url for given types', t => {
url: 'www.foo.bar'
};

t.is(formatContributionType(options, contributor, contribution), '[💻](www.foo.bar)');
t.is(formatContributionType(options, contributor, contribution), '[💻](www.foo.bar "Code")');
});

test('should be able to add types to the symbol list', t => {
Expand All @@ -66,11 +66,11 @@ test('should be able to add types to the symbol list', t => {
cheerful: {symbol: ':smiley:'}
};

t.is(formatContributionType(options, contributor, 'cheerful'), ':smiley:');
t.is(formatContributionType(options, contributor, 'cheerful'), '[:smiley:](#cheerful-kentcdodds "")');
t.is(formatContributionType(options, contributor, {
type: 'cheerful',
url: 'www.foo.bar'
}), '[:smiley:](www.foo.bar)');
}), '[:smiley:](www.foo.bar "")');
});

test('should be able to add types with template to the symbol list', t => {
Expand All @@ -83,7 +83,7 @@ test('should be able to add types with template to the symbol list', t => {
}
};

t.is(formatContributionType(options, contributor, 'web'), '[:web:](www.kentcdodds.com)');
t.is(formatContributionType(options, contributor, 'web'), '[:web:](www.kentcdodds.com "")');
});

test('should be able to override existing types', t => {
Expand All @@ -93,11 +93,11 @@ test('should be able to override existing types', t => {
code: {symbol: ':smiley:'}
};

t.is(formatContributionType(options, contributor, 'code'), ':smiley:');
t.is(formatContributionType(options, contributor, 'code'), '[:smiley:](#code-kentcdodds "")');
t.is(formatContributionType(options, contributor, {
type: 'code',
url: 'www.foo.bar'
}), '[:smiley:](www.foo.bar)');
}), '[:smiley:](www.foo.bar "")');
});

test('should be able to override existing templates', t => {
Expand All @@ -110,11 +110,11 @@ test('should be able to override existing templates', t => {
}
};

t.is(formatContributionType(options, contributor, 'code'), '[:web:](www.kentcdodds.com)');
t.is(formatContributionType(options, contributor, 'code'), '[:web:](www.kentcdodds.com "")');
t.is(formatContributionType(options, contributor, {
type: 'code',
url: 'www.foo.bar'
}), '[:web:](www.foo.bar)');
}), '[:web:](www.foo.bar "")');
});

test('should throw a helpful error on unknown type', t => {
Expand Down
8 changes: 4 additions & 4 deletions lib/generate/format-contributor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test('should format a simple contributor', t => {
const contributor = _.assign(contributors.kentcdodds, {contributions: ['review']});
const {options} = fixtures();

const expected = '[<img src="https://avatars1.githubusercontent.com/u/1500684" width="150px;"/><br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />👀';
const expected = '[<img src="https://avatars1.githubusercontent.com/u/1500684" width="150px;"/><br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />[👀](#review-kentcdodds "Reviewed Pull Requests")';

t.is(formatContributor(options, contributor), expected);
});
Expand All @@ -25,7 +25,7 @@ test('should format contributor with complex contribution types', t => {
const contributor = contributors.kentcdodds;
const {options} = fixtures();

const expected = '[<img src="https://avatars1.githubusercontent.com/u/1500684" width="150px;"/><br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) 👀 💬';
const expected = '[<img src="https://avatars1.githubusercontent.com/u/1500684" width="150px;"/><br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds "Documentation") [👀](#review-kentcdodds "Reviewed Pull Requests") [💬](#question-kentcdodds "Answering Questions")';

t.is(formatContributor(options, contributor), expected);
});
Expand All @@ -45,7 +45,7 @@ test('should default image size to 100', t => {
const {options} = fixtures();
delete options.imageSize;

const expected = '[<img src="https://avatars1.githubusercontent.com/u/1500684" width="100px;"/><br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />👀';
const expected = '[<img src="https://avatars1.githubusercontent.com/u/1500684" width="100px;"/><br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />[👀](#review-kentcdodds "Reviewed Pull Requests")';

t.is(formatContributor(options, contributor), expected);
});
Expand All @@ -54,7 +54,7 @@ test('should format contributor with pipes in their name', t => {
const contributor = contributors.pipey;
const {options} = fixtures();

const expected = '[<img src="https://avatars1.githubusercontent.com/u/1500684" width="150px;"/><br /><sub>Who &#124; Needs &#124; Pipes?</sub>](http://github.com/chrisinajar)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=pipey)';
const expected = '[<img src="https://avatars1.githubusercontent.com/u/1500684" width="150px;"/><br /><sub>Who &#124; Needs &#124; Pipes?</sub>](http://github.com/chrisinajar)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=pipey "Documentation")';

t.is(formatContributor(options, contributor), expected);
});

0 comments on commit f99b470

Please sign in to comment.