tidepool-org/tideline — pull request #4 by nicolashery (2014-02-17 16:15:53+00:00)
Title: Allow easier integration into a web app

A set of changes that should make it easier to consume Tideline in a web app.

The commits hopefully give some comprehensive breakdown of the changes, but here are the highlights:

**Dependencies from `window`**: Client-side dependencies are expected to be on the `window` object. The user of Tideline makes sure they are there (using Bower helps as `bower install https://github.com/tidepool-org/tideline` will put all dependencies in `bower_components/`). The problem with using `require('underscore')` for example, is that when we build a standalone `tideline.js` bundle it will package all of underscore in it. Since some tests are run in Node (no `window` object), I use the "importers" in `js/lib/` to first check for the `window` object.

**Dependencies in Bower**: For consistency, I put all of Tideline's direct dependencies in `bower.json`. Any testing or development dependency can go in `package.json` or in `bower.json`'s "devDependencies". Bower has a nice feature in the sense that it can consume any GitHub repo (with or without a `bower.json`), and use its tags for versions.

**Main entry point**: I created an `index.js` that exposes all of Tideline's smaller modules. It will be used to create a standalone bundle with browserify, `tideline.js`, that exposes a `window.tideline` object. (It can already be created by running `make dist`, and checked in the repo, but it isn't necessary to do it now we can wait till we have a tag-able stable version.)

**Configurable images base url**: The user of Tideline might choose to put the contents of `img/` some arbitrary place (in Blip, `build//images/tideline`). I added a `container.imagesBaseUrl(x)` method to set it, and it gets passed down to child `pool`, `tooltip`, `plot` objects. (Defaults to `img`)

**Use example to illustrate usage**: I changed the `example/` a bit to show more how you would "consume" Tideline in an app (include all dependencies, require the main entry point, etc.).

**Flesh out README**: Added some notes in README on how to install and use in an app, as well as how to contribute (installing dev dependencies, running the example, the tests, etc.)

@jebeck: Hope this helps and doesn't interfere with anything you're working on (I've rebased on `master` so should be all good to go). Feel free to look at this on your own time, and we can also chat if you have questions or want me to walk you through some things.

Thanks!