improvements
+ grab releases by tag name instead of obscure ID + more examples + better labels
This commit is contained in:
parent
478fc27003
commit
8d8a88a3ff
12
index.html
12
index.html
|
@ -168,6 +168,18 @@ Pixel-perfect Retina-ready Fast Consistent Hackable
|
|||
</tbody></table>
|
||||
<h3 id="downloads"> Downloads </h3>
|
||||
<table class='badge'><tbody>
|
||||
<tr><th data-keywords='github'> Github Releases: </th>
|
||||
<td><img src='https://img.shields.io/github/downloads/atom/atom/latest/total.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/github/downloads/atom/atom/latest/total.svg</code></td>
|
||||
</tr>
|
||||
<tr><th data-keywords='github'> Github Releases (by Release): </th>
|
||||
<td><img src='https://img.shields.io/github/downloads/atom/atom/v0.190.0/total.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/github/downloads/atom/atom/v0.190.0/total.svg</code></td>
|
||||
</tr>
|
||||
<tr><th data-keywords='github'> Github Releases (by Asset): </th>
|
||||
<td><img src='https://img.shields.io/github/downloads/atom/atom/latest/atom-amd64.deb.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/github/downloads/atom/atom/latest/atom-amd64.deb.svg</code></td>
|
||||
</tr>
|
||||
<tr><th data-keywords='node'> npm: </th>
|
||||
<td><img src='https://img.shields.io/npm/dm/localeval.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/npm/dm/localeval.svg</code></td>
|
||||
|
|
11
server.js
11
server.js
|
@ -1971,10 +1971,11 @@ camp.route(/^\/github\/downloads\/([^\/]+)\/([^\/]+)\/([^\/]+)\/([^\/]+)\.(svg|p
|
|||
cache(function(data, match, sendBadge, request) {
|
||||
var user = match[1]; // eg, qubyte/rubidium
|
||||
var repo = match[2];
|
||||
var id = match[3];
|
||||
var tag = match[3];
|
||||
var asset_name = match[4].toLowerCase(); // eg. total, atom-amd64.deb, atom.x86_64.rpm
|
||||
var format = match[5];
|
||||
var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo + '/releases/' + id;
|
||||
var release_path = tag !== 'latest' ? 'tags/' + match[3] : 'latest';
|
||||
var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo + '/releases/' + release_path;
|
||||
// Using our OAuth App secret grants us 5000 req/hour
|
||||
// instead of the standard 60 req/hour.
|
||||
if (serverSecrets) {
|
||||
|
@ -2000,7 +2001,11 @@ cache(function(data, match, sendBadge, request) {
|
|||
downloads += asset.download_count;
|
||||
}
|
||||
});
|
||||
badgeData.text[1] = metric(downloads) + (asset_name? ' ' + asset_name: ' total');
|
||||
var label = tag === 'latest' ? 'latest version' : tag;
|
||||
if (asset_name !== 'total') {
|
||||
label += ' ' + '[' + asset_name + ']';
|
||||
}
|
||||
badgeData.text[1] = metric(downloads) + ' ' + label;
|
||||
badgeData.colorscheme = 'brightgreen';
|
||||
sendBadge(format, badgeData);
|
||||
} catch(e) {
|
||||
|
|
10
try.html
10
try.html
|
@ -167,10 +167,18 @@ Pixel-perfect Retina-ready Fast Consistent Hackable
|
|||
</tbody></table>
|
||||
<h3 id="downloads"> Downloads </h3>
|
||||
<table class='badge'><tbody>
|
||||
<tr><th data-keywords='github'> Github: </th>
|
||||
<tr><th data-keywords='github'> Github Releases: </th>
|
||||
<td><img src='/github/downloads/atom/atom/latest/total.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/github/downloads/atom/atom/latest/total.svg</code></td>
|
||||
</tr>
|
||||
<tr><th data-keywords='github'> Github Releases (by Release): </th>
|
||||
<td><img src='/github/downloads/atom/atom/v0.190.0/total.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/github/downloads/atom/atom/v0.190.0/total.svg</code></td>
|
||||
</tr>
|
||||
<tr><th data-keywords='github'> Github Releases (by Asset): </th>
|
||||
<td><img src='/github/downloads/atom/atom/latest/atom-amd64.deb.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/github/downloads/atom/atom/latest/atom-amd64.deb.svg</code></td>
|
||||
</tr>
|
||||
<tr><th data-keywords='node'> npm: </th>
|
||||
<td><img src='/npm/dm/localeval.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/npm/dm/localeval.svg</code></td>
|
||||
|
|
Loading…
Reference in New Issue
Block a user