Permalink
Browse files

add rails files

  • Loading branch information...
andyshearer committed Mar 9, 2009
1 parent a2bdcef commit 089cbbfc7565d8136195147e8f45fb16138832f3
Showing with 9,658 additions and 0 deletions.
  1. +10 −0 Rakefile
  2. +15 −0 app/controllers/application.rb
  3. +86 −0 app/controllers/posts_controller.rb
  4. +3 −0 app/helpers/application_helper.rb
  5. +2 −0 app/helpers/posts_helper.rb
  6. +2 −0 app/models/post.rb
  7. +19 −0 app/views/layouts/posts.html.erb
  8. +20 −0 app/views/posts/edit.html.erb
  9. +22 −0 app/views/posts/index.html.erb
  10. +19 −0 app/views/posts/new.html.erb
  11. +1 −0 app/views/posts/new.js.erb
  12. +13 −0 app/views/posts/show.html.erb
  13. +109 −0 config/boot.rb
  14. +22 −0 config/database.yml
  15. +75 −0 config/environment.rb
  16. +17 −0 config/environments/development.rb
  17. +24 −0 config/environments/production.rb
  18. +22 −0 config/environments/test.rb
  19. +10 −0 config/initializers/inflections.rb
  20. +5 −0 config/initializers/mime_types.rb
  21. +17 −0 config/initializers/new_rails_defaults.rb
  22. +5 −0 config/locales/en.yml
  23. +45 −0 config/routes.rb
  24. BIN db/development.sqlite3
  25. +14 −0 db/migrate/20090309224217_create_posts.rb
  26. +21 −0 db/schema.rb
  27. +5 −0 doc/README_FOR_APP
  28. +1,014 −0 log/development.log
  29. 0 log/production.log
  30. 0 log/server.log
  31. 0 log/test.log
  32. BIN public/.DS_Store
  33. +30 −0 public/404.html
  34. +30 −0 public/422.html
  35. +33 −0 public/500.html
  36. +10 −0 public/dispatch.cgi
  37. +24 −0 public/dispatch.fcgi
  38. +10 −0 public/dispatch.rb
  39. 0 public/favicon.ico
  40. BIN public/images/rails.png
  41. +274 −0 public/index.html
  42. +16 −0 public/javascripts/application.js
  43. +963 −0 public/javascripts/controls.js
  44. +973 −0 public/javascripts/dragdrop.js
  45. +1,128 −0 public/javascripts/effects.js
  46. +19 −0 public/javascripts/jquery-1.3.2.min.js
  47. +4,320 −0 public/javascripts/prototype.js
  48. +5 −0 public/robots.txt
  49. +54 −0 public/stylesheets/scaffold.css
  50. +4 −0 script/about
  51. +3 −0 script/console
  52. +3 −0 script/dbconsole
  53. +3 −0 script/destroy
  54. +3 −0 script/generate
  55. +3 −0 script/performance/benchmarker
  56. +3 −0 script/performance/profiler
  57. +3 −0 script/performance/request
  58. +3 −0 script/plugin
  59. +3 −0 script/process/inspector
  60. +3 −0 script/process/reaper
  61. +3 −0 script/process/spawner
  62. +3 −0 script/runner
  63. +3 −0 script/server
  64. +9 −0 test/fixtures/posts.yml
  65. +45 −0 test/functional/posts_controller_test.rb
  66. +9 −0 test/performance/browsing_test.rb
  67. +38 −0 test/test_helper.rb
  68. +8 −0 test/unit/post_test.rb
View
@@ -0,0 +1,10 @@
+# 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.join(File.dirname(__FILE__), 'config', 'boot'))
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+require 'tasks/rails'
@@ -0,0 +1,15 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ helper :all # include all helpers, all the time
+
+ # See ActionController::RequestForgeryProtection for details
+ # Uncomment the :secret if you're not using the cookie session store
+ protect_from_forgery # :secret => 'aaf4273b87aa795fc4ce608192776855'
+
+ # See ActionController::Base for details
+ # Uncomment this to filter the contents of submitted sensitive data parameters
+ # from your application log (in this case, all fields with names like "password").
+ # filter_parameter_logging :password
+end
@@ -0,0 +1,86 @@
+class PostsController < ApplicationController
+ # GET /posts
+ # GET /posts.xml
+ def index
+ @posts = Post.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @posts }
+ end
+ end
+
+ # GET /posts/1
+ # GET /posts/1.xml
+ def show
+ @post = Post.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @post }
+ end
+ end
+
+ # GET /posts/new
+ # GET /posts/new.xml
+ def new
+ @post = Post.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @post }
+ format.js # new.js.erb
+ end
+ end
+
+ # GET /posts/1/edit
+ def edit
+ @post = Post.find(params[:id])
+ end
+
+ # POST /posts
+ # POST /posts.xml
+ def create
+ @post = Post.new(params[:post])
+
+ respond_to do |format|
+ if @post.save
+ flash[:notice] = 'Post was successfully created.'
+ format.html { redirect_to(@post) }
+ format.xml { render :xml => @post, :status => :created, :location => @post }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /posts/1
+ # PUT /posts/1.xml
+ def update
+ @post = Post.find(params[:id])
+
+ respond_to do |format|
+ if @post.update_attributes(params[:post])
+ flash[:notice] = 'Post was successfully updated.'
+ format.html { redirect_to(@post) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /posts/1
+ # DELETE /posts/1.xml
+ def destroy
+ @post = Post.find(params[:id])
+ @post.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(posts_url) }
+ format.xml { head :ok }
+ end
+ end
+end
@@ -0,0 +1,3 @@
+# Methods added to this helper will be available to all templates in the application.
+module ApplicationHelper
+end
@@ -0,0 +1,2 @@
+module PostsHelper
+end
View
@@ -0,0 +1,2 @@
+class Post < ActiveRecord::Base
+end
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
+ <title>Posts: <%= controller.action_name %></title>
+ <%= stylesheet_link_tag 'scaffold' %>
+<%= javascript_include_tag 'jquery-1.3.2.min.js' %>
+<%= javascript_include_tag 'application.js' %>
+</head>
+<body>
+
+<p style="color: green"><%= flash[:notice] %></p>
+
+<%= yield %>
+
+</body>
+</html>
@@ -0,0 +1,20 @@
+<h1>Editing post</h1>
+
+<% form_for(@post) do |f| %>
+ <%= f.error_messages %>
+
+ <p>
+ <%= f.label :title %><br />
+ <%= f.text_field :title %>
+ </p>
+ <p>
+ <%= f.label :body %><br />
+ <%= f.text_area :body %>
+ </p>
+ <p>
+ <%= f.submit "Update" %>
+ </p>
+<% end %>
+
+<%= link_to 'Show', @post %> |
+<%= link_to 'Back', posts_path %>
@@ -0,0 +1,22 @@
+<h1>Listing posts</h1>
+
+<table>
+ <tr>
+ <th>Title</th>
+ <th>Body</th>
+ </tr>
+
+<% for post in @posts %>
+ <tr>
+ <td><%=h post.title %></td>
+ <td><%=h post.body %></td>
+ <td><%= link_to 'Show', post %></td>
+ <td><%= link_to 'Edit', edit_post_path(post) %></td>
+ <td><%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New post', new_post_path, :class => 'ajaxLink' %>
@@ -0,0 +1,19 @@
+<h1>New post</h1>
+
+<% form_for(@post) do |f| %>
+ <%= f.error_messages %>
+
+ <p>
+ <%= f.label :title %><br />
+ <%= f.text_field :title %>
+ </p>
+ <p>
+ <%= f.label :body %><br />
+ <%= f.text_area :body %>
+ </p>
+ <p>
+ <%= f.submit "Create" %>
+ </p>
+<% end %>
+
+<%= link_to 'Back', posts_path %>
@@ -0,0 +1 @@
+alert('this is a remote call');
@@ -0,0 +1,13 @@
+<p>
+ <b>Title:</b>
+ <%=h @post.title %>
+</p>
+
+<p>
+ <b>Body:</b>
+ <%=h @post.body %>
+</p>
+
+
+<%= link_to 'Edit', edit_post_path(@post) %> |
+<%= link_to 'Back', posts_path %>
View
@@ -0,0 +1,109 @@
+# Don't change this file!
+# Configure your app in config/environment.rb and config/environments/*.rb
+
+RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
+
+module Rails
+ class << self
+ def boot!
+ unless booted?
+ preinitialize
+ pick_boot.run
+ end
+ end
+
+ def booted?
+ defined? Rails::Initializer
+ end
+
+ def pick_boot
+ (vendor_rails? ? VendorBoot : GemBoot).new
+ end
+
+ def vendor_rails?
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
+ end
+
+ def preinitialize
+ load(preinitializer_path) if File.exist?(preinitializer_path)
+ end
+
+ def preinitializer_path
+ "#{RAILS_ROOT}/config/preinitializer.rb"
+ end
+ end
+
+ class Boot
+ def run
+ load_initializer
+ Rails::Initializer.run(:set_load_path)
+ end
+ end
+
+ class VendorBoot < Boot
+ def load_initializer
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
+ Rails::Initializer.run(:install_gem_spec_stubs)
+ end
+ end
+
+ class GemBoot < Boot
+ def load_initializer
+ self.class.load_rubygems
+ load_rails_gem
+ require 'initializer'
+ end
+
+ def load_rails_gem
+ if version = self.class.gem_version
+ gem 'rails', version
+ else
+ gem 'rails'
+ end
+ rescue Gem::LoadError => load_error
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
+ exit 1
+ end
+
+ class << self
+ def rubygems_version
+ Gem::RubyGemsVersion rescue nil
+ end
+
+ def gem_version
+ if defined? RAILS_GEM_VERSION
+ RAILS_GEM_VERSION
+ elsif ENV.include?('RAILS_GEM_VERSION')
+ ENV['RAILS_GEM_VERSION']
+ else
+ parse_gem_version(read_environment_rb)
+ end
+ end
+
+ def load_rubygems
+ require 'rubygems'
+ min_version = '1.3.1'
+ unless rubygems_version >= min_version
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
+ exit 1
+ end
+
+ rescue LoadError
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
+ exit 1
+ end
+
+ def parse_gem_version(text)
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
+ end
+
+ private
+ def read_environment_rb
+ File.read("#{RAILS_ROOT}/config/environment.rb")
+ end
+ end
+ end
+end
+
+# All that for this:
+Rails.boot!
View
@@ -0,0 +1,22 @@
+# SQLite version 3.x
+# gem install sqlite3-ruby (not necessary on OS X Leopard)
+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
Oops, something went wrong.

0 comments on commit 089cbbf

Please sign in to comment.