Add AUR integration.
Add badge for the Arch User Repository (AUR). Includes badges to display the current version, number of votes, and license. Unfortunately, their API does not display downloads at this stage. Signed-off-by: JP-Ellis <josh@jpellis.me>
This commit is contained in:
parent
1e24e2624d
commit
40471a137e
42
server.js
42
server.js
|
@ -4957,7 +4957,49 @@ cache(function(data, match, sendBadge, request) {
|
||||||
badgeData.colorscheme = null;
|
badgeData.colorscheme = null;
|
||||||
badgeData.colorB = '#' + (color || '78bdf2');
|
badgeData.colorB = '#' + (color || '78bdf2');
|
||||||
sendBadge(format, badgeData);
|
sendBadge(format, badgeData);
|
||||||
|
} catch(e) {
|
||||||
|
badgeData.text[1] = 'invalid';
|
||||||
|
sendBadge(format, badgeData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Arch user repository (AUR) integration.
|
||||||
|
camp.route(/^\/aur\/(version|votes|license)\/(.*)\.(svg|png|gif|jpg|json)$/,
|
||||||
|
cache(function(data, match, sendBadge, request) {
|
||||||
|
var info = match[1];
|
||||||
|
var pkg = match[2];
|
||||||
|
var format = match[3];
|
||||||
|
var apiUrl = 'https://aur.archlinux.org/rpc.php?type=info&arg=' + pkg;
|
||||||
|
var badgeData = getBadgeData('AUR', data);
|
||||||
|
request(apiUrl, function(err, res, buffer) {
|
||||||
|
if (err != null) {
|
||||||
|
badgeData.text[1] = 'inaccessible';
|
||||||
|
sendBadge(format, badgeData);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var data = JSON.parse(buffer).results;
|
||||||
|
if (info === 'version') {
|
||||||
|
var vdata = versionColor(data.Version);
|
||||||
|
badgeData.text[1] = vdata.version;
|
||||||
|
if (data.OutOfDate === null) {
|
||||||
|
badgeData.colorscheme = 'blue';
|
||||||
|
} else {
|
||||||
|
badgeData.colorscheme = 'orange';
|
||||||
|
}
|
||||||
|
} else if (info === 'votes') {
|
||||||
|
var votes = data.NumVotes;
|
||||||
|
badgeData.text[0] = "votes";
|
||||||
|
badgeData.text[1] = votes;
|
||||||
|
badgeData.colorscheme = floorCountColor(votes, 2, 20, 60);
|
||||||
|
} else if (info === 'license') {
|
||||||
|
var license = data.License;
|
||||||
|
badgeData.text[0] = "license";
|
||||||
|
badgeData.text[1] = license;
|
||||||
|
badgeData.colorscheme = 'blue';
|
||||||
|
}
|
||||||
|
sendBadge(format, badgeData);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
badgeData.text[1] = 'invalid';
|
badgeData.text[1] = 'invalid';
|
||||||
sendBadge(format, badgeData);
|
sendBadge(format, badgeData);
|
||||||
|
|
11
try.html
11
try.html
|
@ -514,6 +514,10 @@ Pixel-perfect Retina-ready Fast Consistent Hackable
|
||||||
<td><img src='/dub/v/vibe-d.svg' alt=''/></td>
|
<td><img src='/dub/v/vibe-d.svg' alt=''/></td>
|
||||||
<td><code>https://img.shields.io/dub/v/vibe-d.svg</code></td>
|
<td><code>https://img.shields.io/dub/v/vibe-d.svg</code></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr><th data-keywords='aur'> AUR: </th>
|
||||||
|
<td><img src='/aur/version/yaourt.svg' alt=''/></td>
|
||||||
|
<td><code>https://img.shields.io/aur/version/yaourt.svg</code></td>
|
||||||
|
</tr>
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
|
|
||||||
<h3 id="social"> Social </h3>
|
<h3 id="social"> Social </h3>
|
||||||
|
@ -542,6 +546,10 @@ Pixel-perfect Retina-ready Fast Consistent Hackable
|
||||||
<td><img src='/twitter/follow/shields_io.svg?style=social' alt=''/></td>
|
<td><img src='/twitter/follow/shields_io.svg?style=social' alt=''/></td>
|
||||||
<td><code>https://img.shields.io/twitter/follow/shields_io.svg?style=social</code></td>
|
<td><code>https://img.shields.io/twitter/follow/shields_io.svg?style=social</code></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr><th data-keywords='aur'> AUR: </th>
|
||||||
|
<td><img src='/aur/votes/yaourt.svg' alt=''/></td>
|
||||||
|
<td><code>https://img.shields.io/aur/votes/yaourt.svg</code></td>
|
||||||
|
</tr>
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
|
|
||||||
<h3 id="miscellaneous"> Miscellaneous </h3>
|
<h3 id="miscellaneous"> Miscellaneous </h3>
|
||||||
|
@ -749,6 +757,9 @@ Pixel-perfect Retina-ready Fast Consistent Hackable
|
||||||
<tr><th> Maintenance: </th>
|
<tr><th> Maintenance: </th>
|
||||||
<td><img src='/maintenance/yes/2016.svg' alt=''/></td>
|
<td><img src='/maintenance/yes/2016.svg' alt=''/></td>
|
||||||
<td><code>https://img.shields.io/maintenance/yes/2016.svg</code></td>
|
<td><code>https://img.shields.io/maintenance/yes/2016.svg</code></td>
|
||||||
|
<tr><th data-keywords='aur'> AUR: </th>
|
||||||
|
<td><img src='/aur/license/yaourt.svg' alt=''/></td>
|
||||||
|
<td><code>https://img.shields.io/aur/license/yaourt.svg</code></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><th> Waffle.io: </th>
|
<tr><th> Waffle.io: </th>
|
||||||
<td><img src='/waffle/label/evancohen/smart-mirror/in%20progress.svg' alt=''/></td>
|
<td><img src='/waffle/label/evancohen/smart-mirror/in%20progress.svg' alt=''/></td>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user