Added support for chocolatey version and download count
This commit is contained in:
parent
4e99c5cc40
commit
b132e01afa
28
server.js
28
server.js
|
@ -1155,13 +1155,15 @@ cache(function(data, match, sendBadge) {
|
|||
});
|
||||
}));
|
||||
|
||||
// NuGet version integration.
|
||||
camp.route(/^\/nuget\/v\/(.*)\.(svg|png|gif|jpg)$/,
|
||||
// NuGet/chocolatey version integration.
|
||||
camp.route(/^\/(nuget|chocolatey)\/v\/(.*)\.(svg|png|gif|jpg)$/,
|
||||
cache(function(data, match, sendBadge) {
|
||||
var repo = match[1]; // eg, `Nuget.Core`.
|
||||
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);
|
||||
var site = match[1];
|
||||
var repo = match[2]; // eg, `Nuget.Core`.
|
||||
var format = match[3];
|
||||
var filter = 'Id eq \'' + repo + '\' and IsLatestVersion eq true';
|
||||
var apiUrl = 'https://www.' + site + '.org/api/v2/Packages()?$filter=' + encodeURIComponent(filter);
|
||||
var badgeData = getBadgeData(site, data);
|
||||
request(apiUrl, { headers: { 'Accept': 'application/atom+json,application/json' } }, function(err, res, buffer) {
|
||||
if (err != null) {
|
||||
badgeData.text[1] = 'inaccessible';
|
||||
|
@ -1169,7 +1171,8 @@ cache(function(data, match, sendBadge) {
|
|||
}
|
||||
try {
|
||||
var data = JSON.parse(buffer);
|
||||
var version = data.d.results[0].NormalizedVersion;
|
||||
var result = data.d.results[0];
|
||||
var version = result.NormalizedVersion || result.Version;
|
||||
badgeData.text[1] = 'v' + version;
|
||||
if (version[0] === '0') {
|
||||
badgeData.colorscheme = 'orange';
|
||||
|
@ -1184,13 +1187,14 @@ cache(function(data, match, sendBadge) {
|
|||
});
|
||||
}));
|
||||
|
||||
// NuGet download count integration.
|
||||
camp.route(/^\/nuget\/dt\/(.*)\.(svg|png|gif|jpg)$/,
|
||||
// NuGet/chocolatey download count integration.
|
||||
camp.route(/^\/(nuget|chocolatey)\/dt\/(.*)\.(svg|png|gif|jpg)$/,
|
||||
cache(function(data, match, sendBadge) {
|
||||
var repo = match[1]; // eg, `Nuget.Core`.
|
||||
var format = match[2];
|
||||
var site = match[1];
|
||||
var repo = match[2]; // eg, `Nuget.Core`.
|
||||
var format = match[3];
|
||||
var filter = 'Id eq \'' + repo + '\' and IsLatestVersion eq true';
|
||||
var apiUrl = 'https://www.nuget.org/api/v2/Packages()?$filter=' + encodeURIComponent(filter);
|
||||
var apiUrl = 'https://www.' + site + '.org/api/v2/Packages()?$filter=' + encodeURIComponent(filter);
|
||||
var badgeData = getBadgeData('downloads', data);
|
||||
request(apiUrl, { headers: { 'Accept': 'application/atom+json,application/json' } }, function(err, res, buffer) {
|
||||
if (err != null) {
|
||||
|
|
14
try.html
14
try.html
|
@ -175,6 +175,10 @@ I made the GitHub Badge Service.
|
|||
<td><img src='/nuget/dt/Microsoft.AspNet.Mvc.svg' alt=''/></td>
|
||||
<td><code>http://img.shields.io/nuget/dt/Microsoft.AspNet.Mvc.svg</code></td>
|
||||
</tr>
|
||||
<tr><th> Chocolatey: </th>
|
||||
<td><img src='/chocolatey/dt/scriptcs.svg' alt=''/></td>
|
||||
<td><code>http://img.shields.io/chocolatey/dt/scriptcs.svg</code></td>
|
||||
</tr>
|
||||
<tr><th> PyPI: </th>
|
||||
<td><img src='/pypi/dm/Django.svg' alt=''/></td>
|
||||
<td><code>http://img.shields.io/pypi/dm/Django.svg</code></td>
|
||||
|
@ -241,6 +245,10 @@ I made the GitHub Badge Service.
|
|||
<td><img src='/nuget/v/Nuget.Core.svg' alt=''/></td>
|
||||
<td><code>http://img.shields.io/nuget/v/Nuget.Core.svg</code></td>
|
||||
</tr>
|
||||
<tr><th> Chocolatey: </th>
|
||||
<td><img src='/chocolatey/v/git.svg' alt=''/></td>
|
||||
<td><code>http://img.shields.io/chocolatey/v/git.svg</code></td>
|
||||
</tr>
|
||||
<tr><th> Puppet Forge: </th>
|
||||
<td><img src='/puppetforge/v/vStone/percona.svg' alt=''/></td>
|
||||
<td><code>http://img.shields.io/puppetforge/v/vStone/percona.svg</code></td>
|
||||
|
@ -312,6 +320,7 @@ All the activity and the code sits
|
|||
<a class='photo' href='https://github.com/seanlinsley'>
|
||||
<img alt='seanlinsley' src='https://avatars.githubusercontent.com/u/688886?s=80'>
|
||||
</a>
|
||||
<br>
|
||||
<a class='photo' href='https://github.com/CodeBlock'>
|
||||
<img alt='CodeBlock' src='https://avatars.githubusercontent.com/u/43930?s=80'>
|
||||
</a>
|
||||
|
@ -324,7 +333,6 @@ All the activity and the code sits
|
|||
<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>
|
||||
|
@ -340,6 +348,7 @@ All the activity and the code sits
|
|||
<a class='photo' href='https://github.com/cainus'>
|
||||
<img alt='cainus' src='https://gravatar.com/avatar/c8475420ebca73833e55ccf57d8d7500'>
|
||||
</a>
|
||||
<br>
|
||||
<a class='photo' href='https://github.com/jbowes'>
|
||||
<img alt='jbowes' src='https://gravatar.com/avatar/363ada7cda10d5eae5eeb7704278fb51'>
|
||||
</a>
|
||||
|
@ -361,6 +370,9 @@ All the activity and the code sits
|
|||
<a class='photo' href='https://github.com/avanderhoorn'>
|
||||
<img alt='avanderhoorn' src='https://www.gravatar.com/avatar/6af12b64c2fe22af3b27848b8eedd992'>
|
||||
</a>
|
||||
<a class='photo' href='https://github.com/khellang'>
|
||||
<img alt='khellang' src='https://gravatar.com/avatar/b3616645c168b0b8a65e109a6b1cb010'>
|
||||
</a>
|
||||
|
||||
<p><small>:wq</small></p>
|
||||
<script>
|
||||
|
|
Loading…
Reference in New Issue
Block a user