This commit is contained in:
Greg Cochard 2015-12-01 10:33:50 -08:00
parent 18cd0c15b9
commit 79ccfef467
3 changed files with 24 additions and 37 deletions

View File

@ -4210,39 +4210,30 @@ cache(function(data, match, sendBadge, request) {
badgeData.colorscheme = '55ACEE';
badgeData.logo = badgeData.logo || logos.twitter;
badgeData.links = [
'https://twitter.com/intent/follow?screen_name=' + user
'https://twitter.com/intent/follow?screen_name=' + user,
'https://twitter.com/' + user + '/followers'
];
if (data.nobubble) {
badgeData.nobubble = data.nobubble;
sendBadge(format, badgeData);
return;
}
if (badgeData.template === 'social') {
badgeData.links[1] = 'https://twitter.com/' + user + '/followers';
badgeData.text[1] = '';
request(options, function(err, res, buffer) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
return;
}
try {
var data = JSON.parse(buffer);
// the data is formatted as an array
data = data[0];
// data.followers_count could be zero...don't just check if falsey
if(!data.hasOwnProperty('followers_count')){
badgeData.text[1] = 'invalid';
} else {
badgeData.text[1] = metric(data.followers_count);
}
} catch(e) {
console.error(e);
badgeData.text[1] = 'invalid';
}
badgeData.text[1] = '';
request(options, function(err, res, buffer) {
if (err != null) {
sendBadge(format, badgeData);
});
}
return;
}
try {
var data = JSON.parse(buffer);
// the data is formatted as an array
data = data[0];
// data.followers_count could be zero...don't just check if falsey
if(!data.hasOwnProperty('followers_count')){
badgeData.text[1] = '';
} else {
badgeData.text[1] = metric(data.followers_count);
}
} catch(e) {
console.error(e);
}
sendBadge(format, badgeData);
});
}));
// Snap CI build integration.

View File

@ -14,7 +14,7 @@
</linearGradient>
<g stroke="#d5d5d5">
<rect stroke="none" fill="#fcfcfc" x="0.5" y="0.5" width="{{=it.widths[0]}}" height="19" rx="2"/>
{{?!it.nobubble}}
{{?(it.text[1] && it.text[1].length)}}
<rect y="0.5" x="{{=it.widths[0]+6.5}}" width="{{=it.widths[1]}}" height="19" rx="2" fill="#fafafa"/>
<rect x="{{=it.widths[0]+6}}" y="7.5" width="0.5" height="5" stroke="#fafafa"/>
<path d="M{{=it.widths[0]+6.5}} 6.5 l-3 3v1 l3 3" stroke="d5d5d5" fill="#fafafa"/>
@ -26,7 +26,7 @@
<g fill="#333" text-anchor="middle" font-family="Helvetica Neue,Helvetica,Arial,sans-serif" font-weight="700" font-size="11px" line-height="14px">
<text x="{{=(it.widths[0]+it.logoWidth+it.logoPadding)/2}}" y="15" fill="#fff">{{=it.escapeXml(it.capitalize(it.text[0]))}}</text>
<text x="{{=(it.widths[0]+it.logoWidth+it.logoPadding)/2}}" y="14">{{=it.escapeXml(it.capitalize(it.text[0]))}}</text>
{{?!it.nobubble}}
{{?(it.text[1] && it.text[1].length)}}
<text x="{{=it.widths[0]+it.widths[1]/2+6}}" y="15" fill="#fff">{{=it.escapeXml(it.text[1])}}</text>
<a xlink:href="{{=it.links[1]}}">
<text id="rlink" x="{{=it.widths[0]+it.widths[1]/2+6}}" y="14">{{=it.escapeXml(it.text[1])}}</text>

View File

@ -502,10 +502,6 @@ Pixel-perfect &nbsp; Retina-ready &nbsp; Fast &nbsp; Consistent &nbsp; Hackable
<td><img src='/twitter/follow/shields_io.svg?style=social' alt=''/></td>
<td><code>https://img.shields.io/twitter/follow/shields_io.svg?style=social</code></td>
</tr>
<tr><th> Twitter Follow (with no count): </th>
<td><img src='/twitter/follow/shields_io.svg?style=social&nobubble=true' alt=''/></td>
<td><code>https://img.shields.io/twitter/follow/shields_io.svg?style=social&amp;nobubble=true</code></td>
</tr>
</tbody></table>
<h3 id="miscellaneous"> Miscellaneous </h3>