Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
You can have it
Browse files Browse the repository at this point in the history
  • Loading branch information
mythmon committed Nov 14, 2013
1 parent 17a3a84 commit 6724502
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"undef": true,
"strict": false,
"browser": false,
"loopfunc": false,
"asi": false,
"eqeqeq": true,
"evil": false,
"mootools": false,
"shadow": false,
"unused": false,

"globals": {
"console": false,
"module": false,
"process": false,
"require": false,
"setImmediate": false,
"setInterval": false
}
}
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var core = require('./lib/core');
core.start();
20 changes: 20 additions & 0 deletions lib/core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var http = require('http');
var express = require('express');
var socketio = require('socket.io');

var config = require('./config');


var app = express();
app.set('port', config.web.port);

function start() {
var server = http.createServer(app);
server.listen(app.get('port'), function() {
console.log('Listening on https://0.0.0.0:{0}'.format(app.get('port')));
});
}

module.exports = {
start: start,
};
33 changes: 33 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Python new-style string formatting.
* > "Hello, {0}.".format('Mike');
* Hello, Mike.
* > "How is the weather in {citi}?".format({city: 'Mountain View'})
* How is the weather in Mountain View?
*/
String.prototype.format = function(obj) {
var args = arguments;
var str = this;
// Support either an object, or a series.
return str.replace(/\{[\w\d\._-]+\}/g, function(part) {
// Strip off {}.
part = part.slice(1, -1);
var index = parseInt(part, 10);
if (isNaN(index)) {
return dottedGet(obj, part);
} else {
return args[index];
}
});
};

function dottedGet(obj, selector) {
selector = selector.split('.');
while (selector.length) {
obj = obj[selector.splice(0, 1)[0]];
}
return obj;
}

module.exports = {

};

0 comments on commit 6724502

Please sign in to comment.