mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-09 13:36:29 +00:00
feat: add alt text to emoji (#42)
* 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-kevinjalbert "Reviewed Pull Requests")`
* Add kevinjalbert to all-contributorsrc
This commit is contained in:
parent
77a014f28e
commit
f99b4701d3
5 changed files with 41 additions and 29 deletions
|
@ -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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
@ -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));
|
||||
url = contribution.url;
|
||||
} else if (type.link) {
|
||||
url = _.template(type.link)(templateData);
|
||||
}
|
||||
if (type.link) {
|
||||
var url = _.template(type.link)(templateData);
|
||||
return linkTemplate(_.assign({url: url}, templateData));
|
||||
}
|
||||
return type.symbol;
|
||||
|
||||
return linkTemplate(_.assign({url: url}, templateData));
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
@ -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 => {
|
||||
|
@ -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 => {
|
||||
|
@ -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 => {
|
||||
|
@ -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 => {
|
||||
|
@ -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 => {
|
||||
|
@ -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 => {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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 | Needs | 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 | Needs | Pipes?</sub>](http://github.com/chrisinajar)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=pipey "Documentation")';
|
||||
|
||||
t.is(formatContributor(options, contributor), expected);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue