Skip to content

Commit

Permalink
Merge pull request #103 from xiongbo/master
Browse files Browse the repository at this point in the history
finished 410
  • Loading branch information
hlee committed Aug 27, 2013
2 parents d19dda8 + 3c86fb9 commit 20172a0
Show file tree
Hide file tree
Showing 84 changed files with 1,123 additions and 0 deletions.
16 changes: 16 additions & 0 deletions xiongbo/410-ember-part2/booking/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
46 changes: 46 additions & 0 deletions xiongbo/410-ember-part2/booking/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
source 'http://ruby.taobao.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
gem 'ember-rails'

group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]
138 changes: 138 additions & 0 deletions xiongbo/410-ember-part2/booking/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
GEM
remote: http://ruby.taobao.org/
specs:
actionmailer (4.0.0)
actionpack (= 4.0.0)
mail (~> 2.5.3)
actionpack (4.0.0)
activesupport (= 4.0.0)
builder (~> 3.1.0)
erubis (~> 2.7.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
active_model_serializers (0.8.1)
activemodel (>= 3.0)
activemodel (4.0.0)
activesupport (= 4.0.0)
builder (~> 3.1.0)
activerecord (4.0.0)
activemodel (= 4.0.0)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.0)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.0)
i18n (~> 0.6, >= 0.6.4)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
arel (4.0.0)
atomic (1.1.13)
barber (0.4.2)
ember-source
execjs
handlebars-source
builder (3.1.4)
coffee-rails (4.0.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0.beta, < 5.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.6.3)
ember-data-source (0.13)
ember-source
ember-rails (0.12.0)
active_model_serializers
barber (>= 0.4.1)
ember-data-source
ember-source (>= 1.0.0.rc2.2)
execjs (>= 1.2)
railties (>= 3.1)
ember-source (1.0.0.rc7)
handlebars-source (= 1.0.12)
erubis (2.7.0)
execjs (2.0.0)
handlebars-source (1.0.12)
hike (1.2.3)
i18n (0.6.5)
jbuilder (1.5.1)
activesupport (>= 3.0.0)
multi_json (>= 1.2.0)
jquery-rails (3.0.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.0)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.24)
minitest (4.7.5)
multi_json (1.7.9)
polyglot (0.3.3)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rails (4.0.0)
actionmailer (= 4.0.0)
actionpack (= 4.0.0)
activerecord (= 4.0.0)
activesupport (= 4.0.0)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.0)
sprockets-rails (~> 2.0.0)
railties (4.0.0)
actionpack (= 4.0.0)
activesupport (= 4.0.0)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.1.0)
rdoc (3.12.2)
json (~> 1.4)
sass (3.2.10)
sass-rails (4.0.0)
railties (>= 4.0.0.beta, < 5.0)
sass (>= 3.1.10)
sprockets-rails (~> 2.0.0)
sdoc (0.3.20)
json (>= 1.1.3)
rdoc (~> 3.10)
sprockets (2.10.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.8)
thor (0.18.1)
thread_safe (0.1.2)
atomic
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
turbolinks (1.3.0)
coffee-rails
tzinfo (0.3.37)
uglifier (2.1.2)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)

PLATFORMS
ruby

DEPENDENCIES
coffee-rails (~> 4.0.0)
ember-rails
jbuilder (~> 1.2)
jquery-rails
rails (= 4.0.0)
sass-rails (~> 4.0.0)
sdoc
sqlite3
turbolinks
uglifier (>= 1.3.0)
28 changes: 28 additions & 0 deletions xiongbo/410-ember-part2/booking/README.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
== README

This README would normally document whatever steps are necessary to get the
application up and running.

Things you may want to cover:

* Ruby version

* System dependencies

* Configuration

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...


Please feel free to use a different markup language if you do not plan to run
<tt>rake doc:app</tt>.
6 changes: 6 additions & 0 deletions xiongbo/410-ember-part2/booking/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Booking::Application.load_tasks
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require handlebars
//= require ember
//= require ember-data
//= require_self
//= require booking
Booking = Ember.Application.create();
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#= require ./store
#= require_tree ./models
#= require_tree ./controllers
#= require_tree ./views
#= require_tree ./helpers
#= require_tree ./templates
#= require_tree ./routes
#= require ./router
#= require_self
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Booking.ApplicationController = Ember.Controller.extend()
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Booking.BooksController = Ember.ArrayController.extend
addBook: (name)->
Booking.Book.createRecord name: name
@get('store').commit()
@set('newBookName', "")

booking: ->
@setEach('highlight', false)
pool = @rejectProperty('booked')
if pool.length > 0
book = pool[Math.floor(Math.random()*pool.length)]
book.set('booked', true)
book.set('highlight', true)
@get('store').commit()

allBooked: (->
@everyProperty('booked')
).property('@each.booked')
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Booking.Book = DS.Model.extend
name: DS.attr('string')
booked: DS.attr('boolean')
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Booking.Router.map (match)->
@route 'books', path: '/'

Booking.BooksRoute = Ember.Route.extend
model: -> Booking.Book.find()
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Booking.Store = DS.Store.extend
revision: 4
adapter: DS.RESTAdapter.create()

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div id="container">
<h1>Booking</h1>
{{outlet}}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{view Booking.NewBookView}}

<ul>
{{#each controller}}
<li>
{{ name }}
{{#if booked}}
<span {{bindAttr class="booked highlight"}}>Already Booked</span>
{{/if}}
</li>
{{/each}}
</ul>
<button {{action booking}} {{bindAttr disabled="allBooked"}}>Booking</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{view Ember.TextField valueBinding="view.newBookName"}}
<input type="submit" value="Add" />
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Booking.BookView = Ember.View.extend
templateName: 'book'
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Booking.BooksView = Ember.View.extend
templateName: 'books'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Booking.NewBookView = Ember.View.extend
templateName: 'new_book'
tagName: 'form'

submit: ->
@get('controller').send('addBook', @get('newBookName'))
false
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
Loading

0 comments on commit 20172a0

Please sign in to comment.