From d1321179c9e017cbd5e267d290f183046f2bbe89 Mon Sep 17 00:00:00 2001 From: Julien Rottenberg Date: Sat, 27 Feb 2016 18:56:23 -0800 Subject: [PATCH 1/2] PR for badges/shields#241 --- index.html | 4 ++++ server.js | 37 +++++++++++++++++++++++++++++++++++++ try.html | 4 ++++ 3 files changed, 45 insertions(+) diff --git a/index.html b/index.html index 3846d0405ebb8..28b438a2d849b 100644 --- a/index.html +++ b/index.html @@ -723,6 +723,10 @@

Miscellaneous

https://img.shields.io/docker/pulls/mashape/kong.svg + Docker Automated build + + https://img.shields.io/docker/automated/jrottenberg/ffmpeg.svg + ImageLayers Size: https://img.shields.io/imagelayers/image-size/_/ubuntu/latest.svg diff --git a/server.js b/server.js index acb8ab71a590e..05570e9db6406 100644 --- a/server.js +++ b/server.js @@ -4471,6 +4471,43 @@ cache(function(data, match, sendBadge, request) { }); })); + +// Docker Hub automated integration. +camp.route(/^\/docker\/automated\/([^\/]+)\/([^\/]+)\.(svg|png|gif|jpg|json)$/, +cache(function(data, match, sendBadge, request) { + var user = match[1]; // eg, jrottenberg + var repo = match[2]; // eg, ffmpeg + var format = match[3]; + if (user === '_') { + user = 'library'; + } + var path = user + '/' + repo; + var url = 'https://registry.hub.docker.com/v2/repositories/' + path; + var badgeData = getBadgeData('automated build', data); + request(url, function(err, res, buffer) { + if (err != null) { + badgeData.text[1] = 'inaccessible'; + sendBadge(format, badgeData); + return; + } + try { + var data = JSON.parse(buffer); + var automated = data.is_automated; + badgeData.text[1] = automated; + if (automated) { + badgeData.colorscheme = 'blue'; + } else { + badgeData.colorscheme = 'yellow'; + } + badgeData.colorB = '#008bb8'; + sendBadge(format, badgeData); + } catch(e) { + badgeData.text[1] = 'invalid'; + sendBadge(format, badgeData); + } + }); +})); + // Twitter integration. camp.route(/^\/twitter\/url\/([^\/]+)\/(.+)\.(svg|png|gif|jpg|json)$/, cache(function(data, match, sendBadge, request) { diff --git a/try.html b/try.html index c68f09215c890..9ecd25f40682f 100644 --- a/try.html +++ b/try.html @@ -722,6 +722,10 @@

Miscellaneous

https://img.shields.io/docker/pulls/mashape/kong.svg + Docker Automated build + + https://img.shields.io/docker/automated/jrottenberg/ffmpeg.svg + ImageLayers Size: https://img.shields.io/imagelayers/image-size/_/ubuntu/latest.svg From e728f2395cb240613ca41aaf11870c31668df854 Mon Sep 17 00:00:00 2001 From: Julien Rottenberg Date: Tue, 29 Mar 2016 21:33:51 -0700 Subject: [PATCH 2/2] Clearer format for #661 --- server.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server.js b/server.js index 05570e9db6406..fbc0b85e3cb3d 100644 --- a/server.js +++ b/server.js @@ -4483,7 +4483,7 @@ cache(function(data, match, sendBadge, request) { } var path = user + '/' + repo; var url = 'https://registry.hub.docker.com/v2/repositories/' + path; - var badgeData = getBadgeData('automated build', data); + var badgeData = getBadgeData('docker build', data); request(url, function(err, res, buffer) { if (err != null) { badgeData.text[1] = 'inaccessible'; @@ -4492,11 +4492,12 @@ cache(function(data, match, sendBadge, request) { } try { var data = JSON.parse(buffer); - var automated = data.is_automated; - badgeData.text[1] = automated; - if (automated) { + var is_automated = data.is_automated; + if (is_automated) { + badgeData.text[1] = 'automated'; badgeData.colorscheme = 'blue'; } else { + badgeData.text[1] = 'manual'; badgeData.colorscheme = 'yellow'; } badgeData.colorB = '#008bb8';