Adds Nuget release badge
This commit is contained in:
parent
ea51600f4a
commit
abc6d690db
29
server.js
29
server.js
|
@ -851,6 +851,35 @@ cache(function(data, match, sendBadge) {
|
|||
});
|
||||
}));
|
||||
|
||||
// Nuget version integration.
|
||||
camp.route(/^\/nuget\/v\/(.*)\.(svg|png|gif|jpg)$/,
|
||||
cache(function(data, match, sendBadge) {
|
||||
var repo = match[1]; // eg, `localeval`.
|
||||
var format = match[2];
|
||||
var apiUrl = 'https://www.nuget.org/api/v2/Packages()?$filter=Id%20eq%20%27' + repo + '%27%20and%20IsLatestVersion%20eq%20true';
|
||||
var badgeData = getBadgeData('nuget', data);
|
||||
request(apiUrl, { headers: { 'Accept': 'application/atom+json,application/json' } }, function(err, res, buffer) {
|
||||
if (err != null) {
|
||||
badgeData.text[1] = 'inaccessible';
|
||||
sendBadge(format, badgeData);
|
||||
}
|
||||
try {
|
||||
var data = JSON.parse(buffer);
|
||||
var version = data.d.results[0].NormalizedVersion;
|
||||
badgeData.text[1] = 'v' + version;
|
||||
if (version[0] === '0') {
|
||||
badgeData.colorscheme = 'orange';
|
||||
} else {
|
||||
badgeData.colorscheme = 'blue';
|
||||
}
|
||||
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) {
|
||||
|
|
10
try.html
10
try.html
|
@ -188,6 +188,10 @@ I made the GitHub Badge Service.
|
|||
<td><img src='/cookbook/v/chef-sugar.svg' alt=''/></td>
|
||||
<td><code>http://img.shields.io/cookbook/v/chef-sugar.svg</code></td>
|
||||
</tr>
|
||||
<tr><th> Nuget: </th>
|
||||
<td><img src='/nuget/v/Nuget.Core.svg' alt=''/></td>
|
||||
<td><code>http://img.shields.io/nuget/v/Nuget.Core.svg</code></td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
|
||||
<h3> Flat Style </h3>
|
||||
|
@ -256,10 +260,10 @@ All the activity and the code sits
|
|||
<a class='photo' href='https://github.com/rmasters'>
|
||||
<img alt='rmasters' src='https://avatars.githubusercontent.com/u/34284?s=80'>
|
||||
</a>
|
||||
<br>
|
||||
<a class='photo' href='https://github.com/nathany'>
|
||||
<img alt='nathany' src='https://gravatar.com/avatar/7d0978b275a362d11283396a929aee65'>
|
||||
</a>
|
||||
<br>
|
||||
<a class='photo' href='https://github.com/whit537'>
|
||||
<img alt='whit537' src='https://gravatar.com/avatar/fb054b407a6461e417ee6b6ae084da37'>
|
||||
</a>
|
||||
|
@ -293,6 +297,9 @@ All the activity and the code sits
|
|||
<a class='photo' href='https://github.com/maxogden'>
|
||||
<img alt='maxogden' src='https://avatars1.githubusercontent.com/u/39759?s=80'>
|
||||
</a>
|
||||
<a class='photo' href='https://github.com/avanderhoorn'>
|
||||
<img alt='avanderhoorn' src='https://www.gravatar.com/avatar/6af12b64c2fe22af3b27848b8eedd992'>
|
||||
</a>
|
||||
|
||||
<p><small>:wq</small></p>
|
||||
<script>
|
||||
|
@ -308,4 +315,3 @@ function makeImage() {
|
|||
document.location = url;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user