Shields badge specification, website and default API server
Go to file
2014-02-19 13:46:27 +01:00
ass-stubs test: server PNG. 2014-01-19 13:32:43 +01:00
.buildpacks Node engine version information. Deployment files. 2014-01-03 19:25:49 +01:00
.gitignore Add SVGO to the pipeline 2014-01-02 18:25:34 +01:00
.travis.yml Travis: install cairo. 2014-01-29 08:31:07 +01:00
badge.js Using __dirname 2014-01-18 18:57:03 +01:00
colorscheme.json Better orange. 2014-01-06 15:28:05 +01:00
coverage.svg test: server PNG. 2014-01-19 13:32:43 +01:00
favicon.png Move website to the repo's root. 2014-02-14 16:54:09 +01:00
gh-badge.js cli: shebang. 2014-01-19 12:45:17 +01:00
index.html Separate vendors in categories. 2014-02-15 19:33:51 +01:00
LICENSE License file. 2014-02-01 10:16:22 +01:00
logo.svg Move website to the repo's root. 2014-02-14 16:54:09 +01:00
Makefile Omit old files. 2014-02-19 13:46:27 +01:00
package.json Include the readme in NPM. 2014-01-19 13:50:15 +01:00
phantomjs-svg2png.js Local font loading into SVG in Phantom.js 2014-01-05 22:02:02 +01:00
README.md Explain try.html in Readme. 2014-02-15 19:36:42 +01:00
server.js Make localhost:1337/index.html work for testing. 2014-02-14 17:27:57 +01:00
svg-to-img.js website: favicon. 2014-01-17 15:31:29 +01:00
template.svg Font size increase. 2014-01-14 11:37:40 +01:00
test.js Fix writing the coverage page. 2014-02-14 18:02:26 +01:00
try.html try.html for testing, index.html generated. 2014-02-15 22:42:25 +01:00

GitHub badges in SVG format

npm version

coverage

build status

Make your own badges here!

Install the API

npm install gh-badges
var badge = require('gh-badges');
badge({ text: [ "build", "passed" ], colorscheme: "green" },
  function(svg) {
    // svg is a String… of your badge.
  });

Use the CLI

npm install -g gh-badges
badge build passed :green .png > mybadge.png
# Stored a PNG version of your badge on disk.

Set the Server

git clone git@github.com:badges/gh-badges
cd gh-badges
npm install
sudo npm start

The root gets redirected to http://shields.io. For testing purposes, you can go to http://localhost/try.html. You should modify that file. The "real" root, http://localhost/index.html, gets generated from the try.html file.

Format

The format is the following:

{
  /* Textual information shown, in order. */
  "text": [ "build", "passed" ],
  "colorscheme": "green"
  /* … Or… */
  "colorA": "#555",
  "colorB": "#4c1"
}

Defaults

If you want to add a default badge, you only need to modify default-badges.json. The format is the same as that given to the API.

If you want to add a colorscheme, head to colorscheme.json. Each scheme has a name and a CSS/SVG color for the color used in the first box (for the first piece of text, field colorA) and for the one used in the second box (field colorB).

"green": {
  "colorB": "#4c1"
}

Both colorA and colorB have default values. Usually, the first box uses the same dark grey, so you can rely on that default value by not providing a "colorA" field (such as above).

You can also use the "colorA" and "colorB" fields directly in the badges if you don't want to make a color scheme for it. In that case, remove the "colorscheme" field altogether.

Requirements

Because of the usage of the npm module canvas you need to have cairo installed.

For more information check the wiki of the canvas project with system-specific installation details.

Making your Heroku badge server

Once you have installed the Heroku Toolbelt:

heroku login
heroku create your-app-name
heroku config:set BUILDPACK_URL=https://github.com/mojodna/heroku-buildpack-multi.git#build-env
cp /path/to/Verdana.ttf .
make deploy
heroku open

Links

See https://github.com/h5bp/lazyweb-requests/issues/150 for a story of the project's inception.

This is also available as a gem badgerbadgerbadger, code here.

License

All work here is licensed CC0.