Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 185d018ecd6eec3453b6032222d4be24010b9a56 0 parents
@jduff jduff authored
Showing with 6,859 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +4 −0 Gemfile
  3. +73 −0 README.md
  4. +1 −0  Rakefile
  5. +26 −0 batman-rails.gemspec
  6. +1 −0  lib/batman-rails.rb
  7. +6 −0 lib/batman/rails.rb
  8. +6 −0 lib/batman/rails/engine.rb
  9. +6 −0 lib/batman/rails/version.rb
  10. +45 −0 lib/generators/batman/common.rb
  11. +33 −0 lib/generators/batman/controller_generator.rb
  12. +14 −0 lib/generators/batman/helper_generator.rb
  13. +49 −0 lib/generators/batman/install_generator.rb
  14. +29 −0 lib/generators/batman/model_generator.rb
  15. +19 −0 lib/generators/batman/scaffold_generator.rb
  16. +25 −0 lib/generators/batman/templates/batman_app.coffee
  17. +5 −0 lib/generators/batman/templates/controller.coffee
  18. +5 −0 lib/generators/batman/templates/helper.coffee
  19. +7 −0 lib/generators/batman/templates/model.coffee
  20. +40 −0 test/controller_generator_test.rb
  21. +9 −0 test/fixtures/application.js
  22. +82 −0 test/install_generator_test.rb
  23. +44 −0 test/model_generator_test.rb
  24. +5 −0 test/sample/.gitignore
  25. +30 −0 test/sample/Gemfile
  26. +261 −0 test/sample/README
  27. +7 −0 test/sample/Rakefile
  28. BIN  test/sample/app/assets/images/rails.png
  29. +9 −0 test/sample/app/assets/javascripts/application.js
  30. +7 −0 test/sample/app/assets/stylesheets/application.css
  31. +3 −0  test/sample/app/controllers/application_controller.rb
  32. +2 −0  test/sample/app/helpers/application_helper.rb
  33. 0  test/sample/app/mailers/.gitkeep
  34. 0  test/sample/app/models/.gitkeep
  35. +14 −0 test/sample/app/views/layouts/application.html.erb
  36. +4 −0 test/sample/config.ru
  37. +48 −0 test/sample/config/application.rb
  38. +6 −0 test/sample/config/boot.rb
  39. +25 −0 test/sample/config/database.yml
  40. +5 −0 test/sample/config/environment.rb
  41. +30 −0 test/sample/config/environments/development.rb
  42. +60 −0 test/sample/config/environments/production.rb
  43. +42 −0 test/sample/config/environments/test.rb
  44. +7 −0 test/sample/config/initializers/backtrace_silencers.rb
  45. +10 −0 test/sample/config/initializers/inflections.rb
  46. +5 −0 test/sample/config/initializers/mime_types.rb
  47. +7 −0 test/sample/config/initializers/secret_token.rb
  48. +8 −0 test/sample/config/initializers/session_store.rb
  49. +14 −0 test/sample/config/initializers/wrap_parameters.rb
  50. +5 −0 test/sample/config/locales/en.yml
  51. +58 −0 test/sample/config/routes.rb
  52. +7 −0 test/sample/db/seeds.rb
  53. +2 −0  test/sample/doc/README_FOR_APP
  54. 0  test/sample/lib/assets/.gitkeep
  55. 0  test/sample/lib/tasks/.gitkeep
  56. 0  test/sample/log/.gitkeep
  57. +26 −0 test/sample/public/404.html
  58. +26 −0 test/sample/public/422.html
  59. +26 −0 test/sample/public/500.html
  60. 0  test/sample/public/favicon.ico
  61. +241 −0 test/sample/public/index.html
  62. +5 −0 test/sample/public/robots.txt
  63. +6 −0 test/sample/script/rails
  64. 0  test/sample/test/fixtures/.gitkeep
  65. 0  test/sample/test/functional/.gitkeep
  66. 0  test/sample/test/integration/.gitkeep
  67. +12 −0 test/sample/test/performance/browsing_test.rb
  68. +13 −0 test/sample/test/test_helper.rb
  69. 0  test/sample/test/unit/.gitkeep
  70. 0  test/sample/vendor/assets/stylesheets/.gitkeep
  71. 0  test/sample/vendor/plugins/.gitkeep
  72. +24 −0 test/test_helper.rb
  73. +3 −0  tmp/app/assets/javascripts/controllers/regular_users_controller.js.coffee
  74. +73 −0 vendor/assets/javascripts/batman/batman.jquery.js
  75. +4,717 −0 vendor/assets/javascripts/batman/batman.js
  76. +58 −0 vendor/assets/javascripts/batman/batman.rails.js
  77. +415 −0 vendor/assets/javascripts/batman/batman.solo.js
4 .gitignore
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
4 Gemfile
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in batman-rails.gemspec
+gemspec
73 README.md
@@ -0,0 +1,73 @@
+# Batman-Rails
+
+Easily setup and use batman.js (0.6.0) with rails 3.1
+
+## Rails 3.1 setup
+This gem requires the use of rails 3.1, coffeescript and the new rails asset pipeline provided by sprockets.
+
+This gem vendors the latest version of batman.js for Rails 3.1 and greater. The files will be added to the asset pipeline and available for you to use.
+
+### Installation
+
+In your Gemfile, add this line:
+
+ gem "batman-rails"
+
+Then run the following commands:
+
+ bundle install
+ rails g batman:install
+
+### Layout and namespacing
+
+Running `rails g batman:install` will create the following directory structure under `app/assets/javascripts/`:
+
+ controllers/
+ models/
+ helpers/
+
+It will also create a toplevel app_name.coffee file to setup namespacing and setup initial requires.
+
+## Generators
+batman-rails provides 3 simple generators to help get you started using batman.js with rails 3.1.
+The generators will only create client side code (javascript).
+
+### Model Generator
+
+ rails g batman:model
+
+This generator creates a batman model and collection inside `app/assets/javascript/models` to be used to talk to the rails backend.
+
+### Controllers
+
+ rails g batman:controller
+
+This generator creates a batman controller for the given actions provided.
+
+### Scaffolding
+
+ rails g batman:scaffold
+
+This generator creates a controller, helper and mode to create a simple crud single page app
+
+## Example Usage
+
+Created a new rails 3.1 application called `blog`.
+
+ rails new blog
+
+Edit your Gemfile and add
+
+ gem 'batman-rails'
+
+Install the gem and generate scaffolding.
+
+ bundle install
+ rails g batman:install
+ rails g scaffold Post title:string content:string
+ rake db:migrate
+ rails g batman:scaffold Post title:string content:string
+
+You now have installed the batman-rails gem, setup a default directory structure for your frontend batman code.
+Then you generated the usual rails server side crud scaffolding and finally generated batman.js code to provide a simple single page crud app.
+You have one last step:
1  Rakefile
@@ -0,0 +1 @@
+require 'bundler/gem_tasks'
26 batman-rails.gemspec
@@ -0,0 +1,26 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "batman/rails/version"
+
+Gem::Specification.new do |s|
+ s.name = "batman-rails"
+ s.version = Batman::Rails::VERSION
+ s.authors = ["John Duff"]
+ s.email = ["john.duff@jadedpixel.com"]
+ s.homepage = ""
+ s.summary = %q{}
+ s.description = %q{}
+
+ s.rubyforge_project = "batman-rails"
+
+ s.add_dependency "railties", "~> 3.1.0"
+ s.add_dependency "thor", "~> 0.14"
+ s.add_development_dependency "bundler", "~> 1.0.0"
+ s.add_development_dependency "rails", "~> 3.1.0"
+ s.add_development_dependency "mocha"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+end
1  lib/batman-rails.rb
@@ -0,0 +1 @@
+require "batman/rails"
6 lib/batman/rails.rb
@@ -0,0 +1,6 @@
+require "batman/rails/version"
+require "batman/rails/engine"
+module Batman
+ module Rails
+ end
+end
6 lib/batman/rails/engine.rb
@@ -0,0 +1,6 @@
+module Batman
+ module Rails
+ class Engine < ::Rails::Engine
+ end
+ end
+end
6 lib/batman/rails/version.rb
@@ -0,0 +1,6 @@
+module Batman
+ module Rails
+ VERSION = "0.0.1"
+ BATMAN_VERSION = "0.6.0"
+ end
+end
45 lib/generators/batman/common.rb
@@ -0,0 +1,45 @@
+module Batman
+ module Generators
+ module Common
+ def self.included(base)
+ base.send(:extend, ClassMethods)
+ base.source_root File.expand_path("../templates", __FILE__)
+ end
+
+ protected
+ def with_app_name
+ raise "Batman application name must be given" unless app_name
+ yield
+ end
+
+ def js_app_name
+ app_name.camelize
+ end
+
+ def app_name
+ @app_name ||= options[:app_name] || application_name
+ end
+
+ def application_name
+ if defined?(::Rails) && ::Rails.application
+ ::Rails.application.class.name.split('::').first.underscore
+ end
+ end
+
+ def js_path
+ "app/assets/javascripts"
+ end
+
+ def singular_model_name
+ singular_name.camelize
+ end
+
+ module ClassMethods
+ def requires_app_name
+ class_option :app_name, :type => :string, :optional => true,
+ :desc => "Name of the Batman app (defaults to the Rails app name"
+ end
+ end
+ end
+ end
+end
33 lib/generators/batman/controller_generator.rb
@@ -0,0 +1,33 @@
+require 'generators/batman/common'
+module Batman
+ module Generators
+ class ControllerGenerator < ::Rails::Generators::NamedBase
+ include Common
+ requires_app_name
+
+ desc "This generator creates a Batman controller"
+ argument :actions, :type => :array, :default => [], :banner => "action action"
+
+
+ RESERVED_JS_WORDS = %w{
+ break case catch continue debugger default delete do else finally for
+ function if in instanceof new return switch this throw try typeof var void while with
+ }
+
+ def validate_no_reserved_words
+ actions.each do |action|
+ if RESERVED_JS_WORDS.include? action
+ raise Thor::Error, "The name '#{action}' is reserved by javascript " <<
+ "Please choose an alternative action name and run this generator again."
+ end
+ end
+ end
+
+ def create_batman_controller
+ with_app_name do
+ template "controller.coffee", "#{js_path}/controllers/#{plural_name.downcase}_controller.js.coffee"
+ end
+ end
+ end
+ end
+end
14 lib/generators/batman/helper_generator.rb
@@ -0,0 +1,14 @@
+require 'generators/batman/common'
+module Batman
+ module Generators
+ class HelperGenerator < ::Rails::Generators::NamedBase
+ include Common
+
+ desc "This generator creates a Batman helper"
+
+ def create_batman_helper
+ template "helper.coffee", "#{js_path}/helpers/#{plural_name.downcase}_helper.js.coffee"
+ end
+ end
+ end
+end
49 lib/generators/batman/install_generator.rb
@@ -0,0 +1,49 @@
+require 'generators/batman/common'
+module Batman
+ module Generators
+ class InstallGenerator < ::Rails::Generators::Base
+ include Common
+ requires_app_name
+
+ desc "This generator installs Batman.js with a default folder layout"
+
+ class_option :skip_git, :type => :boolean, :aliases => "-G", :default => false,
+ :desc => "Skip Git ignores and keeps"
+
+ def create_batman_app
+ with_app_name do
+ template "batman_app.coffee", "#{js_path}/#{app_name}.js.coffee"
+ end
+ end
+
+ def create_directories
+ %w(models controllers helpers).each do |dir|
+ empty_directory "#{js_path}/#{dir}"
+ create_file "#{js_path}/#{dir}/.gitkeep" unless options[:skip_git]
+ end
+ end
+
+ def inject_batman
+ with_app_name do
+ inject_into_file "#{js_path}/application.js", :after=>/\/\/=(?!.*\/\/=).*?$/m do
+<<-CODE
+\n\n//= require batman/batman
+//= require batman/batman.jquery
+//= require batman/batman.rails
+
+//= require #{app_name}
+
+//= require_tree ./models
+//= require_tree ./controllers
+//= require_tree ./helpers
+
+$(document).ready(function(){
+ #{js_app_name}.run();
+});
+CODE
+ end
+ end
+ end
+ end
+ end
+end
29 lib/generators/batman/model_generator.rb
@@ -0,0 +1,29 @@
+require 'generators/batman/common'
+module Batman
+ module Generators
+ class ModelGenerator < ::Rails::Generators::NamedBase
+ include Common
+ requires_app_name
+
+ desc "This generator creates a Batman model"
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
+
+ def create_batman_model
+ with_app_name do
+ template "model.coffee", "#{js_path}/models/#{file_name.downcase}.js.coffee"
+ end
+ end
+
+ protected
+ def render_attribute(attribute)
+ type = case attribute.type.to_s
+ when 'date', 'datetime'
+ "Batman.Encoders.railsDate"
+ when 'string', 'integer', 'float', 'decimal', 'boolean', 'text'
+ end
+
+ ["'#{attribute.name}'", type].compact.join(', ')
+ end
+ end
+ end
+end
19 lib/generators/batman/scaffold_generator.rb
@@ -0,0 +1,19 @@
+require 'generators/batman/common'
+module Batman
+ module Generators
+ class ScaffoldGenerator < ::Rails::Generators::NamedBase
+ include Common
+ requires_app_name
+
+ desc "This generator creates the client side CRUD scaffolding"
+
+ def create_batman_model
+ with_app_name do
+ generate "batman:model #{singular_model_name} --app_name #{app_name}"
+ generate "batman:controller #{singular_model_name} index show create update destroy --app_name #{app_name}"
+ generate "batman:helper #{singular_model_name}"
+ end
+ end
+ end
+ end
+end
25 lib/generators/batman/templates/batman_app.coffee
@@ -0,0 +1,25 @@
+window.<%= js_app_name %> = class <%= js_app_name %> extends Batman.App
+
+ # @root 'controller#all'
+ # @route '/controller/:id', 'controller#show', resource: 'model', action: 'show'
+
+ @run ->
+ console.log "Running..."
+ true
+
+ @ready ->
+ console.log "<%= js_app_name %> ready for use."
+
+ @flash: Batman()
+ @flash.accessor
+ get: (key) -> @[key]
+ set: (key, value) ->
+ @[key] = value
+ if value isnt ''
+ setTimeout =>
+ @set(key, '')
+ , 2000
+ value
+
+ @flashSuccess: (message) -> @set 'flash.success', message
+ @flashError: (message) -> @set 'flash.error', message
5 lib/generators/batman/templates/controller.coffee
@@ -0,0 +1,5 @@
+class <%= js_app_name %>.<%= plural_name.camelize %>Controller extends Batman.Controller
+<% actions.each do |action| -%>
+ <%= action %>: (params) ->
+
+<% end -%>
5 lib/generators/batman/templates/helper.coffee
@@ -0,0 +1,5 @@
+# <%= plural_name.camelize %> helper file
+
+# Batman.mixin Batman.Filters,
+# helper: (input) ->
+# return input
7 lib/generators/batman/templates/model.coffee
@@ -0,0 +1,7 @@
+class <%= js_app_name %>.<%= singular_model_name %> extends Batman.Model
+ @storageKey: '<%= plural_name %>'
+ @persist Batman.RailsStorage
+
+<% attributes.each do |attribute| -%>
+ @encode <%= render_attribute(attribute) %>
+<% end -%>
40 test/controller_generator_test.rb
@@ -0,0 +1,40 @@
+require 'test_helper'
+require 'generators/batman/controller_generator'
+
+class ControllerGeneratorTest < Rails::Generators::TestCase
+ tests Batman::Generators::ControllerGenerator
+
+ test "simple controller" do
+ run_generator %w(Task index show)
+
+ assert_file "#{javascripts_path}/controllers/tasks_controller.js.coffee" do |controller|
+ controller_class = Regexp.escape("class Sample.TasksController extends Batman.Controller")
+
+ assert_match /#{controller_class}/, controller
+ assert_match %r{ index: \(params\) ->}, controller
+ assert_match %r{ show: \(params\) ->}, controller
+ end
+ end
+
+ test "two word controller is camelcased" do
+ run_generator %w(RegularUser index)
+
+ assert_file "#{javascripts_path}/controllers/regular_users_controller.js.coffee" do |controller|
+ controller_class = Regexp.escape("class Sample.RegularUsersController extends Batman.Controller")
+
+ assert_match /#{controller_class}/, controller
+ assert_match %r{ index: \(params\) ->}, controller
+ end
+ end
+
+ test "simple controller with app_name" do
+ run_generator %w(Task index --app_name MyApp)
+
+ assert_file "#{javascripts_path}/controllers/tasks_controller.js.coffee" do |controller|
+ controller_class = Regexp.escape("class MyApp.TasksController extends Batman.Controller")
+
+ assert_match /#{controller_class}/, controller
+ assert_match %r{ index: \(params\) ->}, controller
+ end
+ end
+end
9 test/fixtures/application.js
@@ -0,0 +1,9 @@
+// This is a manifest file that'll be compiled into including all the files listed below.
+// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
+// be included in the compiled file accessible from http://example.com/assets/application.js
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+//= require jquery
+//= require jquery_ujs
+//= require_tree .
82 test/install_generator_test.rb
@@ -0,0 +1,82 @@
+require 'mocha'
+require 'test_helper'
+require 'generators/batman/install_generator'
+
+class InstallGeneratorTest < Rails::Generators::TestCase
+ tests Batman::Generators::InstallGenerator
+
+ def setup
+ mkdir_p "#{destination_root}/app/assets/javascripts"
+ cp fixture("application.js"), "#{destination_root}/app/assets/javascripts"
+ Rails.application.class.stubs(:name).returns("Dummy::Application")
+
+ super
+ end
+
+ test "Assert Batman application file is created" do
+ run_generator
+
+ assert_file "#{javascripts_path}/dummy.js.coffee" do |app|
+ assert_match /window\.Dummy = class Dummy extends Batman\.App/, app
+ assert_match /@run ->/, app
+ end
+ end
+
+ test "Assert Batman application file is created for two word application name" do
+ Rails.application.class.stubs(:name).returns("FooBar::Application")
+ run_generator
+
+ assert_file "#{javascripts_path}/foo_bar.js.coffee" do |app|
+ assert_match /window\.FooBar = class FooBar extends Batman\.App/, app
+ end
+ end
+
+ test "Assert application require is properly setup for two word application name" do
+ Rails.application.class.stubs(:name).returns("FooBar::Application")
+ run_generator
+
+ assert_file "#{javascripts_path}/application.js", /require foo_bar/
+ end
+
+ test "Assert Batman directory structure is created" do
+ run_generator
+
+ %W{controllers models helpers}.each do |dir|
+ assert_directory "#{javascripts_path}/#{dir}"
+ assert_file "#{javascripts_path}/#{dir}/.gitkeep"
+ end
+ end
+
+ test "Assert no gitkeep files are created when skipping git" do
+ run_generator [destination_root, "--skip-git"]
+
+ %W{controllers models helpers}.each do |dir|
+ assert_directory "#{javascripts_path}/#{dir}"
+ assert_no_file "#{javascripts_path}/#{dir}/.gitkeep"
+ end
+ end
+
+ test "Assert application.js require batman, batman.jquery, batman.rails and dummy.js" do
+ run_generator
+
+ assert_file "#{javascripts_path}/application.js" do |app|
+ %W{batman batman.jquery batman.rails}.each do |require|
+ assert_match /require batman\/#{require}/, app
+ end
+
+ assert_match /require dummy/, app
+
+ %W{models controllers helpers}.each do |require|
+ assert_match /require_tree \.\/#{require}/, app
+ end
+
+ assert_match /Dummy\.run\(\)/, app
+ end
+ end
+
+ private
+
+ def fixture(file)
+ File.expand_path("fixtures/#{file}", File.dirname(__FILE__))
+ end
+end
44 test/model_generator_test.rb
@@ -0,0 +1,44 @@
+require 'test_helper'
+require 'generators/batman/model_generator'
+
+class ModelGeneratorTest < Rails::Generators::TestCase
+ tests Batman::Generators::ModelGenerator
+
+ test "simple model" do
+ run_generator %w(Task title:string created_at:date)
+
+ assert_file "#{javascripts_path}/models/task.js.coffee" do |model|
+ model_class = Regexp.escape("class Sample.Task extends Batman.Model")
+
+ assert_match /#{model_class}/, model
+
+ assert_match /@storageKey: 'tasks'/, model
+ assert_match /@persist Batman.RailsStorage/, model
+
+ assert_match /@encode 'title'/, model
+ assert_match /@encode 'created_at', Batman.Encoders.railsDate/, model
+ end
+ end
+
+ test "two word model is camelcased" do
+ run_generator %w(RegularUser name:string)
+
+ assert_file "#{javascripts_path}/models/regular_user.js.coffee" do |model|
+ model_class = Regexp.escape("class Sample.RegularUser extends Batman.Model")
+
+ assert_match /#{model_class}/, model
+
+ assert_match /@storageKey: 'regular_users'/, model
+ end
+ end
+
+ test "simple model with app_name" do
+ run_generator %w(Task title:string created_at:date --app_name MyApp)
+
+ assert_file "#{javascripts_path}/models/task.js.coffee" do |model|
+ model_class = Regexp.escape("class MyApp.Task extends Batman.Model")
+
+ assert_match /#{model_class}/, model
+ end
+ end
+end
5 test/sample/.gitignore
@@ -0,0 +1,5 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/
+.sass-cache/
30 test/sample/Gemfile
@@ -0,0 +1,30 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.1.0'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'sqlite3'
+
+gem 'json'
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', " ~> 3.1.0"
+ gem 'coffee-rails', "~> 3.1.0"
+ gem 'uglifier'
+end
+
+gem 'jquery-rails'
+
+# Use unicorn as the web server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# To use debugger
+# gem 'ruby-debug'
+
261 test/sample/README
@@ -0,0 +1,261 @@
+== Welcome to Rails
+
+Rails is a web-application framework that includes everything needed to create
+database-backed web applications according to the Model-View-Control pattern.
+
+This pattern splits the view (also called the presentation) into "dumb"
+templates that are primarily responsible for inserting pre-built data in between
+HTML tags. The model contains the "smart" domain objects (such as Account,
+Product, Person, Post) that holds all the business logic and knows how to
+persist themselves to a database. The controller handles the incoming requests
+(such as Save New Account, Update Product, Show Post) by manipulating the model
+and directing data to the view.
+
+In Rails, the model is handled by what's called an object-relational mapping
+layer entitled Active Record. This layer allows you to present the data from
+database rows as objects and embellish these data objects with business logic
+methods. You can read more about Active Record in
+link:files/vendor/rails/activerecord/README.html.
+
+The controller and view are handled by the Action Pack, which handles both
+layers by its two parts: Action View and Action Controller. These two layers
+are bundled in a single package due to their heavy interdependence. This is
+unlike the relationship between the Active Record and Action Pack that is much
+more separate. Each of these packages can be used independently outside of
+Rails. You can read more about Action Pack in
+link:files/vendor/rails/actionpack/README.html.
+
+
+== Getting Started
+
+1. At the command prompt, create a new Rails application:
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
+
+2. Change directory to <tt>myapp</tt> and start the web server:
+ <tt>cd myapp; rails server</tt> (run with --help for options)
+
+3. Go to http://localhost:3000/ and you'll see:
+ "Welcome aboard: You're riding Ruby on Rails!"
+
+4. Follow the guidelines to start developing your application. You can find
+the following resources handy:
+
+* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
+* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
+
+
+== Debugging Rails
+
+Sometimes your application goes wrong. Fortunately there are a lot of tools that
+will help you debug it and get it back on the rails.
+
+First area to check is the application log files. Have "tail -f" commands
+running on the server.log and development.log. Rails will automatically display
+debugging and runtime information to these files. Debugging info will also be
+shown in the browser on requests from 127.0.0.1.
+
+You can also log your own messages directly into the log file from your code
+using the Ruby logger class from inside your controllers. Example:
+
+ class WeblogController < ActionController::Base
+ def destroy
+ @weblog = Weblog.find(params[:id])
+ @weblog.destroy
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
+ end
+ end
+
+The result will be a message in your log file along the lines of:
+
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
+
+More information on how to use the logger is at http://www.ruby-doc.org/core/
+
+Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
+several books available online as well:
+
+* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
+* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
+
+These two books will bring you up to speed on the Ruby language and also on
+programming in general.
+
+
+== Debugger
+
+Debugger support is available through the debugger command when you start your
+Mongrel or WEBrick server with --debugger. This means that you can break out of
+execution at any point in the code, investigate and change the model, and then,
+resume execution! You need to install ruby-debug to run the server in debugging
+mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
+
+ class WeblogController < ActionController::Base
+ def index
+ @posts = Post.all
+ debugger
+ end
+ end
+
+So the controller will accept the action, run the first line, then present you
+with a IRB prompt in the server window. Here you can do things like:
+
+ >> @posts.inspect
+ => "[#<Post:0x14a6be8
+ @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
+ #<Post:0x14a6620
+ @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
+ >> @posts.first.title = "hello from a debugger"
+ => "hello from a debugger"
+
+...and even better, you can examine how your runtime objects actually work:
+
+ >> f = @posts.first
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
+ >> f.
+ Display all 152 possibilities? (y or n)
+
+Finally, when you're ready to resume execution, you can enter "cont".
+
+
+== Console
+
+The console is a Ruby shell, which allows you to interact with your
+application's domain model. Here you'll have all parts of the application
+configured, just like it is when the application is running. You can inspect
+domain models, change values, and save to the database. Starting the script
+without arguments will launch it in the development environment.
+
+To start the console, run <tt>rails console</tt> from the application
+directory.
+
+Options:
+
+* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
+ made to the database.
+* Passing an environment name as an argument will load the corresponding
+ environment. Example: <tt>rails console production</tt>.
+
+To reload your controllers and models after launching the console run
+<tt>reload!</tt>
+
+More information about irb can be found at:
+link:http://www.rubycentral.org/pickaxe/irb.html
+
+
+== dbconsole
+
+You can go to the command line of your database directly through <tt>rails
+dbconsole</tt>. You would be connected to the database with the credentials
+defined in database.yml. Starting the script without arguments will connect you
+to the development database. Passing an argument will connect you to a different
+database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
+PostgreSQL and SQLite 3.
+
+== Description of Contents
+
+The default directory structure of a generated Ruby on Rails application:
+
+ |-- app
+ | |-- assets
+ | |-- images
+ | |-- javascripts
+ | `-- stylesheets
+ | |-- controllers
+ | |-- helpers
+ | |-- mailers
+ | |-- models
+ | `-- views
+ | `-- layouts
+ |-- config
+ | |-- environments
+ | |-- initializers
+ | `-- locales
+ |-- db
+ |-- doc
+ |-- lib
+ | `-- tasks
+ |-- log
+ |-- public
+ |-- script
+ |-- test
+ | |-- fixtures
+ | |-- functional
+ | |-- integration
+ | |-- performance
+ | `-- unit
+ |-- tmp
+ | |-- cache
+ | |-- pids
+ | |-- sessions
+ | `-- sockets
+ `-- vendor
+ |-- assets
+ `-- stylesheets
+ `-- plugins
+
+app
+ Holds all the code that's specific to this particular application.
+
+app/assets
+ Contains subdirectories for images, stylesheets, and JavaScript files.
+
+app/controllers
+ Holds controllers that should be named like weblogs_controller.rb for
+ automated URL mapping. All controllers should descend from
+ ApplicationController which itself descends from ActionController::Base.
+
+app/models
+ Holds models that should be named like post.rb. Models descend from
+ ActiveRecord::Base by default.
+
+app/views
+ Holds the template files for the view that should be named like
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
+ eRuby syntax by default.
+
+app/views/layouts
+ Holds the template files for layouts to be used with views. This models the
+ common header/footer method of wrapping views. In your views, define a layout
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
+ Inside default.html.erb, call <% yield %> to render the view using this
+ layout.
+
+app/helpers
+ Holds view helpers that should be named like weblogs_helper.rb. These are
+ generated for you automatically when using generators for controllers.
+ Helpers can be used to wrap functionality for your views into methods.
+
+config
+ Configuration files for the Rails environment, the routing map, the database,
+ and other dependencies.
+
+db
+ Contains the database schema in schema.rb. db/migrate contains all the
+ sequence of Migrations for your schema.
+
+doc
+ This directory is where your application documentation will be stored when
+ generated using <tt>rake doc:app</tt>
+
+lib
+ Application specific libraries. Basically, any kind of custom code that
+ doesn't belong under controllers, models, or helpers. This directory is in
+ the load path.
+
+public
+ The directory available for the web server. Also contains the dispatchers and the
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
+ server.
+
+script
+ Helper scripts for automation and generation.
+
+test
+ Unit and functional tests along with fixtures. When using the rails generate
+ command, template test files will be generated for you and placed in this
+ directory.
+
+vendor
+ External libraries that the application depends on. Also includes the plugins
+ subdirectory. If the app has frozen rails, those gems also go here, under
+ vendor/rails/. This directory is in the load path.
7 test/sample/Rakefile
@@ -0,0 +1,7 @@
+#!/usr/bin/env rake
+# 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__)
+
+Sample::Application.load_tasks
BIN  test/sample/app/assets/images/rails.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 test/sample/app/assets/javascripts/application.js
@@ -0,0 +1,9 @@
+// This is a manifest file that'll be compiled into including all the files listed below.
+// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
+// be included in the compiled file accessible from http://example.com/assets/application.js
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+//= require jquery
+//= require jquery_ujs
+//= require_tree .
7 test/sample/app/assets/stylesheets/application.css
@@ -0,0 +1,7 @@
+/*
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
+ * and any sub-directories. 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 .
+*/
3  test/sample/app/controllers/application_controller.rb
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
2  test/sample/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
0  test/sample/app/mailers/.gitkeep
No changes.
0  test/sample/app/models/.gitkeep
No changes.
14 test/sample/app/views/layouts/application.html.erb
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Sample</title>
+ <%= stylesheet_link_tag "application" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tags %>
+</head>
+<body>
+
+<%= yield %>
+
+</body>
+</html>
4 test/sample/config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Sample::Application
48 test/sample/config/application.rb
@@ -0,0 +1,48 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+if defined?(Bundler)
+ # If you precompile assets before deploying to production, use this line
+ Bundler.require *Rails.groups(:assets => %w(development test))
+ # If you want your assets lazily compiled in production, use this line
+ # Bundler.require(:default, :assets, Rails.env)
+end
+
+module Sample
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:password]
+
+ # Enable the asset pipeline
+ config.assets.enabled = true
+
+ # Version of your assets, change this if you want to expire all your assets
+ config.assets.version = '1.0'
+ end
+end
6 test/sample/config/boot.rb
@@ -0,0 +1,6 @@
+require 'rubygems'
+
+# Set up gems listed in the Gemfile.
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+
+require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
25 test/sample/config/database.yml
@@ -0,0 +1,25 @@
+# SQLite version 3.x
+# gem install sqlite3
+#
+# Ensure the SQLite 3 gem is defined in your Gemfile
+# gem 'sqlite3'
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
5 test/sample/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the rails application
+require File.expand_path('../application', __FILE__)
+
+# Initialize the rails application
+Sample::Application.initialize!
30 test/sample/config/environments/development.rb
@@ -0,0 +1,30 @@
+Sample::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
+
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Don't care if the mailer can't send
+ config.action_mailer.raise_delivery_errors = false
+
+ # Print deprecation notices to the Rails logger
+ config.active_support.deprecation = :log
+
+ # Only use best-standards-support built into browsers
+ config.action_dispatch.best_standards_support = :builtin
+
+ # Do not compress assets
+ config.assets.compress = false
+
+ # Expands the lines which load the assets
+ config.assets.debug = true
+end
60 test/sample/config/environments/production.rb
@@ -0,0 +1,60 @@
+Sample::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # Code is not reloaded between requests
+ config.cache_classes = true
+
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Disable Rails's static asset server (Apache or nginx will already do this)
+ config.serve_static_assets = false
+
+ # Compress JavaScripts and CSS
+ config.assets.compress = true
+
+ # Don't fallback to assets pipeline if a precompiled asset is missed
+ config.assets.compile = false
+
+ # Generate digests for assets URLs
+ config.assets.digest = true
+
+ # Defaults to Rails.root.join("public/assets")
+ # config.assets.manifest = YOUR_PATH
+
+ # Specifies the header that your server uses for sending files
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # See everything in the log (default is :info)
+ # config.log_level = :debug
+
+ # Use a different logger for distributed setups
+ # config.logger = SyslogLogger.new
+
+ # Use a different cache store in production
+ # config.cache_store = :mem_cache_store
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
+ # config.action_controller.asset_host = "http://assets.example.com"
+
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
+ # config.assets.precompile += %w( search.js )
+
+ # Disable delivery errors, bad email addresses will be ignored
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable threaded mode
+ # config.threadsafe!
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation can not be found)
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners
+ config.active_support.deprecation = :notify
+end
42 test/sample/config/environments/test.rb
@@ -0,0 +1,42 @@
+Sample::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
+
+ # Configure static asset server for tests with Cache-Control for performance
+ config.serve_static_assets = true
+ config.static_cache_control = "public, max-age=3600"
+
+ # Log error messages when you accidentally call methods on nil
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+
+ # Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
+ config.assets.allow_debugging = true
+end
7 test/sample/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
10 test/sample/config/initializers/inflections.rb
@@ -0,0 +1,10 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format
+# (all these examples are active by default):
+# ActiveSupport::Inflector.inflections do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
5 test/sample/config/initializers/mime_types.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
+# Mime::Type.register_alias "text/html", :iphone
7 test/sample/config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+Sample::Application.config.secret_token = 'd99a3616e0e024b85f627f569863e8056b1b060f510a07e28efd6b46a3031b7bf61da8926619beb99bf80c6337a1c897fafe2116dbc7b1b1c8f84071fd14d657'
8 test/sample/config/initializers/session_store.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+Sample::Application.config.session_store :cookie_store, :key => '_sample_session'
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rails generate session_migration")
+# Sample::Application.config.session_store :active_record_store
14 test/sample/config/initializers/wrap_parameters.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters :format => [:json]
+end
+
+# Disable root element in JSON by default.
+ActiveSupport.on_load(:active_record) do
+ self.include_root_in_json = false
+end
5 test/sample/config/locales/en.yml
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
58 test/sample/config/routes.rb
@@ -0,0 +1,58 @@
+Sample::Application.routes.draw do
+ # The priority is based upon order of creation:
+ # first created -> highest priority.
+
+ # Sample of regular route:
+ # match 'products/:id' => 'catalog#view'
+ # Keep in mind you can assign values other than :controller and :action
+
+ # Sample of named route:
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
+ # This route can be invoked with purchase_url(:id => product.id)
+
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
+ # resources :products
+
+ # Sample resource route with options:
+ # resources :products do
+ # member do
+ # get 'short'
+ # post 'toggle'
+ # end
+ #
+ # collection do
+ # get 'sold'
+ # end
+ # end
+
+ # Sample resource route with sub-resources:
+ # resources :products do
+ # resources :comments, :sales
+ # resource :seller
+ # end
+
+ # Sample resource route with more complex sub-resources
+ # resources :products do
+ # resources :comments
+ # resources :sales do
+ # get 'recent', :on => :collection
+ # end
+ # end
+
+ # Sample resource route within a namespace:
+ # namespace :admin do
+ # # Directs /admin/products/* to Admin::ProductsController
+ # # (app/controllers/admin/products_controller.rb)
+ # resources :products
+ # end
+
+ # You can have the root of your site routed with "root"
+ # just remember to delete public/index.html.
+ # root :to => 'welcome#index'
+
+ # See how all your routes lay out with "rake routes"
+
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
+ # Note: This route will make all actions in every controller accessible via GET requests.
+ # match ':controller(/:action(/:id(.:format)))'
+end
7 test/sample/db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
+# Mayor.create(:name => 'Emanuel', :city => cities.first)
2  test/sample/doc/README_FOR_APP
@@ -0,0 +1,2 @@
+Use this README file to introduce your application and point to useful places in the API for learning more.
+Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
0  test/sample/lib/assets/.gitkeep
No changes.
0  test/sample/lib/tasks/.gitkeep
No changes.
0  test/sample/log/.gitkeep
No changes.
26 test/sample/public/404.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>The page you were looking for doesn't exist (404)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/404.html -->
+ <div class="dialog">
+ <h1>The page you were looking for doesn't exist.</h1>
+ <p>You may have mistyped the address or the page may have moved.</p>
+ </div>
+</body>
+</html>
26 test/sample/public/422.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>The change you wanted was rejected (422)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/422.html -->
+ <div class="dialog">
+ <h1>The change you wanted was rejected.</h1>
+ <p>Maybe you tried to change something you didn't have access to.</p>
+ </div>
+</body>
+</html>
26 test/sample/public/500.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>We're sorry, but something went wrong (500)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/500.html -->
+ <div class="dialog">
+ <h1>We're sorry, but something went wrong.</h1>
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
+ </div>
+</body>
+</html>
0  test/sample/public/favicon.ico
No changes.
241 test/sample/public/index.html
@@ -0,0 +1,241 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Ruby on Rails: Welcome aboard</title>
+ <style type="text/css" media="screen">
+ body {
+ margin: 0;
+ margin-bottom: 25px;
+ padding: 0;
+ background-color: #f0f0f0;
+ font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
+ font-size: 13px;
+ color: #333;
+ }
+
+ h1 {
+ font-size: 28px;
+ color: #000;
+ }
+
+ a {color: #03c}
+ a:hover {
+ background-color: #03c;
+ color: white;
+ text-decoration: none;
+ }
+
+
+ #page {
+ background-color: #f0f0f0;
+ width: 750px;
+ margin: 0;
+ margin-left: auto;
+ margin-right: auto;
+ }
+
+ #content {
+ float: left;
+ background-color: white;
+ border: 3px solid #aaa;
+ border-top: none;
+ padding: 25px;
+ width: 500px;
+ }
+
+ #sidebar {
+ float: right;
+ width: 175px;
+ }
+
+ #footer {
+ clear: both;
+ }
+
+ #header, #about, #getting-started {
+ padding-left: 75px;
+ padding-right: 30px;
+ }
+
+
+ #header {
+ background-image: url("/assets/rails.png");
+ background-repeat: no-repeat;
+ background-position: top left;
+ height: 64px;
+ }
+ #header h1, #header h2 {margin: 0}
+ #header h2 {
+ color: #888;
+ font-weight: normal;
+ font-size: 16px;
+ }
+
+
+ #about h3 {
+ margin: 0;
+ margin-bottom: 10px;
+ font-size: 14px;
+ }
+
+ #about-content {
+ background-color: #ffd;
+ border: 1px solid #fc0;
+ margin-left: -55px;
+ margin-right: -10px;
+ }
+ #about-content table {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ font-size: 11px;
+ border-collapse: collapse;
+ }
+ #about-content td {
+ padding: 10px;
+ padding-top: 3px;
+ padding-bottom: 3px;
+ }
+ #about-content td.name {color: #555}
+ #about-content td.value {color: #000}
+
+ #about-content ul {
+ padding: 0;
+ list-style-type: none;
+ }
+
+ #about-content.failure {
+ background-color: #fcc;
+ border: 1px solid #f00;
+ }
+ #about-content.failure p {
+ margin: 0;
+ padding: 10px;
+ }
+
+
+ #getting-started {
+ border-top: 1px solid #ccc;
+ margin-top: 25px;
+ padding-top: 15px;
+ }
+ #getting-started h1 {
+ margin: 0;
+ font-size: 20px;
+ }
+ #getting-started h2 {
+ margin: 0;
+ font-size: 14px;
+ font-weight: normal;
+ color: #333;
+ margin-bottom: 25px;
+ }
+ #getting-started ol {
+ margin-left: 0;
+ padding-left: 0;
+ }
+ #getting-started li {
+ font-size: 18px;
+ color: #888;
+ margin-bottom: 25px;
+ }
+ #getting-started li h2 {
+ margin: 0;
+ font-weight: normal;
+ font-size: 18px;
+ color: #333;
+ }
+ #getting-started li p {
+ color: #555;
+ font-size: 13px;
+ }
+
+
+ #sidebar ul {
+ margin-left: 0;
+ padding-left: 0;
+ }
+ #sidebar ul h3 {
+ margin-top: 25px;
+ font-size: 16px;
+ padding-bottom: 10px;
+ border-bottom: 1px solid #ccc;
+ }
+ #sidebar li {
+ list-style-type: none;
+ }
+ #sidebar ul.links li {
+ margin-bottom: 5px;
+ }
+
+ .filename {
+ font-style: italic;
+ }
+ </style>
+ <script type="text/javascript">
+ function about() {
+ info = document.getElementById('about-content');
+ if (window.XMLHttpRequest)
+ { xhr = new XMLHttpRequest(); }
+ else
+ { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
+ xhr.open("GET","rails/info/properties",false);
+ xhr.send("");
+ info.innerHTML = xhr.responseText;
+ info.style.display = 'block'
+ }
+ </script>
+ </head>
+ <body>
+ <div id="page">
+ <div id="sidebar">
+ <ul id="sidebar-items">
+ <li>
+ <h3>Browse the documentation</h3>
+ <ul class="links">
+ <li><a href="http://guides.rubyonrails.org/">Rails Guides</a></li>
+ <li><a href="http://api.rubyonrails.org/">Rails API</a></li>
+ <li><a href="http://www.ruby-doc.org/core/">Ruby core</a></li>
+ <li><a href="http://www.ruby-doc.org/stdlib/">Ruby standard library</a></li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+
+ <div id="content">
+ <div id="header">
+ <h1>Welcome aboard</h1>
+ <h2>You&rsquo;re riding Ruby on Rails!</h2>
+ </div>
+
+ <div id="about">
+ <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
+ <div id="about-content" style="display: none"></div>
+ </div>
+
+ <div id="getting-started">
+ <h1>Getting started</h1>
+ <h2>Here&rsquo;s how to get rolling:</h2>
+
+ <ol>
+ <li>
+ <h2>Use <code>rails generate</code> to create your models and controllers</h2>
+ <p>To see all available options, run it without parameters.</p>
+ </li>
+
+ <li>
+ <h2>Set up a default route and remove <span class="filename">public/index.html</span></h2>
+ <p>Routes are set up in <span class="filename">config/routes.rb</span>.</p>
+ </li>
+
+ <li>
+ <h2>Create your database</h2>
+ <p>Run <code>rake db:create</code> to create your database. If you're not using SQLite (the default), edit <span class="filename">config/database.yml</span> with your username and password.</p>
+ </li>
+ </ol>
+ </div>
+ </div>
+
+ <div id="footer">&nbsp;</div>
+ </div>
+ </body>
+</html>
5 test/sample/public/robots.txt
@@ -0,0 +1,5 @@
+# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
+#
+# To ban all spiders from the entire site uncomment the next two lines:
+# User-Agent: *
+# Disallow: /
6 test/sample/script/rails
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
+
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require File.expand_path('../../config/boot', __FILE__)
+require 'rails/commands'
0  test/sample/test/fixtures/.gitkeep
No changes.
0  test/sample/test/functional/.gitkeep
No changes.
0  test/sample/test/integration/.gitkeep
No changes.
12 test/sample/test/performance/browsing_test.rb
@@ -0,0 +1,12 @@
+require 'test_helper'
+require 'rails/performance_test_help'
+
+class BrowsingTest < ActionDispatch::PerformanceTest
+ # Refer to the documentation for all available options
+ # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
+ # :output => 'tmp/performance', :formats => [:flat] }
+
+ def test_homepage
+ get '/'
+ end
+end
13 test/sample/test/test_helper.rb
@@ -0,0 +1,13 @@
+ENV["RAILS_ENV"] = "test"
+require File.expand_path('../../config/environment', __FILE__)
+require 'rails/test_help'
+
+class ActiveSupport::TestCase
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
+ #
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
+ # -- they do not yet inherit this setting
+ fixtures :all
+
+ # Add more helper methods to be used by all tests here...
+end
0  test/sample/test/unit/.gitkeep
No changes.
0  test/sample/vendor/assets/stylesheets/.gitkeep
No changes.
0  test/sample/vendor/plugins/.gitkeep
No changes.
24 test/test_helper.rb
@@ -0,0 +1,24 @@
+# Configure Rails Environment
+ENV["RAILS_ENV"] = "test"
+
+require File.expand_path("../sample/config/environment.rb", __FILE__)
+require "rails/test_help"
+
+Rails.backtrace_cleaner.remove_silencers!
+
+# Load support files
+Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
+
+# For Generators
+require 'rails/generators/test_case'
+
+
+class Rails::Generators::TestCase
+ destination File.expand_path("../tmp", File.dirname(__FILE__))
+ setup :prepare_destination
+
+ def javascripts_path
+ "app/assets/javascripts/"
+ end
+
+end
3  tmp/app/assets/javascripts/controllers/regular_users_controller.js.coffee
@@ -0,0 +1,3 @@
+class Sample.RegularUsersController extends Batman.Controller
+ index: (params) ->
+
73 vendor/assets/javascripts/batman/batman.jquery.js
@@ -0,0 +1,73 @@
+(function() {
+ var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+ Batman.Request.prototype.send = function(data) {
+ var options, _ref;
+ options = {
+ url: this.get('url'),
+ type: this.get('method'),
+ dataType: this.get('type'),
+ data: data || this.get('data'),
+ username: this.get('username'),
+ password: this.get('password'),
+ beforeSend: __bind(function() {
+ return this.loading(true);
+ }, this),
+ success: __bind(function(response, textStatus, xhr) {
+ this.set('status', xhr.status);
+ this.set('response', response);
+ return this.success(response);
+ }, this),
+ error: __bind(function(xhr, status, error) {
+ this.set('status', xhr.status);
+ this.set('response', xhr.responseText);
+ xhr.request = this;
+ return this.error(xhr);
+ }, this),
+ complete: __bind(function() {
+ this.loading(false);
+ return this.loaded(true);
+ }, this)
+ };
+ if ((_ref = this.get('method')) === 'PUT' || _ref === 'POST') {
+ if (!this.get('formData')) {
+ options.contentType = this.get('contentType');
+ } else {
+ options.contentType = false;
+ options.processData = false;
+ options.data = this.constructor.objectToFormData(options.data);
+ }
+ }
+ return jQuery.ajax(options);
+ };
+ Batman.mixins.animation = {
+ show: function(addToParent) {
+ var jq, show, _ref, _ref2;
+ jq = $(this);
+ show = function() {
+ return jq.show(600);
+ };
+ if (addToParent) {
+ if ((_ref = addToParent.append) != null) {
+ _ref.appendChild(this);
+ }
+ if ((_ref2 = addToParent.before) != null) {
+ _ref2.parentNode.insertBefore(this, addToParent.before);
+ }
+ jq.hide();
+ setTimeout(show, 0);
+ } else {
+ show();
+ }
+ return this;
+ },
+ hide: function(removeFromParent) {
+ $(this).hide(600, __bind(function() {
+ var _ref;
+ if (removeFromParent) {
+ return (_ref = this.parentNode) != null ? _ref.removeChild(this) : void 0;
+ }
+ }, this));
+ return this;
+ }
+ };
+}).call(this);
4,717 vendor/assets/javascripts/batman/batman.js
4,717 additions, 0 deletions not shown
58 vendor/assets/javascripts/batman/batman.rails.js
@@ -0,0 +1,58 @@
+(function() {
+ var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
+ for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
+ function ctor() { this.constructor = child; }
+ ctor.prototype = parent.prototype;
+ child.prototype = new ctor;
+ child.__super__ = parent.prototype;
+ return child;
+ }, __slice = Array.prototype.slice;
+ Batman.RailsStorage = (function() {
+ __extends(RailsStorage, Batman.RestStorage);
+ function RailsStorage() {
+ RailsStorage.__super__.constructor.apply(this, arguments);
+ }
+ RailsStorage.prototype._addJsonExtension = function(options) {
+ return options.url += '.json';
+ };
+ RailsStorage.prototype.optionsForRecord = function() {
+ var args, callback, _i;
+ args = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), callback = arguments[_i++];
+ return RailsStorage.__super__.optionsForRecord.apply(this, __slice.call(args).concat([function(err, options) {
+ if (!err) {
+ this._addJsonExtension(options);
+ }
+ return callback.call(this, err, options);
+ }]));
+ };
+ RailsStorage.prototype.optionsForCollection = function() {
+ var args, callback, _i;
+ args = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), callback = arguments[_i++];
+ return RailsStorage.__super__.optionsForCollection.apply(this, __slice.call(args).concat([function(err, options) {
+ if (!err) {
+ this._addJsonExtension(options);
+ }
+ return callback.call(this, err, options);
+ }]));
+ };
+ RailsStorage.prototype.after('update', 'create', function(_arg) {
+ var err, key, record, recordOptions, response, validationError, validationErrors, _i, _len, _ref;
+ err = _arg[0], record = _arg[1], response = _arg[2], recordOptions = _arg[3];
+ if (err) {
+ if (err.request.get('status') === 422) {
+ _ref = JSON.parse(err.request.get('response'));
+ for (key in _ref) {
+ validationErrors = _ref[key];
+ for (_i = 0, _len = validationErrors.length; _i < _len; _i++) {
+ validationError = validationErrors[_i];
+ record.get('errors').add(key, "" + key + " " + validationError);
+ }
+ }
+ return [record.get('errors'), record, response, recordOptions];
+ }
+ }
+ return arguments[0];
+ });
+ return RailsStorage;
+ })();
+}).call(this);
415 vendor/assets/javascripts/batman/batman.solo.js
@@ -0,0 +1,415 @@
+(function() {
+
+/*!
+ * Reqwest! A x-browser general purpose XHR connection manager
+ * copyright Dustin Diaz 2011
+ * https://github.com/ded/reqwest
+ * license MIT
+ */
+!
+function(context, win) {
+
+ var twoHundo = /^20\d$/,
+ doc = document,
+ byTag = 'getElementsByTagName',
+ contentType = 'Content-Type',
+ head = doc[byTag]('head')[0],
+ uniqid = 0,
+ lastValue // data stored by the most recent JSONP callback
+ , xhr = ('XMLHttpRequest' in win) ?
+ function() {
+ return new XMLHttpRequest()
+ } : function() {
+ return new ActiveXObject('Microsoft.XMLHTTP')
+ }
+
+ function readyState(o, success, error) {
+ return function() {
+ if (o && o.readyState == 4) {
+ if (twoHundo.test(o.status)) {
+ success(o)
+ } else {
+ error(o)
+ }
+ }
+ }
+ }
+
+ function setHeaders(http, o) {
+ var headers = o.headers || {}
+ headers.Accept = headers.Accept || 'text/javascript, text/html, application/xml, text/xml, */*'
+
+ // breaks cross-origin requests with legacy browsers
+ if (!o.crossOrigin) {
+ headers['X-Requested-With'] = headers['X-Requested-With'] || 'XMLHttpRequest'
+ }
+
+ if (o.data) {
+ headers[contentType] = headers[contentType] || 'application/x-www-form-urlencoded'
+ }
+ for (var h in headers) {
+ headers.hasOwnProperty(h) && http.setRequestHeader(h, headers[h], false)
+ }
+ }
+
+ function getCallbackName(o) {
+ var callbackVar = o.jsonpCallback || "callback"
+ if (o.url.slice(-(callbackVar.length + 2)) == (callbackVar + "=?")) {
+ // Generate a guaranteed unique callback name
+ var callbackName = "reqwest_" + uniqid++
+
+ // Replace the ? in the URL with the generated name
+ o.url = o.url.substr(0, o.url.length - 1) + callbackName
+ return callbackName
+ } else {
+ // Find the supplied callback name
+ var regex = new RegExp(callbackVar + "=([\\w]+)")
+ return o.url.match(regex)[1]
+ }
+ }
+
+ // Store the data returned by the most recent callback
+
+
+ function generalCallback(data) {
+ lastValue = data
+ }
+
+ function getRequest(o, fn, err) {
+ function onload() {
+ // Call the user callback with the last value stored
+ // and clean up values and scripts.
+ o.success && o.success(lastValue)
+ lastValue = undefined
+ head.removeChild(script);
+ }
+ if (o.type == 'jsonp') {
+ var script = doc.createElement('script')
+
+ // Add the global callback
+ win[getCallbackName(o)] = generalCallback;
+
+ // Setup our script element
+ script.type = 'text/javascript'
+ script.src = o.url
+ script.async = true
+
+ script.onload = onload
+ // onload for IE
+ script.onreadystatechange = function() {
+ /^loaded|complete$/.test(script.readyState) && onload()
+ }
+
+ // Add the script to the DOM head
+ head.appendChild(script)
+ } else {
+ var http = xhr()
+ http.open(o.method || 'GET', typeof o == 'string' ? o : o.url, true)
+ setHeaders(http, o)
+ http.onreadystatechange = readyState(http, fn, err)
+ o.before && o.before(http)
+ http.send(o.data || null)
+ return http
+ }
+ }
+
+ function Reqwest(o, fn) {
+ this.o = o
+ this.fn = fn
+ init.apply(this, arguments)
+ }
+
+ function setType(url) {
+ if (/\.json$/.test(url)) {
+ return 'json'
+ }
+ if (/\.jsonp$/.test(url)) {
+ return 'jsonp'
+ }
+ if (/\.js$/.test(url)) {
+ return 'js'
+ }
+ if (/\.html?$/.test(url)) {
+ return 'html'
+ }
+ if (/\.xml$/.test(url)) {
+ return 'xml'
+ }
+ return 'js'
+ }
+
+ function init(o, fn) {
+ this.url = typeof o == 'string' ? o : o.url
+ this.timeout = null
+ var type = o.type || setType(this.url),
+ self = this
+ fn = fn ||
+ function() {}
+
+ if (o.timeout) {
+ this.timeout = setTimeout(function() {
+ self.abort()
+ error()
+ }, o.timeout)
+ }
+
+ function complete(resp) {
+ o.complete && o.complete(resp)
+ }
+
+ function success(resp) {
+ o.timeout && clearTimeout(self.timeout) && (self.timeout = null)
+ var r = resp.responseText
+
+ if (r) {
+ switch (type) {
+ case 'json':
+ resp = win.JSON ? win.JSON.parse(r) : eval('(' + r + ')')
+ break;
+ case 'js':
+ resp = eval(r)
+ break;
+ case 'html':
+ resp = r
+ break;
+ }
+ }
+
+ fn(resp)
+ o.success && o.success(resp)
+ complete(resp)
+ }
+
+ function error(resp) {
+ o.error && o.error(resp)
+ complete(resp)
+ }
+
+ this.request = getRequest(o, success, error)
+ }
+
+ Reqwest.prototype = {
+ abort: function() {
+ this.request.abort()
+ }
+
+ ,
+ retry: function() {
+ init.call(this, this.o, this.fn)
+ }
+ }
+
+ function reqwest(o, fn) {
+ return new Reqwest(o, fn)
+ }
+
+ function enc(v) {
+ return encodeURIComponent(v)
+ }
+
+ function serial(el) {
+ var n = el.name
+ // don't serialize elements that are disabled or without a name
+ if (el.disabled || !n) {
+ return ''
+ }
+ n = enc(n)
+ switch (el.tagName.toLowerCase()) {
+ case 'input':
+ switch (el.type) {
+ // silly wabbit
+ case 'reset':
+ case 'button':
+ case 'image':
+ case 'file':
+ return ''
+ case 'checkbox':
+ case 'radio':
+ return el.checked ? n + '=' + (el.value ? enc(el.value) : true) + '&' : ''
+ default:
+ // text hidden password submit
+ return n + '=' + (el.value ? enc(el.value) : '') + '&'
+ }
+ break;
+ case 'textarea':
+ return n + '=' + enc(el.value) + '&'
+ case 'select':
+ // @todo refactor beyond basic single selected value case
+ return n + '=' + enc(el.options[el.selectedIndex].value) + '&'
+ }
+ return ''
+ }
+
+ reqwest.serialize = function(form) {
+ var fields = [form[byTag]('input'), form[byTag]('select'), form[byTag]('textarea')],
+ serialized = []
+
+ for (var i = 0, l = fields.length; i < l; ++i) {
+ for (var j = 0, l2 = fields[i].length; j < l2; ++j) {
+ serialized.push(serial(fields[i][j]))
+ }
+ }
+ return serialized.join('').replace(/&$/, '')
+ }
+
+ reqwest.serializeArray = function(f) {
+ for (var pairs = this.serialize(f).split('&'), i = 0, l = pairs.length, r = [], o; i < l; i++) {
+ pairs[i] && (o = pairs[i].split('=')) && r.push({
+ name: o[0],
+ value: o[1]
+ })
+ }
+ return r
+ }
+
+ var old = context.reqwest
+ reqwest.noConflict = function() {
+ context.reqwest = old
+ return this
+ }
+
+ // defined as extern for Closure Compilation
+ if (typeof module !== 'undefined') module.exports = reqwest
+ context['reqwest'] = reqwest
+
+}(this, window)
+
+;
+ var buildParams, param, prefixes, r20, rbracket;
+ var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+ (typeof exports !== "undefined" && exports !== null ? exports : this).reqwest = typeof window !== "undefined" && window !== null ? window.reqwest : reqwest;
+ rbracket = /\[\]$/;
+ r20 = /%20/g;
+ param = function(a) {
+ var add, k, name, s, v, value;
+ s = [];
+ add = function(key, value) {
+ value = (Batman.typeOf(value) === 'function' ? value() : value);
+ return s[s.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
+ };
+ if (Batman.typeOf(a) === 'Array') {
+ for (value in a) {
+ name = a[value];
+ add(name, value);
+ }
+ } else {
+ for (k in a) {
+ v = a[k];
+ buildParams(k, v, add);
+ }
+ }
+ return s.join("&").replace(r20, "+");
+ };
+ buildParams = function(prefix, obj, add) {
+ var i, name, v, _len, _results, _results2;
+ if (Batman.typeOf(obj) === 'Array') {
+ _results = [];
+ for (i = 0, _len = obj.length; i < _len; i++) {
+ v = obj[i];
+ _results.push(rbracket.test(prefix) ? add(prefix, v) : buildParams(prefix + "[" + (typeof v === "object" || Batman.typeOf(v) === 'Array' ? i : "") + "]", v, add));
+ }
+ return _results;
+ } else if ((obj != null) && typeof obj === "object") {
+ _results2 = [];
+ for (name in obj) {
+ _results2.push(buildParams(prefix + "[" + name + "]", obj[name], add));
+ }
+ return _results2;
+ } else {
+ return add(prefix, obj);
+ }
+ };
+ Batman.Request.prototype.send = function(data) {
+ var options, xhr, _ref;
+ this.loading(true);
+ options = {
+ url: this.get('url'),
+ method: this.get('method'),
+ type: this.get('type'),
+ headers: {},
+ success: __bind(function(response) {
+ this.set('response', response);
+ this.set('status', xhr.status);
+ return this.success(response);
+ }, this),
+ error: __bind(function(xhr) {
+ this.set('response', xhr.responseText || xhr.content);
+ this.set('status', xhr.status);
+ xhr.request = this;
+ return this.error(xhr);
+ }, this),
+ complete: __bind(function() {
+ this.loading(false);
+ return this.loaded(true);
+ }, this)
+ };
+ if ((_ref = options.method) === 'PUT' || _ref === 'POST') {
+ if (!this.get('formData')) {
+ options.headers['Content-type'] = this.get('contentType');
+ data = data || this.get('data');
+ if (options.method === 'GET') {
+ options.url += param(data);
+ } else {
+ options.data = param(data);
+ }
+ } else {
+ options.data = this.constructor.objectToFormData(options.data);
+ }
+ }
+ return xhr = (reqwest(options)).request;
+ };
+ prefixes = ['Webkit', 'Moz', 'O', 'ms', ''];
+ Batman.mixins.animation = {
+ initialize: function() {
+ var prefix, _i, _len;
+ for (_i = 0, _len = prefixes.length; _i < _len; _i++) {
+ prefix = prefixes[_i];
+ this.style["" + prefix + "Transform"] = 'scale(0, 0)';
+ this.style.opacity = 0;
+ this.style["" + prefix + "TransitionProperty"] = "" + (prefix ? '-' + prefix.toLowerCase() + '-' : '') + "transform, opacity";
+ this.style["" + prefix + "TransitionDuration"] = "0.8s, 0.55s";
+ this.style["" + prefix + "TransformOrigin"] = "left top";
+ }
+ return this;
+ },
+ show: function(addToParent) {
+ var show, _ref, _ref2;
+ show = __bind(function() {
+ var prefix, _i, _len;
+ this.style.opacity = 1;
+ for (_i = 0, _len = prefixes.length; _i < _len; _i++) {
+ prefix = prefixes[_i];
+ this.style["" + prefix + "Transform"] = 'scale(1, 1)';
+ }
+ return this;
+ }, this);
+ if (addToParent) {
+ if ((_ref = addToParent.append) != null) {
+ _ref.appendChild(this);
+ }
+ if ((_ref2 = addToParent.before) != null) {
+ _ref2.parentNode.insertBefore(this, addToParent.before);
+ }
+ setTimeout(show, 0);
+ } else {
+ show();
+ }
+ return this;
+ },
+ hide: function(shouldRemove) {
+ var prefix, _i, _len;
+ this.style.opacity = 0;
+ for (_i = 0, _len = prefixes.length; _i < _len; _i++) {
+ prefix = prefixes[_i];
+ this.style["" + prefix + "Transform"] = 'scale(0, 0)';
+ }
+ if (shouldRemove) {
+ setTimeout((__bind(function() {
+ var _ref;
+ return (_ref = this.parentNode) != null ? _ref.removeChild(this) : void 0;
+ }, this)), 600);
+ }
+ return this;
+ }
+ };
+}).call(this);
Please sign in to comment.
Something went wrong with that request. Please try again.