Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 79 lines (46 sloc) 2.66 kB
040d6e9 @maccman implement
authored
1 # Catapult
2
0a18a1b @maccman README
authored
3 Simple gem that gives pure JavaScript/CoffeeScript projects a basic structure, and manages any necessary compilation and concatenation.
4
5 Catapult is especially useful alongside MVC frameworks like [Spine](http://spinejs.com) and [Backbone](http://backbonejs.org).
040d6e9 @maccman implement
authored
6
7 ## Installation
8
b0248d5 @maccman use config.ru file if it exists
authored
9 $ gem install catapult
040d6e9 @maccman implement
authored
10
b0248d5 @maccman use config.ru file if it exists
authored
11 ## Usage
040d6e9 @maccman implement
authored
12
0a18a1b @maccman README
authored
13 To generate an app, use:
14
a86374d @maccman more docs
authored
15 $ catapult new myapp
16
17 create myapp
18 create myapp/assets/javascripts/app.js
19 create myapp/assets/stylesheets/app.css
20 create myapp/browser.json
21 create myapp/public/index.htm
22
23 $ cd myapp
24
25 You'll notice a bunch of files have been created. The convention in Catapult is that any assets under `assets/javascripts` and `assets/stylsheets` will be compiled under the static `public` directory. Your HTML files can reference them there.
040d6e9 @maccman implement
authored
26
b0248d5 @maccman use config.ru file if it exists
authored
27 Now you can start a catapult server:
040d6e9 @maccman implement
authored
28
a86374d @maccman more docs
authored
29 $ catapult server
30
31 And open up the app [in your browser](http://localhost:9292).
040d6e9 @maccman implement
authored
32
a86374d @maccman more docs
authored
33 You can also build the files for deployment:
040d6e9 @maccman implement
authored
34
a86374d @maccman more docs
authored
35 $ catapult build
b0248d5 @maccman use config.ru file if it exists
authored
36
37 Or watch the files for changes, and then automatically build:
040d6e9 @maccman implement
authored
38
a86374d @maccman more docs
authored
39 $ catapult watch
040d6e9 @maccman implement
authored
40
0a18a1b @maccman README
authored
41 ## Concatenation
42
43 Catapult uses [Sprockets](https://github.com/sstephenson/sprockets) for concatenation. Sprockets uses meta comments to specify dependencies. For example:
44
45 //= require jquery
46 //= require ./other_file
47 //= require_tree ./app
48
49 See the Sprockets documentation for more information.
50
51 ## Included compilers
52
53 Sprockets will automatically compile certain file types when the files are first requested. For example, files with `.coffee` extensions will be compiled down to JavaScript before being served up to the end user.
54
55 The included Sprockets compilers are: [CoffeeScript](http://coffeescript.org), [sprockets-commonjs](http://github.com/maccman/sprockets-commonjs) and [Stylus](http://learnboost.github.com/stylus/). You can include additional ones by simply adding them to your project's `Gemfile`.
56
57 ## Deploying to Heroku
58
59 It's a good idea to just serve up static files in production, and disable the asset compilation.
60
61 If you're using a system like Apache, you can just serve up the static files under the `./public` dir. Otherwise, with a [Rack](http://rack.github.com) based system, like [Heroku](http://heroku.com), you're going to need a few files:
62
63 Firstly, a `Gemfile`:
64
65 source 'https://rubygems.org'
66 gem 'catapult'
67
68 Then a `config.ru` file, serving up the static files:
69
70 require 'catapult'
71
72 use Catapult::TryStatic,
73 :root => Catapult.root.join('public'),
74 :urls => %w[/],
75 :try => ['.html', 'index.html', '/index.html']
040d6e9 @maccman implement
authored
76
0a18a1b @maccman README
authored
77 run lambda {|env|
78 [404, {}, ['Not found']]
79 }
Something went wrong with that request. Please try again.