Use contributor\'s blog as profile link if available

This commit is contained in:
Jeroen Engels 2016-03-06 19:37:26 +01:00
parent f9979731fb
commit a973379bd5
5 changed files with 20 additions and 14 deletions

View file

@ -7,7 +7,7 @@
"login": "jfmengels"
, "name": "Jeroen Engels"
, "avatar_url": "https://avatars.githubusercontent.com/u/3869412?v=3"
, "html_url": "https://github.com/jfmengels"
, "profile": "https://github.com/jfmengels"
, "contributions": [
"code"
, "doc"
@ -18,7 +18,7 @@
"login": "kentcdodds"
, "name": "Kent C. Dodds"
, "avatar_url": "https://avatars.githubusercontent.com/u/1500684?v=3"
, "html_url": "http://kentcdodds.com/"
, "profile": "http://kentcdodds.com/"
, "contributions": [
"doc"
]

View file

@ -6,7 +6,7 @@ function mockInfoFetcher(username, cb) {
login: username,
name: 'Some name',
avatar_url: 'www.avatar.url',
html_url: 'www.html.url'
profile: 'www.profile.url'
});
}
@ -16,7 +16,7 @@ function fixtures() {
login: 'login1',
name: 'Some name',
avatar_url: 'www.avatar.url',
html_url: 'www.html.url',
profile: 'www.profile.url',
contributions: [
'code'
]
@ -24,7 +24,7 @@ function fixtures() {
login: 'login2',
name: 'Some name',
avatar_url: 'www.avatar.url',
html_url: 'www.html.url',
profile: 'www.profile.url',
contributions: [
{ type: 'blog', url: 'www.blog.url/path' },
'code'
@ -60,7 +60,7 @@ test.cb('should add new contributor at the end of the list of contributors', t =
login: 'login3',
name: 'Some name',
avatar_url: 'www.avatar.url',
html_url: 'www.html.url',
profile: 'www.profile.url',
contributions: [
'doc'
]
@ -82,7 +82,7 @@ test.cb('should add new contributor at the end of the list of contributors with
login: 'login3',
name: 'Some name',
avatar_url: 'www.avatar.url',
html_url: 'www.html.url',
profile: 'www.profile.url',
contributions: [
{ type: 'doc', url: 'www.foo.bar' }
]
@ -115,7 +115,7 @@ test.cb(`should update an existing contributor's contributions if a new type is
login: 'login1',
name: 'Some name',
avatar_url: 'www.avatar.url',
html_url: 'www.html.url',
profile: 'www.profile.url',
contributions: [
'code',
'bug'
@ -138,7 +138,7 @@ test.cb(`should update an existing contributor's contributions if a new type is
login: 'login1',
name: 'Some name',
avatar_url: 'www.avatar.url',
html_url: 'www.html.url',
profile: 'www.profile.url',
contributions: [
'code',
{ type: 'bug', url: 'www.foo.bar' },

View file

@ -13,7 +13,13 @@ module.exports = function getUserInfo(username, cb) {
if (error) {
return cb(error);
}
var user = JSON.parse(res.body);
return cb(null, _.pick(['login', 'name', 'avatar_url', 'html_url'], user));
var body = JSON.parse(res.body);
var user = {
login: body.login,
name: body.name,
avatar_url: body.avatar_url,
profile: body.blog || body.html_url
};
return cb(null, user);
});
}

View file

@ -2,7 +2,7 @@
"kentcdodds": {
"login": "kentcdodds",
"name": "Kent C. Dodds",
"html_url": "http://kentcdodds.com",
"profile": "http://kentcdodds.com",
"avatar_url": "https://avatars1.githubusercontent.com/u/1500684",
"contributions": [
"doc",
@ -13,7 +13,7 @@
"bogas04": {
"login": "bogas04",
"name": "Divjot Singh",
"html_url": "http://bogas04.github.io",
"profile": "http://bogas04.github.io",
"avatar_url": "https://avatars1.githubusercontent.com/u/6177621",
"contributions": [
"review"

View file

@ -5,7 +5,7 @@ var _ = require('lodash/fp');
var formatContributionType = require('./formatContributionType');
var avatarTemplate = _.template('![<%= contributor.name %>](<%= contributor.avatar_url %>)');
var avatarBlockTemplate = _.template('[<%= avatar %><br /><sub><%= contributor.name %></sub>](<%= contributor.html_url %>)');
var avatarBlockTemplate = _.template('[<%= avatar %><br /><sub><%= contributor.name %></sub>](<%= contributor.profile %>)');
var contributorTemplate = _.template('<%= avatarBlock %><br /><%= contributions %>');
function defaultTemplate(templateData) {