In Ember, the application's state manager handles routing. Let's take a look at a simple example:
App.stateManager = Ember.StateManager.create({
start: Ember.State.extend({
index: Ember.State.extend({
route: "/",| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
| # |
| class ActionDispatch::Routing::Mapper | |
| def draw(routes_name) | |
| instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb"))) | |
| end | |
| end | |
| BCX::Application.routes.draw do | |
| draw :api | |
| draw :account | |
| draw :session |
| import SimpleHTTPServer | |
| class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
| def send_head(self): | |
| """Common code for GET and HEAD commands. | |
| This sends the response code and MIME headers. | |
| Return value is either a file object (which has to be copied | |
| to the outputfile by the caller unless the command was HEAD, | |
| and must be closed by the caller under all circumstances), or |
| # config/initializers/source_maps.rb | |
| if Rails.env.development? | |
| require 'open3' | |
| module CoffeeScript | |
| class SourceMapError < StandardError; end; | |
| class << self | |
| def map_dir |
I. Create a Middleman project with middleman-ember-template
$ middleman init hello --template=ember
II. Install ember.js package
$ bower install ember
| gifify() { | |
| if [[ -n "$1" ]]; then | |
| if [[ $2 == '--good' ]]; then | |
| ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png | |
| time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif | |
| rm out-static*.png | |
| else | |
| ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif | |
| fi | |
| else |
| // include this code in your application, you don't need to call any initialization manually! | |
| Ember.Application.initializer({ | |
| name: "meta", | |
| initialize: function(container, application) { | |
| // helper function to get tag from dom | |
| var _getTag = function(tagname, property, value) { | |
| var tags = document.head.getElementsByTagName(tagname), | |
| tag, |
| var empty, get, set, | |
| __hasProp = {}.hasOwnProperty; | |
| get = Ember.get; | |
| set = Ember.set; | |
| empty = function(obj) { | |
| var key; | |
| for (key in obj) { | |
| if (!__hasProp.call(obj, key)) continue; |
| (function (global) { | |
| "use strict"; | |
| function empty(obj) { | |
| var key; | |
| for (key in obj) if (obj.hasOwnProperty(key)) return false; | |
| return true; | |
| } | |
| var Ember = global.Ember, |