Skip to content

Commit

Permalink
[FEATURE] serve a badge for number of available achievements (#41)
Browse files Browse the repository at this point in the history
* serve a badge for number of available achievements

* add the badge to the readme
  • Loading branch information
thatkookooguy committed Jan 27, 2017
1 parent 89b8492 commit 95caf92
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
@@ -1,6 +1,8 @@
## achievibit
<img src="https://achievibit.herokuapp.com/images/favicon.png" width="150">
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=102)](https://github.com/ellerbrock/open-source-badge/)
[![Supported achievements](https://achievibit.herokuapp.com/achievementsBadge)

------
github hook system to integrate achievements for repositories

Expand Down
Binary file added Verdana.ttf
Binary file not shown.
18 changes: 18 additions & 0 deletions index.js
Expand Up @@ -13,6 +13,7 @@ var express = require('express'), // call express
cons = require('consolidate'),
moment = require('moment'),
_ = require('lodash'),
badge = require('gh-badges'),
nconf = require('nconf'),
ngrok = require('ngrok');

Expand All @@ -25,6 +26,13 @@ var url = nconf.get('databaseUrl');
var db = monk(url);
var app = express(); // define our app using express

var achievements = require('require-all')({
dirname : __dirname + '/achievements',
filter : /(.+achievement)\.js$/,
excludeDirs : /^\.(git|svn)$/,
recursive : true
});

// use scribe.js for logging
var console = require('./consoleService')('SERVER', ['magenta', 'inverse'], process.console);
var eventManager = require('./eventManager');
Expand Down Expand Up @@ -128,6 +136,16 @@ app.post('*', jsonParser, function(req, res) {
});
});

app.get('/achievementsBadge', function(req, res) {
badge.loadFont('./Verdana.ttf', function(err) {
badge({ text: ["achievements", _.keys(achievements).length], colorA: "#894597", colorB: "#5d5d5d", template: "flat" },
function(svg, err) {
res.setHeader('Content-Type', 'image/svg+xml;charset=utf-8');
res.send(svg);
});
});
});

app.get('/download/extension', function(req, res) {
var file = __dirname + '/public/achievibit-chrome-extension.crx';
res.download(file);
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -20,6 +20,8 @@
"compression": "^1.6.2",
"consolidate": "^0.14.1",
"express": "^4.14.0",
"gh-badges": "^1.3.0",
"gist-sync": "Thatkookooguy/gist-sync",
"githubhook": "^1.6.1",
"gulp": "^3.9.1",
"gulp-util": "^3.0.7",
Expand All @@ -40,7 +42,6 @@
"serve-favicon": "^2.3.0",
"socket.io": "^1.4.8",
"swig": "^1.4.2",
"tinycolor2": "^1.4.1",
"gist-sync": "Thatkookooguy/gist-sync"
"tinycolor2": "^1.4.1"
}
}

0 comments on commit 95caf92

Please sign in to comment.