Code Monkey home page Code Monkey logo

spine.app's Introduction

##Introduction

Effortlessly generate Spine, CoffeeScript and Hem applications. Spine.App gives hooks your application up with some structure, CommonJS modules, and gives you some nice tools to help it grow.

##Usage

First step is to install the npm package. If you don't already have npm or NodeJS you'll need to install them first.

$ npm install -g spine.app

Then we can generate the initial application structure like this:

$ spine app my_app

Now we've produced a directory structure looking like:

my_app/.gitignore
my_app/.npmignore
my_app/Procfile
my_app/app
my_app/app/controllers
my_app/app/index.coffee
my_app/app/lib
my_app/app/lib/setup.coffee
my_app/app/models
my_app/app/views
my_app/app/views/sample.jade
my_app/css
my_app/css/index.styl
my_app/css/mixin.styl
my_app/lib
my_app/lib/jade_runtime.js
my_app/lib/jquery.js
my_app/package.json
my_app/public
my_app/public/favicon.ico
my_app/public/index.html
my_app/slug.coffee
my_app/test
my_app/test/specs

First let's navigate to our application, and install it's npm dependencies:

$ cd my_app
$ npm install .

These will be exported locally in the ./npm_modules folder. Now, let's install Hem, which will be in charge or bundling our application.

$ npm install -g hem

And to serve our application up:

$ hem server

This will boot up an server on port 9294. You can now start generating Spine controllers and models:

$ spine controller users
    app/controllers/users.coffee

$ spine model user
    app/models/user.coffee

Any application specific code should go in the app folder. Otherwise, generic code, should go in the lib folder.

Any CoffeeScript, Stylus, or Jade templates files inside the application will be automatically compiled when requested, you don't need to worry about compiling them manually. That is Hem's magic happening.

Hem will also bundle up all your JavaScript files, enclosing them in a CommonJS wrapper. This means that scripts in the app folder need to be CommonJS compliant (basically exactly like normal Node scripts). In other words, to use a module you'll need to require() it, and you'll need to explicitly export any global variables.

Guide = require("controllers/guide")

class App extends Spine.Controller
  elements:
    "#item": "item"

  init ->
    @guide = new Guide(el: @item)

# Explicitly export it
module.exports = App

Inside your HTML files, you need only require application.js and every module will be wrapped up and ready to be loaded. As you can see, the generated index.html kicks things off by instantiating app/app.coffee when the page loads.

var exports = this;
jQuery(function(){
  var App = require("app");
  exports.App = new App({el: $("#body")});
});

spine.app's People

Contributors

aeischeid avatar cayleyh avatar cengebretson avatar iammerrick avatar jiahut avatar kamal avatar maccman avatar mperham avatar richard-flosi avatar rjfranco avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.