• This repository has been archived on 15/Oct/2019
  • Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
    JavaScript
  • Created over 12 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Removing the boilerplate from starting single page apps.

Backbone Stack (0.3.4)

A pre-configured Backbone Stack for starting new projects, it alleviates a lot of the common boilerplate code and setup. It uses AMD modules, mocha for TDD and handlebars precompiled templates. Grunt plays a major role in the automated linting, testing and building of your code.

Build Status Dependency Status

View the changelog

Included libraries

  • Grunt - A task runner like Make, used to watch and compile the JS code
  • Require JS - To asynchronously load in all of the scripts and templates
  • Almond - To run the built AMD code in production
  • Backbone JS - for MVC JavaScript
  • jQuery - For DOM manipulation and ajax
  • Handlebars JS - for templating
  • Twitter Bootstrap - For a quick and dirty UI prototype

Libraries for Test Driven Development

  • Mocha - TDD / BDD testing framework for JavaScript
  • Chai.js - Nice assertions
  • Sinon - Spies, Stubs and Mocks

Setup

Installing dependencies

Bower is used as for package management, the default client-side dependencies are listed in the bower.json file.

Note you will need node.js and npm and phantomJS for headless unit tests.

# Install bower package manager
$ npm install -g bower

# Install grunt build tool
$ npm install -g grunt-cli

# Install additional grunt tasks
$ npm install

# Install client-side packages
$ bower install

Installing new dependencies - Bower documentation

# Search for a library
$ bower search [name..]

# Install a library and save it to the bower.json file
$ bower install [name..] --save

Getting started

Running your app

Open up the ./index.html file in your browser to view your app, it will be using pre-compiled templates and build and minified JS.

Testing your code

The unit tests can be opened up in the browser with the test/test-runner.html file, or can be done through grunt on the command line.

The idea behind linting first, then testing and then building is to fail as quickly and early as possible, this will really help to boost productivity.

# Watch src/ and test/ files and lint, test, then build on change (handy for TDD)
$ grunt watch

# Lint and test files
$ grunt test

Note the test suite loads requireJS dynamically and you don't need to build to run the tests, this lets you do TDD with less effort.

Building your code

All of the JavaScript is pre-build using grunt and the r.js optimiser, this means your development environment better simulates what will be served in production. Your built CSS and JS are then version and your index.html file is automatically updated with the versioned filename.

# Watch src/ and test/ files and test, then build on change
$ grunt watch

# Do a one off build - will lint and test your code first
$ grunt build

# Compile the handlebars templates
$ grunt handlebars

# Compile less and css styles
$ grunt styles

git pre-commit hook

Simply run these commands inside your project dir to set a commit hook that will run before each commit. If any of the test or build phase fails the commit will not be accepted.

# Create a pre-commit hook
$ touch .git/hooks/pre-commit
# Make executable
$ chmod +x .git/hooks/pre-commit
# Build on commit
$ echo "grunt test" > .git/hooks/pre-commit

Contributors

  • Pete Hawkins - github.com/phawk
  • Miguel Andrade - github.com/miguelcobain

MIT License

Copyright (C) 2013 Pete Hawkins

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

rails-deploy

Ansible scripts to setup a fully loaded ruby/rails web server
Shell
50
star
2

happi

Happi makes email customer support a joy to use!
Ruby
50
star
3

youtube-rails-starter

Ruby
38
star
4

simple-error-pages

Basic error templates for 400, 404, 422 and 500 errors
HTML
29
star
5

dalli-ui

A web UI for Dalli
Ruby
18
star
6

fuel-oauth-provider

Oauth Server package for Fuel PHP.
PHP
8
star
7

coinfusion

Ruby
8
star
8

sinatra-minitest

Basic setup of Sinatra and minitest::spec
Ruby
8
star
9

meetups-map

Displays nearby developer meetups
Ruby
7
star
10

tdd-backbone-mocha

An example repo for a tutorial on TDD – http://phawk.co.uk/articles/testing-backbone-with-mocha
JavaScript
7
star
11

ruby_open_ai

Ruby
6
star
12

php-Contact-Form

A small contact form library for php.
PHP
5
star
13

hotwire-demo

Ruby
4
star
14

action-cable-online-status

YouTube episode demonstrating how to show which users are online using action cable
Ruby
4
star
15

Stackio

Basic stack overflow iOS application
Objective-C
3
star
16

tweeter

Ruby
3
star
17

sinatra-api

Simple starting point for making REST APIs in sinatra
JavaScript
3
star
18

ansible-server-setup

VCL
2
star
19

jQuery-Autotabs

autotabs technique for jquery
JavaScript
2
star
20

cap-git-tags

Auto tags staging deploys, deploys last staging tag to production with a tag
Ruby
2
star
21

ng-list

Sample angular app integration with the Dropbox datastore API
JavaScript
2
star
22

rapid_stripe_checkout

Ruby
2
star
23

baseless

Simple css styles for type, lists and forms.
2
star
24

tailwind-combo-box

Ruby
2
star
25

Backbone-Dropdown

Simple dropdown component for Backbone.js
JavaScript
2
star
26

Google-Maps-JS-Library

A simple google maps library to help make 1 off or simple maps easier and faster.
JavaScript
2
star
27

hotwire-sortable-js

Using Sortable.js with Hotwire
Ruby
2
star
28

rapid-ruby-starter

The starter template that I use for creating my YouTube content
Ruby
1
star
29

rapid_tagging_posts

Ruby
1
star
30

view_component_tutorial

Ruby
1
star
31

show-qrcode

JavaScript
1
star
32

js-rect-example

A tutorial on architecture on my blog. http://phawk.co.uk
JavaScript
1
star
33

laravel4-db-profiler

Simple DB profiler script that ouputs all queries to the bottom of your page.
JavaScript
1
star
34

Backbone-Panels

A basic Backbone panel manager.
JavaScript
1
star
35

Compound-Calculator

A basic mac app that will calculate monthly compound interest
Objective-C
1
star
36

rapid_yaml_data_store

Ruby
1
star
37

rapid_auth_zero_demo

Ruby
1
star
38

administration_zero

Ruby
1
star
39

tdd-node-mocha

JavaScript
1
star
40

s3bkp

Shell script to backup your server and upload to an amazon S3 bucket
Shell
1
star