Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/badges/master' into Circle_CI
Browse files Browse the repository at this point in the history
  • Loading branch information
RedSparr0w committed Oct 24, 2016
2 parents 2b0d688 + 6e5904d commit e455272
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 30 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM node:0.12-onbuild
FROM node:6.4.0-onbuild
ENV INFOSITE http://shields.io
EXPOSE 80
4 changes: 2 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ You can build and run the server locally using Docker. First build an image:
```console
$ docker build -t shields ./
Sending build context to Docker daemon 3.923 MB
Step 0 : FROM node:0.12.7-onbuild
Step 0 : FROM node:6.4.0-onbuild
Removing intermediate container c4678889953f
Successfully built 4471b442c220
Expand All @@ -137,7 +137,7 @@ Successfully built 4471b442c220
Then run the container:

```console
$ docker run --rm -p 8080:80 shields
$ docker run --rm -p 8080:80 -v "$(pwd)/secret.json":/usr/src/app/secret.json --name shields shields

> [email protected] start /usr/src/app
> node server.js
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ What kind of metadata can you convey using badges?
## Services using the Shields standard
* [Badger](https://github.com/badges/badgerbadgerbadger)
* [badges2svg](https://github.com/bfontaine/badges2svg)
* [CII Best Practices](https://bestpractices.coreinfrastructure.org/)
* [Codacy](https://www.codacy.com)
* [Code Climate](https://codeclimate.com/changelog/510d4fde56b102523a0004bf)
* [Coveralls](https://coveralls.io/)
Expand Down
18 changes: 12 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ <h3 id="downloads"> Downloads </h3>
</tbody></table>
<h3 id="version"> Version </h3>
<table class='badge'><tbody>
<tr><th data-keywords='cdn cdnjs'> CDNJS: </th>
<td><img src='https://img.shields.io/cdnjs/v/jquery.svg?maxAge=2592000' alt=''/></td>
<td><code>https://img.shields.io/cdnjs/v/jquery.svg</code></td>
</tr>
<tr><th data-keywords='node'> npm: </th>
<td><img src='https://img.shields.io/npm/v/npm.svg?maxAge=2592000' alt=''/></td>
<td><code>https://img.shields.io/npm/v/npm.svg</code></td>
Expand Down Expand Up @@ -576,8 +580,8 @@ <h3 id="social"> Social </h3>
<td><code>https://img.shields.io/twitter/url/http/shields.io.svg?style=social</code></td>
</tr>
<tr><th> Twitter Follow: </th>
<td><img src='https://img.shields.io/twitter/follow/shields_io.svg?style=social&label=Follow&maxAge=2592000' alt=''/></td>
<td><code>https://img.shields.io/twitter/follow/shields_io.svg?style=social&amp;label=Follow</code></td>
<td><img src='https://img.shields.io/twitter/follow/espadrine.svg?style=social&label=Follow&maxAge=2592000' alt=''/></td>
<td><code>https://img.shields.io/twitter/follow/espadrine.svg?style=social&amp;label=Follow</code></td>
</tr>
</tbody></table>

Expand Down Expand Up @@ -1045,7 +1049,7 @@ <h2 id="like-this"> Like This? </h2>
And tell us, we might be able to bring it to you anyway!
</p>
<p>
<a href='https://twitter.com/Shields_io'><img src='https://img.shields.io/twitter/follow/shields_io.svg?style=social&label=Follow&maxAge=2592000' alt='Follow @shields_io'></a>
<a href='https://twitter.com/espadrine'><img src='https://img.shields.io/twitter/follow/espadrine.svg?style=social&label=Follow&maxAge=2592000' alt='Follow @espadrine'></a>
<a href='https://www.gratipay.com/Shields/'><img src='https://img.shields.io/gratipay/Shields.svg?style=social&label=Donate&maxAge=2592000' alt='Donate to us!'/></a>
<iframe src="https://ghbtns.com/github-btn.html?user=badges&amp;repo=shields&amp;type=fork&amp;count=true"
style="border:0; background-color:transparent"
Expand Down Expand Up @@ -1293,7 +1297,7 @@ <h2 id="like-this"> Like This? </h2>
var th = tr.firstElementChild;
var link = th.dataset.link? th.dataset.link: '';
// Remove the ?maxAge parameter from the query string.
trimg.replace(/[\?&]maxAge=\d+$|maxAge=\d+&/, '');
trimg = trimg.replace(/[\?&]maxAge=\d+$|maxAge=\d+&/, '');
copyForm.img.value = trimg;
copyForm.url.value = link;
// Insert documentation.
Expand All @@ -1312,8 +1316,10 @@ <h2 id="like-this"> Like This? </h2>
var url = copyForm.url.value;
var img = copyForm.img.value;
var style = copyForm.style.value;
// Default style doesn't show.
if (style !== 'flat') { img += '?style=' + style; }
// Default style doesn't need value
if (style !== 'flat') {
img += (img.indexOf('?') != -1 ? '&style=' : '?style=') + style;
}
var md = '[![' + trname + '](' + img + ')](' + url + ')';
var rst = '.. image:: ' + img + ' :target: ' + url;
copyMarkdown.value = md;
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
},
"dependencies": {
"dot": "~1.0.3",
"svgo": "~0.5.1",
"pdfkit": "~0.7.1",
"phantomjs-prebuilt": "~2.1.7",
"request": "~2.55.0",
"redis": "~1.0.0",
"camp": "~16.2.2",
"semver": "~4.3.3",
"bower": "~1.4.1",
"svgo": "~0.7.1",
"pdfkit": "~0.8.0",
"phantomjs-prebuilt": "~2.1.13",
"request": "~2.75.0",
"redis": "~2.6.2",
"camp": "~16.2.3",
"semver": "~5.3.0",
"bower": "~1.7.9",
"chrome-web-store-item-property": "^1.1.2",
"json-autosave": "~1.1.1"
},
Expand Down
47 changes: 40 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,32 @@ cache(function(data, match, sendBadge, request) {
});
}));

// CDNJS version integration
camp.route(/^\/cdnjs\/v\/(.*)\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
var library = encodeURIComponent(match[1]); // eg, "express" or "@user/express"
var format = match[2];
var apiUrl = 'https://api.cdnjs.com/libraries/' + library + '?fields=version';
var badgeData = getBadgeData('cdnjs', data);
request(apiUrl, function(err, res, buffer) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
return;
}
try {
var version = JSON.parse(buffer).version || 0;
var vdata = versionColor(version);
badgeData.text[1] = vdata.version;
badgeData.colorscheme = vdata.color;
sendBadge(format, badgeData);
} catch(e) {
badgeData.text[1] = 'not found';
sendBadge(format, badgeData);
}
});
}));

// npm download integration.
camp.route(/^\/npm\/dm\/(.*)\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
Expand Down Expand Up @@ -2899,7 +2925,7 @@ cache(function(data, match, sendBadge, request) {
var user = match[2]; // eg, qubyte/rubidium
var repo = match[3];
var format = match[4];
var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo + '/contributors?page=1&per_page=1&anon=' + (0+isAnon);
var apiUrl = 'https://api.github.com/repos/' + user + '/' + repo + '/contributors?page=1&per_page=1&anon=' + (!!isAnon);
var badgeData = getBadgeData('contributors', data);
if (badgeData.template === 'social') {
badgeData.logo = badgeData.logo || logos.github;
Expand All @@ -2911,8 +2937,15 @@ cache(function(data, match, sendBadge, request) {
return;
}
try {
var data = JSON.parse(buffer);
badgeData.text[1] = metric(data[0].contributions);
var contributors;

if (res.headers['link'] && res.headers['link'].indexOf('rel="last"') !== -1) {
contributors = res.headers['link'].match(/[?&]page=(\d+)[^>]+>; rel="last"/)[1];
} else {
contributors = JSON.parse(buffer).length;
}

badgeData.text[1] = metric(+contributors);
badgeData.colorscheme = 'blue';
} catch(e) {
badgeData.text[1] = 'inaccessible';
Expand Down Expand Up @@ -4479,7 +4512,7 @@ cache(function(data, match, sendBadge, request) {

// CircleCI build integration.
// https://circleci.com/api/v1/project/BrightFlair/PHP.Gt?circle-token=0a5143728784b263d9f0238b8d595522689b3af2&limit=1&filter=completed
camp.route(/^\/circleci\/(?:token\/(\w+))?[+\/]?project\/(github|bitbucket)?[+\/]?([^\/]+\/[^\/]+)(?:\/(.*))?\.(svg|png|gif|jpg|json)$/,
camp.route(/^\/circleci\/(?:token\/(\w+))?[+\/]?project\/(?:(github|bitbucket)\/)?([^\/]+\/[^\/]+)(?:\/(.*))?\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
var token = match[1];
var type = match[2] || 'github'; // github OR bitbucket
Expand Down Expand Up @@ -5285,20 +5318,20 @@ cache(function(data, match, sendBadge, request) {
badgeData.colorscheme = vdata.color;
} else if (type === 'd') {
var downloads = value.interactionCount.UserDownloads;
badgeData.text[0] = 'downloads';
badgeData.text[0] = data.label || 'downloads';
badgeData.text[1] = metric(downloads) + ' total';
badgeData.colorscheme = downloadCountColor(downloads);
} else if (type === 'price') {
badgeData.text[1] = value.price;
badgeData.colorscheme = 'brightgreen';
} else if (type === 'rating') {
var rating = Math.round(value.ratingValue * 100) / 100;
badgeData.text[0] = 'rating';
badgeData.text[0] = data.label || 'rating';
badgeData.text[1] = rating;
badgeData.colorscheme = floorCountColor(rating, 2, 3, 4);
} else if (type === 'rating-count') {
var ratingCount = value.ratingCount;
badgeData.text[0] = 'rating count';
badgeData.text[0] = data.label || 'rating count';
badgeData.text[1] = metric(ratingCount) + ' total';
badgeData.colorscheme = floorCountColor(ratingCount, 5, 50, 500);
}
Expand Down
18 changes: 12 additions & 6 deletions try.html
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ <h3 id="downloads"> Downloads </h3>
</tbody></table>
<h3 id="version"> Version </h3>
<table class='badge'><tbody>
<tr><th data-keywords='cdn cdnjs'> CDNJS: </th>
<td><img src='/cdnjs/v/jquery.svg' alt=''/></td>
<td><code>https://img.shields.io/cdnjs/v/jquery.svg</code></td>
</tr>
<tr><th data-keywords='node'> npm: </th>
<td><img src='/npm/v/npm.svg' alt=''/></td>
<td><code>https://img.shields.io/npm/v/npm.svg</code></td>
Expand Down Expand Up @@ -575,8 +579,8 @@ <h3 id="social"> Social </h3>
<td><code>https://img.shields.io/twitter/url/http/shields.io.svg?style=social</code></td>
</tr>
<tr><th> Twitter Follow: </th>
<td><img src='/twitter/follow/shields_io.svg?style=social&label=Follow' alt=''/></td>
<td><code>https://img.shields.io/twitter/follow/shields_io.svg?style=social&amp;label=Follow</code></td>
<td><img src='/twitter/follow/espadrine.svg?style=social&label=Follow' alt=''/></td>
<td><code>https://img.shields.io/twitter/follow/espadrine.svg?style=social&amp;label=Follow</code></td>
</tr>
</tbody></table>

Expand Down Expand Up @@ -1044,7 +1048,7 @@ <h2 id="like-this"> Like This? </h2>
And tell us, we might be able to bring it to you anyway!
</p>
<p>
<a href='https://twitter.com/Shields_io'><img src='/twitter/follow/shields_io.svg?style=social&label=Follow' alt='Follow @shields_io'></a>
<a href='https://twitter.com/espadrine'><img src='/twitter/follow/espadrine.svg?style=social&label=Follow' alt='Follow @espadrine'></a>
<a href='https://www.gratipay.com/Shields/'><img src='/gratipay/Shields.svg?style=social&label=Donate' alt='Donate to us!'/></a>
<iframe src="https://ghbtns.com/github-btn.html?user=badges&amp;repo=shields&amp;type=fork&amp;count=true"
style="border:0; background-color:transparent"
Expand Down Expand Up @@ -1292,7 +1296,7 @@ <h2 id="like-this"> Like This? </h2>
var th = tr.firstElementChild;
var link = th.dataset.link? th.dataset.link: '';
// Remove the ?maxAge parameter from the query string.
trimg.replace(/[\?&]maxAge=\d+$|maxAge=\d+&/, '');
trimg = trimg.replace(/[\?&]maxAge=\d+$|maxAge=\d+&/, '');
copyForm.img.value = trimg;
copyForm.url.value = link;
// Insert documentation.
Expand All @@ -1311,8 +1315,10 @@ <h2 id="like-this"> Like This? </h2>
var url = copyForm.url.value;
var img = copyForm.img.value;
var style = copyForm.style.value;
// Default style doesn't show.
if (style !== 'flat') { img += '?style=' + style; }
// Default style doesn't need value
if (style !== 'flat') {
img += (img.indexOf('?') != -1 ? '&style=' : '?style=') + style;
}
var md = '[![' + trname + '](' + img + ')](' + url + ')';
var rst = '.. image:: ' + img + ' :target: ' + url;
copyMarkdown.value = md;
Expand Down

0 comments on commit e455272

Please sign in to comment.