Twitter URL

This commit is contained in:
Thaddee Tyl 2015-06-18 21:49:39 +02:00
parent 624f93fc58
commit 016a9f40dc
3 changed files with 52 additions and 12 deletions

3
logo/twitter.svg Normal file
View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" x="0" y="0" width="40" height="40" viewBox="0 0 72 72">
<path fill="#55acee" d="M68.812,15.141c-2.348,1.039-4.869,1.743-7.519,2.06c2.703-1.62,4.778-4.187,5.756-7.244c-2.529,1.5-5.33,2.592-8.313,3.176C56.349,10.591,52.948,9,49.182,9c-7.229,0-13.092,5.861-13.092,13.093c0,1.026,0.118,2.021,0.338,2.981c-10.885-0.548-20.528-5.757-26.987-13.679c-1.126,1.936-1.771,4.184-1.771,6.581c0,4.542,2.312,8.551,5.824,10.898c-2.146-0.069-4.165-0.657-5.93-1.638c-0.002,0.055-0.002,0.11-0.002,0.162c0,6.345,4.513,11.638,10.504,12.84c-1.101,0.298-2.256,0.457-3.449,0.457c-0.846,0-1.667-0.078-2.465-0.231c1.667,5.2,6.499,8.986,12.23,9.09c-4.482,3.512-10.129,5.606-16.26,5.606c-1.055,0-2.096-0.061-3.122-0.184c5.794,3.717,12.676,5.882,20.067,5.882c24.083,0,37.251-19.949,37.251-37.249c0-0.566-0.014-1.134-0.039-1.694C64.838,20.068,67.058,17.765,68.812,15.141z"/>
</svg>

After

Width:  |  Height:  |  Size: 891 B

View File

@ -3858,6 +3858,35 @@ cache(function(data, match, sendBadge, request) {
});
}));
// Twitter integration.
camp.route(/^\/twitter\/url\/([^\/]+)\/(.+)\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
var scheme = match[1]; // eg, https
var path = match[2]; // eg, shields.io
var format = match[3];
var url = 'http://cdn.api.twitter.com/1/urls/count.json?url=' + scheme + '://' + path;
var badgeData = getBadgeData('tweet', data);
if (badgeData.template === 'social') {
badgeData.logo = badgeData.logo || logos.twitter;
}
request(url, function(err, res, buffer) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
return;
}
try {
var data = JSON.parse(buffer);
badgeData.text[1] = metric(data.count);
badgeData.colorscheme = '55ACEE';
sendBadge(format, badgeData);
} catch(e) {
badgeData.text[1] = 'invalid';
sendBadge(format, badgeData);
}
});
}));
// Any badge.
camp.route(/^\/(:|badge\/)(([^-]|--)*?)-(([^-]|--)*)-(([^-]|--)+)\.(svg|png|gif|jpg)$/,
function(data, match, end, ask) {

View File

@ -460,6 +460,26 @@ Pixel-perfect &nbsp; Retina-ready &nbsp; Fast &nbsp; Consistent &nbsp; Hackable
</tr>
</tbody></table>
<h3 id="social"> Social </h3>
<table class='badge'><tbody>
<tr><th> GitHub forks: </th>
<td><img src='/github/forks/badges/shields.svg' alt=''/></td>
<td><code>https://img.shields.io/github/forks/badges/shields.svg</code></td>
</tr>
<tr><th> GitHub stars: </th>
<td><img src='/github/stars/badges/shields.svg' alt=''/></td>
<td><code>https://img.shields.io/github/stars/badges/shields.svg</code></td>
</tr>
<tr><th> GitHub followers: </th>
<td><img src='/github/followers/espadrine.svg' alt=''/></td>
<td><code>https://img.shields.io/github/followers/espadrine.svg</code></td>
</tr>
<tr><th> Twitter: </th>
<td><img src='/twitter/url/https/shields.io.svg' alt=''/></td>
<td><code>https://img.shields.io/twitter/url/https/shields.io.svg</code></td>
</tr>
</tbody></table>
<h3 id="miscellaneous"> Miscellaneous </h3>
<table class='badge'><tbody>
<tr><th> Gratipay: </th>
@ -582,18 +602,6 @@ Pixel-perfect &nbsp; Retina-ready &nbsp; Fast &nbsp; Consistent &nbsp; Hackable
<td><img src='/github/issues-raw/badges/shields.svg' alt=''/></td>
<td><code>https://img.shields.io/github/issues-raw/badges/shields.svg</code></td>
</tr>
<tr><th> GitHub forks: </th>
<td><img src='/github/forks/badges/shields.svg' alt=''/></td>
<td><code>https://img.shields.io/github/forks/badges/shields.svg</code></td>
</tr>
<tr><th> GitHub stars: </th>
<td><img src='/github/stars/badges/shields.svg' alt=''/></td>
<td><code>https://img.shields.io/github/stars/badges/shields.svg</code></td>
</tr>
<tr><th> GitHub followers: </th>
<td><img src='/github/followers/espadrine.svg' alt=''/></td>
<td><code>https://img.shields.io/github/followers/espadrine.svg</code></td>
</tr>
<tr><th data-keywords='github license'> GitHub license: </th>
<td><img src='/github/license/mashape/apistatus.svg' alt=''/></td>
<td><code>https://img.shields.io/github/license/mashape/apistatus.svg</code></td>