Merge remote-tracking branch 'sagiegurari/master'
This commit is contained in:
commit
cb89543e43
|
@ -212,6 +212,10 @@ Pixel-perfect Retina-ready Fast Consistent Hackable
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
<h3 id="downloads"> Downloads </h3>
|
<h3 id="downloads"> Downloads </h3>
|
||||||
<table class='badge'><tbody>
|
<table class='badge'><tbody>
|
||||||
|
<tr><th data-keywords='github'> Github All Releases: </th>
|
||||||
|
<td><img src='https://img.shields.io/github/downloads/atom/atom/total.svg' alt=''/></td>
|
||||||
|
<td><code>https://img.shields.io/github/downloads/atom/atom/total.svg</code></td>
|
||||||
|
</tr>
|
||||||
<tr><th data-keywords='github'> Github Releases: </th>
|
<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><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>
|
<td><code>https://img.shields.io/github/downloads/atom/atom/latest/total.svg</code></td>
|
||||||
|
@ -925,6 +929,10 @@ is where the current server got started.
|
||||||
<a class='photo' href='https://github.com/PeterDaveHello'>
|
<a class='photo' href='https://github.com/PeterDaveHello'>
|
||||||
<img alt='PeterDaveHello' src='https://avatars3.githubusercontent.com/u/3691490?s=80'>
|
<img alt='PeterDaveHello' src='https://avatars3.githubusercontent.com/u/3691490?s=80'>
|
||||||
</a>
|
</a>
|
||||||
|
<br>
|
||||||
|
<a class='photo' href='https://github.com/sagiegurari'>
|
||||||
|
<img alt='sagiegurari' src='https://avatars.githubusercontent.com/u/8112599?s=80'>
|
||||||
|
</a>
|
||||||
<p><small>:wq</small></p>
|
<p><small>:wq</small></p>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|
42
server.js
42
server.js
|
@ -2633,15 +2633,29 @@ cache(function(data, match, sendBadge, request) {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// GitHub release-download-count integration.
|
// GitHub release-download-count integration.
|
||||||
camp.route(/^\/github\/downloads\/([^\/]+)\/([^\/]+)\/([^\/]+)\/([^\/]+)\.(svg|png|gif|jpg|json)$/,
|
camp.route(/^\/github\/downloads\/([^\/]+)\/([^\/]+)(\/[^\/]+)?\/([^\/]+)\.(svg|png|gif|jpg|json)$/,
|
||||||
cache(function(data, match, sendBadge, request) {
|
cache(function(data, match, sendBadge, request) {
|
||||||
var user = match[1]; // eg, qubyte/rubidium
|
var user = match[1]; // eg, qubyte/rubidium
|
||||||
var repo = match[2];
|
var repo = match[2];
|
||||||
var tag = match[3];
|
|
||||||
|
var tag = match[3]; //null for all releases
|
||||||
var asset_name = match[4].toLowerCase(); // eg. total, atom-amd64.deb, atom.x86_64.rpm
|
var asset_name = match[4].toLowerCase(); // eg. total, atom-amd64.deb, atom.x86_64.rpm
|
||||||
var format = match[5];
|
var format = match[5];
|
||||||
var release_path = tag !== 'latest' ? 'tags/' + match[3] : 'latest';
|
|
||||||
var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo + '/releases/' + release_path;
|
if (tag && (tag.indexOf('/') !== -1)) {
|
||||||
|
tag = tag.split('/').join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
var total = true;
|
||||||
|
if (tag) {
|
||||||
|
total = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo + '/releases';
|
||||||
|
if (!total) {
|
||||||
|
var release_path = tag !== 'latest' ? 'tags/' + tag : 'latest';
|
||||||
|
apiUrl = apiUrl + '/' + release_path;
|
||||||
|
}
|
||||||
// Using our OAuth App secret grants us 5000 req/hour
|
// Using our OAuth App secret grants us 5000 req/hour
|
||||||
// instead of the standard 60 req/hour.
|
// instead of the standard 60 req/hour.
|
||||||
if (serverSecrets) {
|
if (serverSecrets) {
|
||||||
|
@ -2665,15 +2679,33 @@ cache(function(data, match, sendBadge, request) {
|
||||||
}
|
}
|
||||||
var data = JSON.parse(buffer);
|
var data = JSON.parse(buffer);
|
||||||
var downloads = 0;
|
var downloads = 0;
|
||||||
|
|
||||||
|
var label;
|
||||||
|
if (total) {
|
||||||
|
data.forEach(function (tagData) {
|
||||||
|
tagData.assets.forEach(function (asset) {
|
||||||
|
if (asset_name === 'total' || asset_name === asset.name.toLowerCase()) {
|
||||||
|
downloads += asset.download_count;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
label = 'total';
|
||||||
|
if (asset_name !== 'total') {
|
||||||
|
label += ' ' + '[' + asset_name + ']';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
data.assets.forEach(function (asset) {
|
data.assets.forEach(function (asset) {
|
||||||
if (asset_name === 'total' || asset_name === asset.name.toLowerCase()) {
|
if (asset_name === 'total' || asset_name === asset.name.toLowerCase()) {
|
||||||
downloads += asset.download_count;
|
downloads += asset.download_count;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var label = tag !== 'latest' ? tag : '';
|
|
||||||
|
label = tag !== 'latest' ? tag : '';
|
||||||
if (asset_name !== 'total') {
|
if (asset_name !== 'total') {
|
||||||
label += ' ' + '[' + asset_name + ']';
|
label += ' ' + '[' + asset_name + ']';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
badgeData.text[1] = metric(downloads) + ' ' + label;
|
badgeData.text[1] = metric(downloads) + ' ' + label;
|
||||||
badgeData.colorscheme = 'brightgreen';
|
badgeData.colorscheme = 'brightgreen';
|
||||||
sendBadge(format, badgeData);
|
sendBadge(format, badgeData);
|
||||||
|
|
8
try.html
8
try.html
|
@ -211,6 +211,10 @@ Pixel-perfect Retina-ready Fast Consistent Hackable
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
<h3 id="downloads"> Downloads </h3>
|
<h3 id="downloads"> Downloads </h3>
|
||||||
<table class='badge'><tbody>
|
<table class='badge'><tbody>
|
||||||
|
<tr><th data-keywords='github'> Github All Releases: </th>
|
||||||
|
<td><img src='https://img.shields.io/github/downloads/atom/atom/total.svg' alt=''/></td>
|
||||||
|
<td><code>https://img.shields.io/github/downloads/atom/atom/total.svg</code></td>
|
||||||
|
</tr>
|
||||||
<tr><th data-keywords='github'> Github Releases: </th>
|
<tr><th data-keywords='github'> Github Releases: </th>
|
||||||
<td><img src='/github/downloads/atom/atom/latest/total.svg' alt=''/></td>
|
<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>
|
<td><code>https://img.shields.io/github/downloads/atom/atom/latest/total.svg</code></td>
|
||||||
|
@ -924,6 +928,10 @@ is where the current server got started.
|
||||||
<a class='photo' href='https://github.com/PeterDaveHello'>
|
<a class='photo' href='https://github.com/PeterDaveHello'>
|
||||||
<img alt='PeterDaveHello' src='https://avatars3.githubusercontent.com/u/3691490?s=80'>
|
<img alt='PeterDaveHello' src='https://avatars3.githubusercontent.com/u/3691490?s=80'>
|
||||||
</a>
|
</a>
|
||||||
|
<br>
|
||||||
|
<a class='photo' href='https://github.com/sagiegurari'>
|
||||||
|
<img alt='sagiegurari' src='https://avatars.githubusercontent.com/u/8112599?s=80'>
|
||||||
|
</a>
|
||||||
<p><small>:wq</small></p>
|
<p><small>:wq</small></p>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user