conoremclaughlin / bones-boiler

Testing sets of Bones tools to make life easier for the impatient.
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

bones-boiler

A boilerplate of tools, examples, and tweaks to Bones to make getting started easier, Bones apps more flexible, and life less annoying for those that want to get started right away. The Bones project was created by the brilliant guys at Development Seed. It is a group of conventions for sharing code between a node.js server and a Backbone client for hopefully faster development.

One of the strengths of Backbone and Bones is flexibility. They do not try to enforce too much opinion on how you should build your application. This is wonderful for ubiquitous use of a library. But if you're like me and thirst for opinion or inspiration - if it annoys you to wade through stuff not directly related to your core product - then this library may be for you. Fork it, tear it apart, paint it green, whatever.

Beware: most of this code was just abstracted from a couple different projects, so it's a little rough around the edges :( I love issues so please make them.

Features

Model API

Assets

Backends

Rendering and Templating

Publishing and Commands

Utilities

Jekyll/Yaml Integration

Miscellaneous

Libraries

Pushing bones-boiler to be additive, so just remove the dependencies and features of whatever you don't need.

Getting Started

  1. Read Development Seed's documentation on Bones and check out the simple app example under examples.
  2. Install and launch mongodb.
  3. Retrieve project.
    • Fork, clone, modify.
    • Or add as a dependency and add to your application's index.js file require('bones-boiler') after require('bones')
  4. Modify or override options in commands/Config.bones.js with your specific MongoDB instance information
    • Default localhost:27017/bb
  5. Run npm install
  6. From the bones-boiler directory, run:
    rm -rf node_modules/bones/node_modules/backbone node_modules/bones/node_modules/jquery node_modules/bones/node_modules/mirror

    to delete bones' backbone, jquery, and mirror dependency folders so bones-boiler can use its own versions.

  7. Run node ./index.js

Testing

Requires mocha. See dev-dependencies in package.json. Run npm test from bones-boiler root.

How To Use

Bones

Some tips beyond the original documentation.

Models, views, routers, templates, servers, and commands folders each hold the core .bones.js files. These files are then wrapped with .prefix.js and .suffix.js before they are executed on either the client or server. Bones chooses what .prefix.js and *.suffix.js files are used to wrap the core files depending on where the code will be executed. If it's the server, node.js requires can be seen in the prefix file while client's will hold the beginning of a closure. This is how Bones provides conventions for declaration:

model.prefix.js

...
var model;
MyModel.bones.js

model = new Bones.Backbone.Model({});

Otherwise you are just building a Backbone application on the client and building an Express application on the server (with some Backbone code mixed in).

Bones-Boiler

Client/Shared/Server Philosophy

There seem to be three primary schools of thought concerning node.js and sharing Javascript code between the client and server:

I personally subscribe to the third philosophy. I believe the client/shared/server architecture Bones uses is incredibly powerful. Identifying areas of shared functionality and structure, and then building independent client and server components from that foundation, creates a single core that can be quickly understood while maintaining flexibility.

Examples of shared functionality or structure:

Examples of not shared:

By making use of shared code and using Backbone models as data models between the server and client, a server implementation does not have to tie itself to a single ORM for data modeling. However, certain components contain functionality irrelevant to the server. Backbone views used to only render a model leave a heavy memory footprint, for example.

This project tries to walk the fine line of shared functionality or structure. Hopefully this way, those coming from express can easily understand the server and quickly grasp some Backbone concepts, while those coming from Backbone can easily understand the client and quickly grasp some Express concepts.

Credits

Development Seed

Wiredcraft

@makara

License

Same as bones. BSD licensed.