TryGhost/Ghost — pull request #1521 by hswolff (2013-11-20 04:05:23+00:00)
Title: Ghost as a module, fixes #1326

This PR allows you to `require('ghost')` as an npm_module and instantiate it yourself. It does not allow you to pass in a config object, that will require a separate PR (and require #1390 to land first, so the location of our files can be relative to the file instantiating ghost). This is the first step towards getting to the ultimate goal of allowing ghost to be used as a module, one that I think is a good step towards that ultimate goal.

This works from a separate file where you can do this:

```
var ghost = require('ghost');
ghost();
```

or

```
var ghost = require('ghost'),
express = require('express');
ghost(express());
```

This is mostly accomplished by changing `./core/server` to have it's functionality enclosed in functions, instead of having them execute as soon as the module is included elsewhere.

It also requires two different code paths:
1. When ghost is ran from the CLI it delegates to the `./index.js` file to start the ghost app.
2. When ghost is ran as a npm module from a seperate file, it leverages `package.json`'s `main` property to dictate what file is included.

This is also built on top of my previous #1444, so that needs to be merged before this one can.

Sorry for the size of the PR, hope it's manageable enough to get merged. Let me know how I can speed along the process (assuming this is the way we want to go).