1
0
mirror of https://github.com/badges/stability-badges.git synced 2025-04-19 04:02:16 +03:00

first commit

This commit is contained in:
Hugh Kennedy 2013-07-16 09:30:42 +10:00
commit 9543defac4
12 changed files with 320 additions and 0 deletions

18
LICENSE.md Normal file
View File

@ -0,0 +1,18 @@
This software is released under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

52
README.md Normal file
View File

@ -0,0 +1,52 @@
# stability-badges #
A set of SVG badges to mark your modules with the
[Node stability index](http://nodejs.org/api/documentation.html#documentation_stability_index).
### Stability: 0 - Deprecated ###
[![deprecated](https://raw.github.com/hughsk/stability-badges/master/dist/deprecated.svg)](http://nodejs.org/api/documentation.html#documentation_stability_index)
``` markdown
[![deprecated](https://raw.github.com/hughsk/stability-badges/master/dist/deprecated.svg)](http://nodejs.org/api/documentation.html#documentation_stability_index)
```
### Stability: 1 - Experimental ###
[![experimental](https://raw.github.com/hughsk/stability-badges/master/dist/experimental.svg)](http://nodejs.org/api/documentation.html#documentation_stability_index)
``` markdown
[![experimental](https://raw.github.com/hughsk/stability-badges/master/dist/experimental.svg)](http://nodejs.org/api/documentation.html#documentation_stability_index)
```
### Stability: 2 - Unstable ###
[![unstable](https://raw.github.com/hughsk/stability-badges/master/dist/unstable.svg)](http://nodejs.org/api/documentation.html#documentation_stability_index)
``` markdown
[![unstable](https://raw.github.com/hughsk/stability-badges/master/dist/unstable.svg)](http://nodejs.org/api/documentation.html#documentation_stability_index)
```
### Stability: 3 - Stable ###
[![stable](https://raw.github.com/hughsk/stability-badges/master/dist/stable.svg)](http://nodejs.org/api/documentation.html#documentation_stability_index)
``` markdown
[![stable](https://raw.github.com/hughsk/stability-badges/master/dist/stable.svg)](http://nodejs.org/api/documentation.html#documentation_stability_index)
```
### Stability: 4 - Frozen ###
[![frozen](https://raw.github.com/hughsk/stability-badges/master/dist/frozen.svg)](http://nodejs.org/api/documentation.html#documentation_stability_index)
``` markdown
[![frozen](https://raw.github.com/hughsk/stability-badges/master/dist/frozen.svg)](http://nodejs.org/api/documentation.html#documentation_stability_index)
```
### Stability: 5 - Locked ###
[![locked](https://raw.github.com/hughsk/stability-badges/master/dist/locked.svg)](http://nodejs.org/api/documentation.html#documentation_stability_index)
``` markdown
[![locked](https://raw.github.com/hughsk/stability-badges/master/dist/locked.svg)](http://nodejs.org/api/documentation.html#documentation_stability_index)
```

114
badge.js Normal file
View File

@ -0,0 +1,114 @@
module.exports = badge
function badge(label, category, options) {
options = options || {}
options.labelColor = options.labelColor || '#4B4B4B'
options.categoryColor = options.categoryColor || '#74C614'
options.width = options.width || 100
options.labelWidth = options.labelWidth || 35
var svg = ''
svg += el('rect', {
x: 0
, y: 2
, width: options.width
, height: 20
, style: {
fill: options.labelColor
, opacity: 0.3
}
})
svg += el('rect', {
x: 0
, y: 0
, width: options.width
, height: 20
, style: {
fill: options.labelColor
}
})
svg += el('rect', {
x: options.labelWidth
, y: 0
, width: options.width - options.labelWidth
, height: 20
, style: {
fill: options.categoryColor
}
})
svg += shadow(5, 10, label)
svg += shadow(options.labelWidth + 5, 10, category)
return svg
}
function el(el) {
var args = Array.prototype.slice.call(arguments, 1)
var str = '<' + el
args.filter(function(arg) {
return typeof arg !== 'string'
}).forEach(function(opts) {
Object.keys(opts).forEach(function(key) {
var value = opts[key]
if (Array.isArray(value)) value = value.join(' ')
if (typeof value === 'object') {
value = Object.keys(value).reduce(function(str, key) {
str += key
str += ':'
str += value[key]
str += ';'
return str
}, '')
}
str += ' '
str += key
str += '="'
str += String(value).replace(/\"/g, '\\"')
str += '"'
})
})
str += '>'
args.filter(function(arg) {
return typeof arg === 'string'
}).forEach(function(inner) {
str += inner
})
str += '</' + el + '>'
return str
}
function shadow(x, y, label) {
return el('text', label, {
x: x
, y: y + 1
, style: {
'alignment-baseline': 'middle'
, 'font-size': '10px'
, 'fill': '#000'
, 'opacity': '0.75'
, 'font-family': 'Arial, Helvetica, sans-serif'
}
}) + el('text', label, {
x: x
, y: y
, style: {
'alignment-baseline': 'middle'
, 'font-size': '10px'
, 'fill': '#fff'
, 'font-family': 'Arial, Helvetica, sans-serif'
}
})
}

8
dist/deprecated.svg vendored Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="120px"
height="25px"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
><rect x="0" y="2" width="110" height="20" style="fill:#4B4B4B;opacity:0.3;"></rect><rect x="0" y="0" width="110" height="20" style="fill:#4B4B4B;"></rect><rect x="45" y="0" width="65" height="20" style="fill:#C62914;"></rect><text x="5" y="11" style="alignment-baseline:middle;font-size:10px;fill:#000;opacity:0.75;font-family:Arial, Helvetica, sans-serif;">stability</text><text x="5" y="10" style="alignment-baseline:middle;font-size:10px;fill:#fff;font-family:Arial, Helvetica, sans-serif;">stability</text><text x="50" y="11" style="alignment-baseline:middle;font-size:10px;fill:#000;opacity:0.75;font-family:Arial, Helvetica, sans-serif;">deprecated</text><text x="50" y="10" style="alignment-baseline:middle;font-size:10px;fill:#fff;font-family:Arial, Helvetica, sans-serif;">deprecated</text>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

8
dist/experimental.svg vendored Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="120px"
height="25px"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
><rect x="0" y="2" width="117" height="20" style="fill:#4B4B4B;opacity:0.3;"></rect><rect x="0" y="0" width="117" height="20" style="fill:#4B4B4B;"></rect><rect x="45" y="0" width="72" height="20" style="fill:#DD5F0A;"></rect><text x="5" y="11" style="alignment-baseline:middle;font-size:10px;fill:#000;opacity:0.75;font-family:Arial, Helvetica, sans-serif;">stability</text><text x="5" y="10" style="alignment-baseline:middle;font-size:10px;fill:#fff;font-family:Arial, Helvetica, sans-serif;">stability</text><text x="50" y="11" style="alignment-baseline:middle;font-size:10px;fill:#000;opacity:0.75;font-family:Arial, Helvetica, sans-serif;">experimental</text><text x="50" y="10" style="alignment-baseline:middle;font-size:10px;fill:#fff;font-family:Arial, Helvetica, sans-serif;">experimental</text>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

8
dist/frozen.svg vendored Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="120px"
height="25px"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
><rect x="0" y="2" width="85" height="20" style="fill:#4B4B4B;opacity:0.3;"></rect><rect x="0" y="0" width="85" height="20" style="fill:#4B4B4B;"></rect><rect x="45" y="0" width="40" height="20" style="fill:#33C614;"></rect><text x="5" y="11" style="alignment-baseline:middle;font-size:10px;fill:#000;opacity:0.75;font-family:Arial, Helvetica, sans-serif;">stability</text><text x="5" y="10" style="alignment-baseline:middle;font-size:10px;fill:#fff;font-family:Arial, Helvetica, sans-serif;">stability</text><text x="50" y="11" style="alignment-baseline:middle;font-size:10px;fill:#000;opacity:0.75;font-family:Arial, Helvetica, sans-serif;">frozen</text><text x="50" y="10" style="alignment-baseline:middle;font-size:10px;fill:#fff;font-family:Arial, Helvetica, sans-serif;">frozen</text>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

8
dist/locked.svg vendored Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="120px"
height="25px"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
><rect x="0" y="2" width="85" height="20" style="fill:#4B4B4B;opacity:0.3;"></rect><rect x="0" y="0" width="85" height="20" style="fill:#4B4B4B;"></rect><rect x="45" y="0" width="40" height="20" style="fill:#14C6C6;"></rect><text x="5" y="11" style="alignment-baseline:middle;font-size:10px;fill:#000;opacity:0.75;font-family:Arial, Helvetica, sans-serif;">stability</text><text x="5" y="10" style="alignment-baseline:middle;font-size:10px;fill:#fff;font-family:Arial, Helvetica, sans-serif;">stability</text><text x="50" y="11" style="alignment-baseline:middle;font-size:10px;fill:#000;opacity:0.75;font-family:Arial, Helvetica, sans-serif;">locked</text><text x="50" y="10" style="alignment-baseline:middle;font-size:10px;fill:#fff;font-family:Arial, Helvetica, sans-serif;">locked</text>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

8
dist/stable.svg vendored Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="120px"
height="25px"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
><rect x="0" y="2" width="85" height="20" style="fill:#4B4B4B;opacity:0.3;"></rect><rect x="0" y="0" width="85" height="20" style="fill:#4B4B4B;"></rect><rect x="45" y="0" width="40" height="20" style="fill:#74C614;"></rect><text x="5" y="11" style="alignment-baseline:middle;font-size:10px;fill:#000;opacity:0.75;font-family:Arial, Helvetica, sans-serif;">stability</text><text x="5" y="10" style="alignment-baseline:middle;font-size:10px;fill:#fff;font-family:Arial, Helvetica, sans-serif;">stability</text><text x="50" y="11" style="alignment-baseline:middle;font-size:10px;fill:#000;opacity:0.75;font-family:Arial, Helvetica, sans-serif;">stable</text><text x="50" y="10" style="alignment-baseline:middle;font-size:10px;fill:#fff;font-family:Arial, Helvetica, sans-serif;">stable</text>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

8
dist/unstable.svg vendored Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="120px"
height="25px"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
><rect x="0" y="2" width="95" height="20" style="fill:#4B4B4B;opacity:0.3;"></rect><rect x="0" y="0" width="95" height="20" style="fill:#4B4B4B;"></rect><rect x="45" y="0" width="50" height="20" style="fill:#E5AE13;"></rect><text x="5" y="11" style="alignment-baseline:middle;font-size:10px;fill:#000;opacity:0.75;font-family:Arial, Helvetica, sans-serif;">stability</text><text x="5" y="10" style="alignment-baseline:middle;font-size:10px;fill:#fff;font-family:Arial, Helvetica, sans-serif;">stability</text><text x="50" y="11" style="alignment-baseline:middle;font-size:10px;fill:#000;opacity:0.75;font-family:Arial, Helvetica, sans-serif;">unstable</text><text x="50" y="10" style="alignment-baseline:middle;font-size:10px;fill:#fff;font-family:Arial, Helvetica, sans-serif;">unstable</text>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

25
generate.js Normal file
View File

@ -0,0 +1,25 @@
var badges = require('./')
var path = require('path')
var fs = require('fs')
var header = [
'<?xml version="1.0" encoding="utf-8" standalone="no"?>'
, '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'
, '<svg width="120px"'
, 'height="25px"'
// Note: you'll get invalid images if you don't
// use these attributes on the SVG element!
, 'xmlns="http://www.w3.org/2000/svg"'
, 'xmlns:xlink="http://www.w3.org/1999/xlink"'
, '>'
].join('\n')
var footer = '\n</svg>'
Object.keys(badges).forEach(function(name) {
var filename = __dirname + '/dist/' + name + '.svg'
var contents = header + badges[name] + footer
console.error('generated "' + path.relative(__dirname, filename) + '"')
fs.writeFileSync(filename, contents)
})

38
index.js Normal file
View File

@ -0,0 +1,38 @@
var badges = module.exports = {}
var badge = require('./badge')
badges.deprecated = badge('stability', 'deprecated', {
categoryColor: '#C62914'
, width: 110
, labelWidth: 45
})
badges.experimental = badge('stability', 'experimental', {
categoryColor: '#DD5F0A'
, width: 117
, labelWidth: 45
})
badges.unstable = badge('stability', 'unstable', {
categoryColor: '#E5AE13'
, width: 95
, labelWidth: 45
})
badges.stable = badge('stability', 'stable', {
categoryColor: '#74C614'
, width: 85
, labelWidth: 45
})
badges.frozen = badge('stability', 'frozen', {
categoryColor: '#33C614'
, width: 85
, labelWidth: 45
})
badges.locked = badge('stability', 'locked', {
categoryColor: '#14C6C6'
, width: 85
, labelWidth: 45
})

25
package.json Normal file
View File

@ -0,0 +1,25 @@
{
"name": "stability-badges",
"version": "0.0.0",
"description": "A set of SVG badges to mark your modules with the Node stability index",
"main": "index.js",
"devDependencies": {},
"scripts": {
"prepublish": "node generate.js"
},
"repository": {
"type": "git",
"url": "git://github.com/hughsk/stability-badges.git"
},
"keywords": [
"stability",
"badges",
"readme",
"image",
"svg",
"content"
],
"author": "Hugh Kennedy <hughskennedy@gmail.com> (http://hughskennedy.com/)",
"license": "MIT",
"readmeFilename": "README.md"
}