Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

upgrading to Rails 3

  • Loading branch information...
commit 5f58f79ba929eb548058bb15d318315436263036 1 parent b6bb9e2
@ryanb authored
Showing with 7,816 additions and 9,179 deletions.
  1. +6 −4 .gitignore
  2. +1 −0  .rspec
  3. +24 −0 Gemfile
  4. +129 −0 Gemfile.lock
  5. +2 −2 LICENSE
  6. +2 −10 Rakefile
  7. +0 −15 TODO
  8. +1 −10 app/controllers/application_controller.rb
  9. +1 −2  app/helpers/application_helper.rb
  10. +23 −0 app/helpers/error_messages_helper.rb
  11. +5 −6 app/helpers/layout_helper.rb
  12. +1 −1  app/models/comment.rb
  13. +3 −3 app/models/episode.rb
  14. +1 −1  app/models/spam_question.rb
  15. +3 −3 app/models/spam_report.rb
  16. +1 −1  app/models/sponsor.rb
  17. +3 −3 app/views/comments/_comment.html.erb
  18. +4 −4 app/views/comments/_form.html.erb
  19. +1 −1  app/views/comments/index.html.erb
  20. +3 −3 app/views/episodes/_episode.html.erb
  21. +5 −5 app/views/episodes/_form.html.erb
  22. +2 −2 app/views/episodes/archive.html.erb
  23. +3 −3 app/views/episodes/index.html.erb
  24. +4 −4 app/views/episodes/show.html.erb
  25. +5 −4 app/views/layouts/application.html.erb
  26. +1 −1  app/views/sessions/new.html.erb
  27. +2 −2 app/views/shared/_side.html.erb
  28. +1 −1  app/views/spam_checks/_form.html.erb
  29. +2 −2 app/views/spam_checks/index.html.erb
  30. +1 −1  app/views/spam_questions/_form.html.erb
  31. +2 −2 app/views/spam_questions/index.html.erb
  32. +5 −5 app/views/spam_reports/index.html.erb
  33. +4 −4 app/views/spam_reports/show.html.erb
  34. +2 −2 app/views/sponsors/_form.html.erb
  35. +1 −1  app/views/sponsors/index.html.erb
  36. +2 −2 app/views/tags/show.html.erb
  37. +2 −0  autotest/discover.rb
  38. +4 −0 config.ru
  39. +49 −0 config/application.rb
  40. +13 −110 config/boot.rb
  41. +4 −73 config/environment.rb
  42. +22 −13 config/environments/development.rb
  43. +43 −16 config/environments/production.rb
  44. +29 −20 config/environments/test.rb
  45. +7 −0 config/initializers/backtrace_silencers.rb
  46. +0 −5 config/initializers/hoptoad.rb
  47. +2 −2 config/initializers/inflections.rb
  48. +0 −15 config/initializers/new_rails_defaults.rb
  49. +7 −0 config/initializers/secret_token.rb
  50. +8 −0 config/initializers/session_store.rb
  51. +5 −0 config/locales/en.yml
  52. +0 −3  config/preinitializer.rb
  53. +28 −22 config/routes.rb
  54. +7 −44 db/schema.rb
  55. +7 −0 db/seeds.rb
  56. 0  lib/tasks/.gitkeep
  57. +0 −181 lib/tasks/rspec.rake
  58. +24 −31 public/404.html
  59. +24 −31 public/422.html
  60. +24 −31 public/500.html
  61. +0 −10 public/dispatch.cgi
  62. +0 −24 public/dispatch.fcgi
  63. +0 −10 public/dispatch.rb
  64. +2 −6 public/javascripts/application.js
  65. +0 −963 public/javascripts/controls.js
  66. +0 −973 public/javascripts/dragdrop.js
  67. +0 −1,128 public/javascripts/effects.js
  68. +6,874 −10 public/javascripts/jquery.js
  69. +166 −0 public/javascripts/jquery.min.js
  70. +0 −4,320 public/javascripts/prototype.js
  71. +156 −0 public/javascripts/rails.js
  72. 0  public/stylesheets/.gitkeep
  73. +0 −3  script/about
  74. +0 −6 script/autospec
  75. +0 −3  script/console
  76. +0 −3  script/dbconsole
  77. +0 −3  script/destroy
  78. +0 −3  script/generate
  79. +0 −3  script/performance/benchmarker
  80. +0 −3  script/performance/profiler
  81. +0 −3  script/performance/request
  82. +0 −3  script/plugin
  83. +0 −3  script/process/inspector
  84. +0 −3  script/process/reaper
  85. +0 −3  script/process/spawner
  86. +6 −0 script/rails
  87. +0 −3  script/runner
  88. +0 −3  script/server
  89. +0 −15 script/setup
  90. +0 −4 script/setup_test
  91. +0 −22 script/spec
  92. +0 −52 script/spec_server
  93. +3 −3 spec/controllers/comments_controller_spec.rb
  94. +6 −6 spec/controllers/episodes_controller_spec.rb
  95. +1 −1  spec/controllers/info_controller_spec.rb
  96. +1 −1  spec/controllers/sessions_controller_spec.rb
  97. +2 −2 spec/controllers/spam_checks_controller_spec.rb
  98. +2 −2 spec/controllers/spam_questions_controller_spec.rb
  99. +4 −4 spec/controllers/spam_reports_controller_spec.rb
  100. +2 −2 spec/controllers/sponsors_controller_spec.rb
  101. +1 −1  spec/controllers/tags_controller_spec.rb
  102. +0 −2  spec/rcov.opts
  103. +0 −4 spec/spec.opts
  104. +25 −13 spec/spec_helper.rb
  105. 0  spec/{ → support}/controller_macros.rb
  106. 0  vendor/plugins/.gitkeep
  107. +0 −47 vendor/plugins/hoptoad_notifier/INSTALL
  108. +0 −112 vendor/plugins/hoptoad_notifier/README
  109. +0 −22 vendor/plugins/hoptoad_notifier/Rakefile
  110. +0 −1  vendor/plugins/hoptoad_notifier/install.rb
  111. +0 −261 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb
  112. +0 −50 vendor/plugins/hoptoad_notifier/tasks/hoptoad_notifier_tasks.rake
  113. +0 −353 vendor/plugins/hoptoad_notifier/test/hoptoad_notifier_test.rb
View
10 .gitignore
@@ -1,8 +1,10 @@
-log/*
-tmp/*
+.bundle
+db/*.sqlite3
+log/*.log
+log/*.pid
+tmp/**/*
config/database.yml
config/app_config.yml
config/*.sphinx.conf
-db/*.sqlite3
db/sphinx
-public/assets
+public/assets
View
1  .rspec
@@ -0,0 +1 @@
+--colour
View
24 Gemfile
@@ -0,0 +1,24 @@
+source 'http://rubygems.org'
+
+gem "rails", "3.0.3"
+gem "mysql2"
+gem "RedCloth"
+gem "coderay"
+gem "acts_as_list"
+gem "thinking-sphinx", :require => "thinking_sphinx"
+gem "whenever", :require => false
+gem "will_paginate", ">= 3.0.pre2"
+gem "jquery-rails"
+
+group :development, :test do
+ gem "mocha"
+ gem "rspec-rails"
+ gem "factory_girl_rails"
+ gem "webrat"
+ gem "autotest"
+ gem "autotest-rails"
+end
+
+group :development do
+ gem "nifty-generators"
+end
View
129 Gemfile.lock
@@ -0,0 +1,129 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ RedCloth (4.2.3)
+ ZenTest (4.4.0)
+ aaronh-chronic (0.3.9)
+ abstract (1.0.0)
+ actionmailer (3.0.3)
+ actionpack (= 3.0.3)
+ mail (~> 2.2.9)
+ actionpack (3.0.3)
+ activemodel (= 3.0.3)
+ activesupport (= 3.0.3)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.4)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.13)
+ rack-test (~> 0.5.6)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.3)
+ activesupport (= 3.0.3)
+ builder (~> 2.1.2)
+ i18n (~> 0.4)
+ activerecord (3.0.3)
+ activemodel (= 3.0.3)
+ activesupport (= 3.0.3)
+ arel (~> 2.0.2)
+ tzinfo (~> 0.3.23)
+ activeresource (3.0.3)
+ activemodel (= 3.0.3)
+ activesupport (= 3.0.3)
+ activesupport (3.0.3)
+ acts_as_list (0.1.2)
+ arel (2.0.3)
+ autotest (4.4.1)
+ autotest-rails (4.1.0)
+ ZenTest
+ builder (2.1.2)
+ coderay (0.9.5)
+ diff-lcs (1.1.2)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ factory_girl (1.3.2)
+ factory_girl_rails (1.0)
+ factory_girl (~> 1.3)
+ rails (>= 3.0.0.beta4)
+ i18n (0.4.2)
+ jquery-rails (0.2.5)
+ rails (~> 3.0)
+ thor (~> 0.14.4)
+ mail (2.2.10)
+ activesupport (>= 2.3.6)
+ i18n (~> 0.4.1)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ mocha (0.9.9)
+ rake
+ mysql2 (0.2.6)
+ nifty-generators (0.4.2)
+ nokogiri (1.4.4)
+ polyglot (0.3.1)
+ rack (1.2.1)
+ rack-mount (0.6.13)
+ rack (>= 1.0.0)
+ rack-test (0.5.6)
+ rack (>= 1.0)
+ rails (3.0.3)
+ actionmailer (= 3.0.3)
+ actionpack (= 3.0.3)
+ activerecord (= 3.0.3)
+ activeresource (= 3.0.3)
+ activesupport (= 3.0.3)
+ bundler (~> 1.0)
+ railties (= 3.0.3)
+ railties (3.0.3)
+ actionpack (= 3.0.3)
+ activesupport (= 3.0.3)
+ rake (>= 0.8.7)
+ thor (~> 0.14.4)
+ rake (0.8.7)
+ riddle (1.2.1)
+ rspec (2.1.0)
+ rspec-core (~> 2.1.0)
+ rspec-expectations (~> 2.1.0)
+ rspec-mocks (~> 2.1.0)
+ rspec-core (2.1.0)
+ rspec-expectations (2.1.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.1.0)
+ rspec-rails (2.1.0)
+ rspec (~> 2.1.0)
+ thinking-sphinx (2.0.0)
+ activerecord (>= 3.0.0)
+ riddle (>= 1.2.0)
+ thor (0.14.4)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.23)
+ webrat (0.7.2)
+ nokogiri (>= 1.2.0)
+ rack (>= 1.0)
+ rack-test (>= 0.5.3)
+ whenever (0.6.2)
+ aaronh-chronic (>= 0.3.9)
+ activesupport (>= 2.3.4)
+ will_paginate (3.0.pre2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ RedCloth
+ acts_as_list
+ autotest
+ autotest-rails
+ coderay
+ factory_girl_rails
+ jquery-rails
+ mocha
+ mysql2
+ nifty-generators
+ rails (= 3.0.3)
+ rspec-rails
+ thinking-sphinx
+ webrat
+ whenever
+ will_paginate (>= 3.0.pre2)
View
4 LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2008 Ryan Bates, Railscasts
+Copyright (c) 2010 Ryan Bates, Railscasts
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
12 Rakefile
@@ -1,15 +1,7 @@
# 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 File.expand_path('../config/application', __FILE__)
require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-
-require 'tasks/rails'
-begin
- require 'thinking_sphinx/tasks'
-rescue MissingSourceFile
-end
+Railscasts::Application.load_tasks
View
15 TODO
@@ -1,15 +0,0 @@
-Fixes
-
-Features
-- add alternative download format for linux/windows
-- add search to comments page
-
-Possible
-- try "application/quicktime" content type to open movie directly in quicktime (see apple.com/quicktime for examples)
-- provide adobe media player feed
-- integration with miro (getmiro.com)
-+ improve CSS design
-+ author edit comment for short time
-+ textile for comments
-+ remember me when logging in
-+ add a blog
View
11 app/controllers/application_controller.rb
@@ -1,14 +1,5 @@
-# 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 => 'fc8393e85d1780ae56953606f53014e1'
-
- include HoptoadNotifier::Catcher if APP_CONFIG['hoptoad_key']
+ protect_from_forgery
private
View
3  app/helpers/application_helper.rb
@@ -1,6 +1,5 @@
-# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def textilize(text)
- Textilizer.new(text).to_html unless text.blank?
+ Textilizer.new(text).to_html.html_safe unless text.blank?
end
end
View
23 app/helpers/error_messages_helper.rb
@@ -0,0 +1,23 @@
+module ErrorMessagesHelper
+ # Render error messages for the given objects. The :message and :header_message options are allowed.
+ def error_messages_for(*objects)
+ options = objects.extract_options!
+ options[:header_message] ||= "Invalid Fields"
+ options[:message] ||= "Correct the following errors and try again."
+ messages = objects.compact.map { |o| o.errors.full_messages }.flatten
+ unless messages.empty?
+ content_tag(:div, :class => "error_messages") do
+ list_items = messages.map { |msg| content_tag(:li, msg) }
+ content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe)
+ end
+ end
+ end
+
+ module FormBuilderAdditions
+ def error_messages(options = {})
+ @template.error_messages_for(@object, options)
+ end
+ end
+end
+
+ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions)
View
11 app/helpers/layout_helper.rb
@@ -4,20 +4,19 @@
# helper :layout
module LayoutHelper
def title(page_title, show_title = true)
- @content_for_title = page_title.to_s
+ content_for(:title) { h(page_title.to_s) }
@show_title = show_title
end
-
+
def show_title?
@show_title
end
-
+
def stylesheet(*args)
- content_for(:head) { stylesheet_link_tag(*args.map(&:to_s)) }
+ content_for(:head) { stylesheet_link_tag(*args) }
end
-
+
def javascript(*args)
- args = args.map { |arg| arg == :defaults ? arg : arg.to_s }
content_for(:head) { javascript_include_tag(*args) }
end
end
View
2  app/models/comment.rb
@@ -3,7 +3,7 @@ class Comment < ActiveRecord::Base
validates_presence_of :name, :content, :episode_id
- named_scope :recent, :order => "created_at DESC"
+ scope :recent, order("created_at DESC")
before_save :add_protocol_to_site_url
View
6 app/models/episode.rb
@@ -6,9 +6,9 @@ class Episode < ActiveRecord::Base
acts_as_list
- named_scope :published, lambda { {:conditions => ['published_at <= ?', Time.now.utc]} }
- named_scope :unpublished, lambda { {:conditions => ['published_at > ?', Time.now.utc]} }
- named_scope :recent, :order => 'position DESC'
+ scope :published, lambda { where('published_at <= ?', Time.now.utc) }
+ scope :unpublished, lambda { where('published_at > ?', Time.now.utc) }
+ scope :recent, order('position DESC')
validates_presence_of :published_at, :name
validates_associated :downloads, :on => :update # create automatically handles validation
View
2  app/models/spam_question.rb
@@ -2,6 +2,6 @@ class SpamQuestion < ActiveRecord::Base
attr_accessible :question, :answer
def self.random # there are more efficient ways to do this but it's database specific
- find(:first, :offset => rand(self.count-1))
+ find(:first, :offset => rand(self.count))
end
end
View
6 app/models/spam_report.rb
@@ -3,9 +3,9 @@ class SpamReport < ActiveRecord::Base
before_create :copy_comment_attributes
- named_scope :unconfirmed, :conditions => "confirmed_at is null"
- named_scope :confirmed, :conditions => "confirmed_at is not null"
- named_scope :popular, :order => "hit_count desc"
+ scope :unconfirmed, where("confirmed_at is null")
+ scope :confirmed, where("confirmed_at is not null")
+ scope :popular, order("hit_count desc")
def self.report_comment(comment)
if comment.matching_spam_reports.empty?
View
2  app/models/sponsor.rb
@@ -1,5 +1,5 @@
class Sponsor < ActiveRecord::Base
- named_scope :active, :conditions => ["active = ?", true]
+ scope :active, where("active = ?", true)
def position
if force_top?
View
6 app/views/comments/_comment.html.erb
@@ -1,18 +1,18 @@
<% @comment_counter ||= 0 -%>
<% @comment_counter += 1 -%>
<%= tag :hr if @comment_counter > 1 %>
-<% div_for comment do %>
+<%= div_for comment do %>
<%- if comment.episode && !current_page?(comment.episode) -%>
<h4>
Episode #<%= comment.episode.position %>:
- <%= link_to h(comment.episode.name), episode_path(:id => comment.episode, :anchor => dom_id(comment)) %>
+ <%= link_to comment.episode.name, episode_path(:id => comment.episode, :anchor => dom_id(comment)) %>
</h4>
<%- end -%>
<%- if comment.position -%>
<span class="position"><%= comment.position %>.</span>
<%- end -%>
<span class="name">
- <%= link_to_unless comment.site_url.blank?, h(comment.name), h(comment.site_url), :rel => "nofollow" %>
+ <%= link_to_unless comment.site_url.blank?, comment.name, comment.site_url, :rel => "nofollow" %>
</span>
<%- unless comment.created_at.nil? -%>
<span class="created_at">
View
8 app/views/comments/_form.html.erb
@@ -1,13 +1,13 @@
-<% form_for @comment do |f| %>
- <%= error_messages_for :comment %>
+<%= form_for @comment do |f| %>
+ <%= f.error_messages %>
<noscript><p>Javascript required to add comment.</p></noscript>
<div>
<%= f.hidden_field :episode_id %>
- <%= enkode hidden_field_tag(:spam_key, APP_CONFIG['spam_key']) %>
+ <%= raw enkode(hidden_field_tag(:spam_key, APP_CONFIG['spam_key'])) %>
</div>
<% if current_spam_question %>
<p id="spam_question">
- <strong><%=h current_spam_question.question %></strong><br />
+ <strong><%= current_spam_question.question %></strong><br />
<%= text_field_tag :spam_answer %>
</p>
<% end %>
View
2  app/views/comments/index.html.erb
@@ -1,5 +1,5 @@
<% title "Recent Comments" %>
-<% content_tag :head do %>
+<% content_for :head do %>
<link rel="alternate" type="application/rss+xml" title="Comments RSS" href="http://feeds.feedburner.com/railscasts_comments" />
<% end %>
View
6 app/views/episodes/_episode.html.erb
@@ -11,13 +11,13 @@
<% end %>
</div>
<div class="main">
- <h2><%= link_to_unless_current h(episode.name), episode %></h2>
- <div class="description"><%=h episode.description %></div>
+ <h2><%= link_to_unless_current episode.name, episode %></h2>
+ <div class="description"><%= episode.description %></div>
<% unless episode.tags.empty? %>
<div class="tags">
Tags:
<% for tag in episode.tags %>
- <%= link_to h(tag.name), tag %>
+ <%= link_to tag.name, tag %>
<% end %>
</div>
<% end %>
View
10 app/views/episodes/_form.html.erb
@@ -1,6 +1,6 @@
<div class="content">
- <%= error_messages_for :episode %>
- <% form_for @episode do |f| %>
+ <%= form_for @episode do |f| %>
+ <%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
@@ -30,9 +30,9 @@
<%= f.label :asciicasts, "Available on ASCIIcasts" %>
</p>
<% for download in @episode.downloads %>
- <% fields_for_download(download) do |d| %>
- <%= error_messages_for :download, :object => download %>
- <h3><%=h download.format %></h3>
+ <%= fields_for_download(download) do |d| %>
+ <%= d.error_messages %>
+ <h3><%= download.format %></h3>
<div><%= d.hidden_field :format %></div>
<p>
<%= d.label :url, 'File URL' %><br />
View
4 app/views/episodes/archive.html.erb
@@ -1,7 +1,7 @@
<% title "All Episodes" %>
<div class="content">
- <% form_tag archive_episodes_path, :method => 'get' do %>
+ <%= form_tag archive_episodes_path, :method => 'get' do %>
<p>
<%= text_field_tag :search, params[:search] %>
<%= submit_tag "Search", :name => nil %>
@@ -9,7 +9,7 @@
<% end %>
<% @episode_months.each do |month, episodes| %>
- <h2><%=h month.strftime('%B %Y') %></h2>
+ <h2><%= month.strftime('%B %Y') %></h2>
<% for episode in episodes %>
<div>
<%= episode.position %>.
View
6 app/views/episodes/index.html.erb
@@ -1,6 +1,6 @@
<% title "Free Ruby on Rails Screencasts", false %>
-<% form_tag episodes_path, :method => 'get' do %>
+<%= form_tag episodes_path, :method => 'get' do %>
<p class="content">
<%= text_field_tag :search, params[:search] %>
<%= submit_tag "Search", :name => nil %>
@@ -16,9 +16,9 @@
<% end %>
<p class="content">
- <%= link_to h('< Previous Page'), :overwrite_params => { :page => @episodes.previous_page } if @episodes.previous_page %>
+ <%= link_to '< Previous Page', :overwrite_params => { :page => @episodes.previous_page } if @episodes.previous_page %>
<%= "|" if @episodes.previous_page && @episodes.next_page %>
- <%= link_to h('Next Page >'), :overwrite_params => { :page => @episodes.next_page } if @episodes.next_page %>
+ <%= link_to 'Next Page >', :overwrite_params => { :page => @episodes.next_page } if @episodes.next_page %>
</p>
<% if admin? %>
View
8 app/views/episodes/show.html.erb
@@ -1,20 +1,20 @@
<% title @episode.name, false %>
-<% content_tag :head do %>
+<% content_for :head do %>
<link rel="alternate" type="application/rss+xml" title="Episode Comments RSS" href="<%= episode_url(@episode, :format => 'rss') %>" />
<% end %>
<div class="episodes">
- <% render :layout => @episode do %>
+ <%= render :layout => @episode do %>
<div class="notes">
<%= textilize @episode.notes %>
</div>
<div id="episode_nav">
<% unless @episode.first? %>
- <div id="previous_episode"><%= link_to h('< Previous Episode'), @episode.higher_item %></div>
+ <div id="previous_episode"><%= link_to '< Previous Episode', @episode.higher_item %></div>
<% end %>
<% unless @episode.last_published? || @episode.last? %>
- <div id="next_episode"><%= link_to h('Next Episode >'), @episode.lower_item %></div>
+ <div id="next_episode"><%= link_to 'Next Episode >', @episode.lower_item %></div>
<% end %>
</div>
<div class="clear"></div>
View
9 app/views/layouts/application.html.erb
@@ -3,12 +3,13 @@
<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>Railscasts - <%= h(yield(:title) || "Free Ruby on Rails Screencasts") %></title>
+ <title>Railscasts - <%= content_for?(:title) ? yield(:title) : "Free Ruby on Rails Screencasts" %></title>
<meta name="description" content="Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced programmers." />
<meta name="keywords" content="rails, ruby on rails, screencasts, railscast, railscasts, tips, tricks, tutorials, training, podcasts, programming" />
<link rel="alternate" type="application/rss+xml" title="Episodes RSS" href="http://feeds.feedburner.com/railscasts" />
<%= stylesheet_link_tag 'application', 'coderay' %>
- <%= javascript_include_tag 'jquery', 'application' %>
+ <%= javascript_include_tag :defaults %>
+ <%= csrf_meta_tag %>
<%= yield(:head) %>
</head>
<body>
@@ -20,13 +21,13 @@
<%- end -%>
<%- if show_title? -%>
- <h1 class="content"><%=h yield(:title) %></h1>
+ <h1 class="content"><%= yield(:title) %></h1>
<%- end -%>
<%= yield %>
</div>
<div id="side">
- <%= yield(:side) || render(:partial => 'shared/side') %>
+ <%= content_for?(:side) ? yield(:side) : render(:partial => 'shared/side') %>
</div>
<div class="clear"></div>
</div>
View
2  app/views/sessions/new.html.erb
@@ -1,7 +1,7 @@
<% title "Login" %>
<div class="content">
- <% form_tag sessions_path do %>
+ <%= form_tag sessions_path do %>
<p>
<%= label_tag 'password', 'Password:' %>
<%= password_field_tag 'password' %>
View
4 app/views/shared/_side.html.erb
@@ -9,7 +9,7 @@
<strong>sponsored by:</strong>
<% for sponsor in Sponsor.active.sort_by(&:position) %>
<div class="sponsor">
- <%= link_to image_tag(sponsor.image_url, :alt => h(sponsor.name)), sponsor.site_url %>
+ <%= link_to image_tag(sponsor.image_url, :alt => sponsor.name), sponsor.site_url %>
</div>
<% end %>
</div>
@@ -17,7 +17,7 @@
<strong>tags:</strong>
<ul id="tags">
<% for tag in Tag.find(:all, :order => 'name') %>
- <li><%= link_to h(tag.name), tag_path(tag) %></li>
+ <li><%= link_to tag.name, tag_path(tag) %></li>
<% end %>
</ul>
</div>
View
2  app/views/spam_checks/_form.html.erb
@@ -1,4 +1,4 @@
-<% form_for @spam_check do |f| %>
+<%= form_for @spam_check do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :regexp %><br />
View
4 app/views/spam_checks/index.html.erb
@@ -11,8 +11,8 @@
</tr>
<% for spam_check in @spam_checks %>
<tr>
- <td><%=h spam_check.regexp %></td>
- <td><%=h spam_check.weight %></td>
+ <td><%= spam_check.regexp %></td>
+ <td><%= spam_check.weight %></td>
<td><%= link_to "edit", edit_spam_check_path(spam_check) %></td>
<td><%= link_to "destroy", spam_check, :method => :delete, :confirm => "Are you sure?" %></td>
</tr>
View
2  app/views/spam_questions/_form.html.erb
@@ -1,4 +1,4 @@
-<% form_for @spam_question do |f| %>
+<%= form_for @spam_question do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :question %><br />
View
4 app/views/spam_questions/index.html.erb
@@ -11,8 +11,8 @@
</tr>
<% for spam_question in @spam_questions %>
<tr>
- <td><%=h spam_question.question %></td>
- <td><%=h spam_question.answer %></td>
+ <td><%= spam_question.question %></td>
+ <td><%= spam_question.answer %></td>
<td><%= link_to "Edit", edit_spam_question_path(spam_question) %></td>
<td><%= link_to "Destroy", spam_question, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
View
10 app/views/spam_reports/index.html.erb
@@ -4,7 +4,7 @@
<%= render :partial => 'shared/navigation' %>
<% end %>
-<% form_tag confirm_spam_reports_path do %>
+<%= form_tag confirm_spam_reports_path do %>
<table border="1" cellspacing="0" cellpadding="3" id="spam_reports">
<tr>
<th></th>
@@ -16,10 +16,10 @@
<% for spam_report in @spam_reports %>
<tr>
<td><%= check_box_tag "id[]", spam_report.id, false %></td>
- <td><%= link_to h(spam_report.comment_name), spam_report %></td>
- <td><%=h spam_report.comment_ip %></td>
- <td><%=h spam_report.comment_site_url %></td>
- <td><%=h spam_report.hit_count %></td>
+ <td><%= link_to spam_report.comment_name, spam_report %></td>
+ <td><%= spam_report.comment_ip %></td>
+ <td><%= spam_report.comment_site_url %></td>
+ <td><%= spam_report.hit_count %></td>
</tr>
<% end %>
</table>
View
8 app/views/spam_reports/show.html.erb
@@ -6,24 +6,24 @@
<% unless @spam_report.comment_ip.blank? %>
<p>
<strong>IP Address:</strong>
- <%=h @spam_report.comment_ip %>
+ <%= @spam_report.comment_ip %>
</p>
<% end %>
<% unless @spam_report.comment_site_url.blank? %>
<p>
<strong>Site URL:</strong>
- <%=h @spam_report.comment_site_url %>
+ <%= @spam_report.comment_site_url %>
</p>
<% end %>
<% unless @spam_report.comment_name.blank? %>
<p>
<strong>Author Name:</strong>
- <%=h @spam_report.comment_name %>
+ <%= @spam_report.comment_name %>
</p>
<% end %>
<p>
<strong>Number of Hits:</strong>
- <%=h @spam_report.hit_count %>
+ <%= @spam_report.hit_count %>
</p>
<p>Look through the comments below and confirm this spam report by choosing confirm at the bottom. Otherwise you can <%= link_to 'destroy it', @spam_report, :confirm => 'Are you sure?', :method => :delete %>.</p>
View
4 app/views/sponsors/_form.html.erb
@@ -1,6 +1,6 @@
<div class="content">
- <%= error_messages_for :sponsor %>
- <% form_for @sponsor do |f| %>
+ <%= form_for @sponsor do |f| %>
+ <%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
View
2  app/views/sponsors/index.html.erb
@@ -2,7 +2,7 @@
<div class="content">
<% for sponsor in @sponsors %>
<div class="sponsor">
- <h3><%=h sponsor.name %></h3>
+ <h3><%= sponsor.name %></h3>
<p><%= image_tag(sponsor.image_url) %></p>
<p class="actions">
<%= link_to "Edit", edit_sponsor_path(sponsor) %> |
View
4 app/views/tags/show.html.erb
@@ -5,7 +5,7 @@
</div>
<p class="content">
- <%= link_to h('< Previous Page'), :overwrite_params => { :page => @episodes.previous_page } if @episodes.previous_page %>
+ <%= link_to '< Previous Page', :overwrite_params => { :page => @episodes.previous_page } if @episodes.previous_page %>
<%= "|" if @episodes.previous_page && @episodes.next_page %>
- <%= link_to h('Next Page >'), :overwrite_params => { :page => @episodes.next_page } if @episodes.next_page %>
+ <%= link_to 'Next Page >', :overwrite_params => { :page => @episodes.next_page } if @episodes.next_page %>
</p>
View
2  autotest/discover.rb
@@ -0,0 +1,2 @@
+Autotest.add_discovery { "rails" }
+Autotest.add_discovery { "rspec2" }
View
4 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 Railscasts::Application
View
49 config/application.rb
@@ -0,0 +1,49 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'yaml'
+APP_CONFIG = YAML.load(File.read(File.expand_path('../app_config.yml', __FILE__)))
+
+require 'rails/all'
+
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)
+
+module Railscasts
+ 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
+
+ # JavaScript files you want as :defaults (application.js is always included).
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
+
+ # 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]
+
+ config.time_zone = 'Pacific Time (US & Canada)'
+
+ config.autoload_paths += %W(#{Rails.root}/lib)
+ end
+end
View
123 config/boot.rb
@@ -1,110 +1,13 @@
-# 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)
- Rails::GemDependency.add_frozen_gem_path
- 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!
+require 'rubygems'
+
+# Set up gems listed in the Gemfile.
+gemfile = File.expand_path('../../Gemfile', __FILE__)
+begin
+ ENV['BUNDLE_GEMFILE'] = gemfile
+ require 'bundler'
+ Bundler.setup
+rescue Bundler::GemNotFound => e
+ STDERR.puts e.message
+ STDERR.puts "Try running `bundle install`."
+ exit!
+end if File.exist?(gemfile)
View
77 config/environment.rb
@@ -1,74 +1,5 @@
-# Be sure to restart your server when you modify this file
+# Load the rails application
+require File.expand_path('../application', __FILE__)
-# Uncomment below to force Rails into production mode when
-# you don't control web/app server and can't set it the proper way
-# ENV['RAILS_ENV'] ||= 'production'
-
-# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
-
-# Bootstrap the Rails environment, frameworks, and default configuration
-require File.join(File.dirname(__FILE__), 'boot')
-
-Rails::Initializer.run do |config|
- # 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.
- # See Rails::Configuration for more options.
-
- # Skip frameworks you're not going to use. To use Rails without a database
- # you must remove the Active Record framework.
- # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
-
- # Specify gems that this application depends on.
- # They can then be installed with "rake gems:install" on new installations.
- # config.gem "bj"
- # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
- # config.gem "aws-s3", :lib => "aws/s3"
-
- # Only load the plugins named here, in the order given. By default, all plugins
- # in vendor/plugins are loaded in alphabetical order.
- # :all can be used as a placeholder for all plugins not explicitly named
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
-
- # Add additional load paths for your own custom dirs
- # config.load_paths += %W( #{RAILS_ROOT}/extras )
-
- # Force all environments to use the same logger level
- # (by default production uses :info, the others :debug)
- # config.log_level = :debug
-
- # Make Time.zone default to the specified zone, and make Active Record store time values
- # in the database in UTC, and return them converted to the specified local zone.
- # Run "rake -D time" for a list of tasks for finding time zone names. Uncomment to use default local time.
- config.time_zone = 'Pacific Time (US & Canada)'
-
- # Your secret key for verifying cookie session data integrity.
- # If you change this key, all old sessions 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.
- config.action_controller.session = {
- :session_key => APP_CONFIG['session_key'],
- :secret => APP_CONFIG['session_secret']
- }
-
- # 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 "rake db:sessions:create")
- # config.action_controller.session_store = :active_record_store
-
- # 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
-
- # Activate observers that should always be running
- # config.active_record.observers = :cacher, :garbage_collector
-
- config.gem "RedCloth", :lib => 'redcloth', :version => ">= 4.0"
- config.gem "coderay"
- config.gem 'ryanb-acts-as-list', :lib => 'acts_as_list', :source => 'http://gems.github.com'
- config.gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com'
- config.gem 'ryanb-thinking-sphinx', :lib => 'thinking_sphinx', :source => 'http://gems.github.com'
- config.gem 'javan-whenever', :lib => false, :source => 'http://gems.github.com'
-end
+# Initialize the rails application
+Railscasts::Application.initialize!
View
35 config/environments/development.rb
@@ -1,17 +1,26 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Railscasts::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 webserver when you make code changes.
-config.cache_classes = false
+ # 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 webserver when you make code changes.
+ config.cache_classes = false
-# Log error messages when you accidentally call methods on nil.
-config.whiny_nils = true
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_view.debug_rjs = true
-config.action_controller.perform_caching = false
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_view.debug_rjs = 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
+end
-# Don't care if the mailer can't send
-config.action_mailer.raise_delivery_errors = false
View
59 config/environments/production.rb
@@ -1,22 +1,49 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Railscasts::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
-# The production environment is meant for finished, "live" apps.
-# Code is not reloaded between requests
-config.cache_classes = true
+ # The production environment is meant for finished, "live" apps.
+ # Code is not reloaded between requests
+ config.cache_classes = true
-# Use a different logger for distributed setups
-# config.logger = SyslogLogger.new
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
-# Full error reports are disabled and caching is turned on
-config.action_controller.consider_all_requests_local = false
-config.action_controller.perform_caching = true
-config.action_view.cache_template_loading = true
+ # Specifies the header that your server uses for sending files
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
-# Use a different cache store in production
-# config.cache_store = :mem_cache_store
+ # For nginx:
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
-# Enable serving of images, stylesheets, and javascripts from an asset server
-# config.action_controller.asset_host = "http://assets.example.com"
+ # If you have no front-end server that supports something like X-Sendfile,
+ # just comment this out and Rails will serve the files
-# Disable delivery errors, bad email addresses will be ignored
-# config.action_mailer.raise_delivery_errors = false
+ # 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
+
+ # Disable Rails's static asset server
+ # In production, Apache or nginx will already do this
+ config.serve_static_assets = false
+
+ # Enable serving of images, stylesheets, and javascripts from an asset server
+ # config.action_controller.asset_host = "http://assets.example.com"
+
+ # 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
View
49 config/environments/test.rb
@@ -1,26 +1,35 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Railscasts::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
+ # 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
-# Log error messages when you accidentally call methods on nil.
-config.whiny_nils = true
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_controller.perform_caching = false
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
-# Disable request forgery protection in test environment
-config.action_controller.allow_forgery_protection = false
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = 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
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
-config.gem 'thoughtbot-factory_girl', :version => '>= 1.1.1', :lib => 'factory_girl', :source => 'http://gems.github.com'
-config.gem "rspec", :lib => false, :version => ">= 1.2.0"
-config.gem "rspec-rails", :lib => false, :version => ">= 1.2.0"
+ # 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
+end
View
7 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!
View
5 config/initializers/hoptoad.rb
@@ -1,5 +0,0 @@
-if APP_CONFIG['hoptoad_key']
- HoptoadNotifier.configure do |config|
- config.api_key = APP_CONFIG['hoptoad_key']
- end
-end
View
4 config/initializers/inflections.rb
@@ -1,8 +1,8 @@
# Be sure to restart your server when you modify this file.
-# Add new inflection rules using the following format
+# Add new inflection rules using the following format
# (all these examples are active by default):
-# Inflector.inflections do |inflect|
+# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
View
15 config/initializers/new_rails_defaults.rb
@@ -1,15 +0,0 @@
-# These settings change the behavior of Rails 2 apps and will be defaults
-# for Rails 3. You can remove this initializer when Rails 3 is released.
-
-# Include Active Record class name as root for JSON serialized output.
-ActiveRecord::Base.include_root_in_json = true
-
-# Store the full class name (including module namespace) in STI type column.
-ActiveRecord::Base.store_full_sti_class = true
-
-# Use ISO 8601 format for JSON serialized times and dates.
-ActiveSupport.use_standard_json_time_format = true
-
-# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
-# if you're including raw json in an HTML page.
-ActiveSupport.escape_html_entities_in_json = false
View
7 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.
+Railscasts::Application.config.secret_token = APP_CONFIG['session_secret']
View
8 config/initializers/session_store.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+Railscasts::Application.config.session_store :cookie_store, :key => APP_CONFIG['session_key']
+
+# 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")
+# Railscasts::Application.config.session_store :active_record_store
View
5 config/locales/en.yml
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
View
3  config/preinitializer.rb
@@ -1,3 +0,0 @@
-# load app_config.yml
-require 'yaml'
-APP_CONFIG = YAML.load(File.read(RAILS_ROOT + "/config/app_config.yml"))
View
50 config/routes.rb
@@ -1,24 +1,30 @@
-ActionController::Routing::Routes.draw do |map|
- map.resources :spam_questions
-
- map.resources :spam_checks
-
- map.with_options :controller => 'info' do |info|
- info.about 'about', :action => 'about'
- info.contest 'contest', :action => 'contest'
- info.feeds 'feeds', :action => 'feeds'
- info.give_back 'give_back', :action => 'give_back'
- end
-
- map.login 'login', :controller => 'sessions', :action => 'new'
- map.logout 'logout', :controller => 'sessions', :action => 'destroy'
+Railscasts::Application.routes.draw do
+ root :to => "episodes#index"
- map.resources :sponsors
- map.resources :comments
- map.resources :tags
- map.resources :episodes, :collection => { :archive => :get }
- map.resources :sessions
- map.resources :spam_reports, :member => { :confirm => :post }, :collection => { :confirm => :post }
+ match "about" => "info#about", :as => "about"
+ match "contest" => "info#contest", :as => "contest"
+ match "feeds" => "info#feeds", :as => "feeds"
+ match "give_back" => "info#give_back", :as => "give_back"
+ match "login" => "sessions#new", :as => "login"
+ match "logout" => "sessions#destroy", :as => "logout"
- map.root :episodes
-end
+ resources :sponsors
+ resources :comments
+ resources :tags
+ resources :episodes do
+ collection do
+ get :archive
+ end
+ end
+ resources :sessions
+ resources :spam_questions
+ resources :spam_checks
+ resources :spam_reports do
+ member do
+ post :confirm
+ end
+ collection do
+ post :confirm
+ end
+ end
+end
View
51 db/schema.rb
@@ -1,10 +1,11 @@
-# This file is auto-generated from the current state of the database. Instead of editing this file,
-# please use the migrations feature of Active Record to incrementally modify your database, and
-# then regenerate this schema definition.
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
#
-# Note that this schema.rb definition is the authoritative source for your database schema. If you need
-# to create the application database on another system, you should be using db:schema:load, not running
-# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
@@ -87,19 +88,6 @@
t.boolean "force_top", :default => false, :null => false
end
- create_table "subscriptions", :force => true do |t|
- t.integer "user_id"
- t.string "ip_address"
- t.string "first_name"
- t.string "last_name"
- t.date "card_expires_on"
- t.date "expires_on"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "customer_token"
- t.boolean "cancelling", :default => false, :null => false
- end
-
create_table "taggings", :force => true do |t|
t.integer "episode_id"
t.integer "tag_id"
@@ -116,29 +104,4 @@
t.datetime "updated_at"
end
- create_table "transaction_responses", :force => true do |t|
- t.integer "subscription_id"
- t.string "action"
- t.integer "amount"
- t.boolean "success"
- t.string "authorization"
- t.string "message"
- t.text "params"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- create_table "users", :force => true do |t|
- t.string "username"
- t.string "email"
- t.string "persistence_token"
- t.string "crypted_password"
- t.string "password_salt"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.boolean "admin", :default => false, :null => false
- t.boolean "pro", :default => false, :null => false
- t.string "pro_token"
- end
-
end
View
7 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 => 'Daley', :city => cities.first)
View
0  lib/tasks/.gitkeep
No changes.
View
181 lib/tasks/rspec.rake
@@ -1,181 +0,0 @@
-gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
-rspec_gem_dir = nil
-Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir|
- rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb")
-end
-rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec')
-
-if rspec_gem_dir && (test ?d, rspec_plugin_dir)
- raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n"
-end
-
-if rspec_gem_dir
- $LOAD_PATH.unshift("#{rspec_gem_dir}/lib")
-elsif File.exist?(rspec_plugin_dir)
- $LOAD_PATH.unshift("#{rspec_plugin_dir}/lib")
-end
-
-# Don't load rspec if running "rake gems:*"
-unless ARGV.any? {|a| a =~ /^gems/}
-
-begin
- require 'spec/rake/spectask'
-rescue MissingSourceFile
- module Spec
- module Rake
- class SpecTask
- def initialize(name)
- task name do
- # if rspec-rails is a configured gem, this will output helpful material and exit ...
- require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
-
- # ... otherwise, do this:
- raise <<-MSG
-
-#{"*" * 80}
-* You are trying to run an rspec rake task defined in
-* #{__FILE__},
-* but rspec can not be found in vendor/gems, vendor/plugins or system gems.
-#{"*" * 80}
-MSG
- end
- end
- end
- end
- end
-end
-
-Rake.application.instance_variable_get('@tasks').delete('default')
-
-spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
-task :noop do
-end
-
-task :default => :spec
-task :stats => "spec:statsetup"
-
-desc "Run all specs in spec directory (excluding plugin specs)"
-Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['spec/**/*/*_spec.rb']
-end
-
-namespace :spec do
- desc "Run all specs in spec directory with RCov (excluding plugin specs)"
- Spec::Rake::SpecTask.new(:rcov) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['spec/**/*/*_spec.rb']
- t.rcov = true
- t.rcov_opts = lambda do
- IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
- end
- end
-
- desc "Print Specdoc for all specs (excluding plugin specs)"
- Spec::Rake::SpecTask.new(:doc) do |t|
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
- t.spec_files = FileList['spec/**/*/*_spec.rb']
- end
-
- desc "Print Specdoc for all plugin examples"
- Spec::Rake::SpecTask.new(:plugin_doc) do |t|
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
- t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*')
- end
-
- [:models, :controllers, :views, :helpers, :lib].each do |sub|
- desc "Run the code examples in spec/#{sub}"
- Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
- end
- end
-
- desc "Run the code examples in vendor/plugins (except RSpec's own)"
- Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['vendor/plugins/**/spec/**/*/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
- end
-
- namespace :plugins do
- desc "Runs the examples for rspec_on_rails"
- Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
- t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*/*_spec.rb']
- end
- end
-
- # Setup specs for stats
- task :statsetup do
- require 'code_statistics'
- ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
- ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
- ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
- ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
- ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
- ::STATS_DIRECTORIES << %w(Routing\ specs spec/lib) if File.exist?('spec/routing')
- ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
- ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
- ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
- ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
- ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
- ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
- ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
- end
-
- namespace :db do
- namespace :fixtures do
- desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z."
- task :load => :environment do
- ActiveRecord::Base.establish_connection(Rails.env)
- base_dir = File.join(Rails.root, 'spec', 'fixtures')
- fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
-
- require 'active_record/fixtures'
- (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
- Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
- end
- end
- end
- end
-
- namespace :server do
- daemonized_server_pid = File.expand_path("#{RAILS_ROOT}/tmp/pids/spec_server.pid")
-
- desc "start spec_server."
- task :start do
- if File.exist?(daemonized_server_pid)
- $stderr.puts "spec_server is already running."
- else
- $stderr.puts %Q{Starting up spec_server ...}
- FileUtils.mkdir_p('tmp/pids') unless test ?d, 'tmp/pids'
- system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
- end
- end
-
- desc "stop spec_server."
- task :stop do
- unless File.exist?(daemonized_server_pid)
- $stderr.puts "No server running."
- else
- $stderr.puts "Shutting down spec_server ..."
- system("kill", "-s", "TERM", File.read(daemonized_server_pid).strip) &&
- File.delete(daemonized_server_pid)
- end
- end
-
- desc "restart spec_server."
- task :restart => [:stop, :start]
-
- desc "check if spec server is running"
- task :status do
- if File.exist?(daemonized_server_pid)
- $stderr.puts %Q{spec_server is running (PID: #{File.read(daemonized_server_pid).gsub("\n","")})}
- else
- $stderr.puts "No server running."
- end
- end
- end
-end
-
-end
View
55 public/404.html
@@ -1,33 +1,26 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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>Railscasts - File not Found</title>
- <link href="/stylesheets/application.css?1217174801" media="screen" rel="stylesheet" type="text/css" />
- </head>
+<!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>
- <div id="container">
- <div id="logo"><a href="/"><img alt="Railscasts" height="88" src="/images/logo.png" width="452" /></a></div>
-
- <div id="main">
- <div class="content">
- <h1>File Not Found</h1>
- <p>The page you were looking for doesn't exist. If you reached this from clicking a link, please send an email to ryan AT railscasts DOT com.</p>
- </div>
- </div>
-
- <div id="side">
- <div class="section">
- <strong>navigation:</strong>
- <ul id="navigation">
- <li><a href="/">Recent Episodes</a></li>
- <li><a href="/episodes/archive">All Episodes</a></li>
- <li><a href="/about">About Railscasts</a></li>
- </ul>
- </div>
- </div>
- </div>
- </body>
+<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>
View
55 public/422.html
@@ -1,33 +1,26 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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>Railscasts - Request Rejected</title>
- <link href="/stylesheets/application.css?1217174801" media="screen" rel="stylesheet" type="text/css" />
- </head>
+<!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>
- <div id="container">
- <div id="logo"><a href="/"><img alt="Railscasts" height="88" src="/images/logo.png" width="452" /></a></div>
-
- <div id="main">
- <div class="content">
- <h1>Request Rejected</h1>
- <p>The change you wanted was rejected. Maybe you tried to change something you didn't have access to. If you reached this from clicking a link, please send an email to ryan AT railscasts DOT com.</p>
- </div>
- </div>
-
- <div id="side">
- <div class="section">
- <strong>navigation:</strong>
- <ul id="navigation">
- <li><a href="/">Recent Episodes</a></li>
- <li><a href="/episodes/archive">All Episodes</a></li>
- <li><a href="/about">About Railscasts</a></li>
- </ul>
- </div>
- </div>
- </div>
- </body>
+<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>
View
55 public/500.html
@@ -1,33 +1,26 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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>Railscasts - Error Occurred</title>
- <link href="/stylesheets/application.css?1217174801" media="screen" rel="stylesheet" type="text/css" />
- </head>
+<!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>
- <div id="container">
- <div id="logo"><a href="/"><img alt="Railscasts" height="88" src="/images/logo.png" width="452" /></a></div>
-
- <div id="main">
- <div class="content">
- <h1>Error Occurred</h1>
- <p>We're sorry, but something went wrong. If you reached this from clicking a link, please send an email to ryan AT railscasts DOT com.</p>
- </div>
- </div>
-
- <div id="side">
- <div class="section">
- <strong>navigation:</strong>
- <ul id="navigation">
- <li><a href="/">Recent Episodes</a></li>
- <li><a href="/episodes/archive">All Episodes</a></li>
- <li><a href="/about">About Railscasts</a></li>
- </ul>
- </div>
- </div>
- </div>
- </body>
+<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>
View
10 public/dispatch.cgi
@@ -1,10 +0,0 @@
-#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
-
-require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
-
-# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
-# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
-require "dispatcher"
-
-ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
-Dispatcher.dispatch
View
24 public/dispatch.fcgi
@@ -1,24 +0,0 @@
-#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
-#
-# You may specify the path to the FastCGI crash log (a log of unhandled
-# exceptions which forced the FastCGI instance to exit, great for debugging)
-# and the number of requests to process before running garbage collection.
-#
-# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
-# and the GC period is nil (turned off). A reasonable number of requests
-# could range from 10-100 depending on the memory footprint of your app.
-#
-# Example:
-# # Default log path, normal GC behavior.
-# RailsFCGIHandler.process!
-#
-# # Default log path, 50 requests between GC.
-# RailsFCGIHandler.process! nil, 50
-#
-# # Custom log path, normal GC behavior.
-# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
-#
-require File.dirname(__FILE__) + "/../config/environment"
-require 'fcgi_handler'
-
-RailsFCGIHandler.process!
View
10 public/dispatch.rb
@@ -1,10 +0,0 @@
-#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
-
-require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
-
-# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
-# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
-require "dispatcher"
-
-ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
-Dispatcher.dispatch
View
8 public/javascripts/application.js
@@ -1,8 +1,4 @@
-jQuery.ajaxSetup({
- 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
-})
-
-$(document).ready(function() {
+$(function() {
$("#comments .spam_report").removeAttr("onclick").click(function () {
$.post(this.href, null, null, "script");
return false;
@@ -13,4 +9,4 @@ $(document).ready(function() {
}
return false;
});
-})
+});
View
963 public/javascripts/controls.js
@@ -1,963 +0,0 @@
-// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005-2008 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
-// (c) 2005-2008 Jon Tirsen (http://www.tirsen.com)
-// Contributors:
-// Richard Livsey
-// Rahul Bhargava
-// Rob Wills
-//
-// script.aculo.us is freely distributable under the terms of an MIT-style license.
-// For details, see the script.aculo.us web site: http://script.aculo.us/
-
-// Autocompleter.Base handles all the autocompletion functionality
-// that's independent of the data source for autocompletion. This
-// includes drawing the autocompletion menu, observing keyboard
-// and mouse events, and similar.
-//
-// Specific autocompleters need to provide, at the very least,
-// a getUpdatedChoices function that will be invoked every time
-// the text inside the monitored textbox changes. This method
-// should get the text for which to provide autocompletion by
-// invoking this.getToken(), NOT by directly accessing
-// this.element.value. This is to allow incremental tokenized
-// autocompletion. Specific auto-completion logic (AJAX, etc)
-// belongs in getUpdatedChoices.
-//
-// Tokenized incremental autocompletion is enabled automatically
-// when an autocompleter is instantiated with the 'tokens' option
-// in the options parameter, e.g.:
-// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' });
-// will incrementally autocomplete with a comma as the token.
-// Additionally, ',' in the above example can be replaced with
-// a token array, e.g. { tokens: [',', '\n'] } which
-// enables autocompletion on multiple tokens. This is most
-// useful when one of the tokens is \n (a newline), as it
-// allows smart autocompletion after linebreaks.
-
-if(typeof Effect == 'undefined')
- throw("controls.js requires including script.aculo.us' effects.js library");
-
-var Autocompleter = { };
-Autocompleter.Base = Class.create({
- baseInitialize: function(element, update, options) {
- element = $(element);
- this.element = element;
- this.update = $(update);
- this.hasFocus = false;
- this.changed = false;
- this.active = false;
- this.index = 0;
- this.entryCount = 0;
- this.oldElementValue = this.element.value;
-
- if(this.setOptions)
- this.setOptions(options);
- else
- this.options = options || { };
-
- this.options.paramName = this.options.paramName || this.element.name;
- this.options.tokens = this.options.tokens || [];
- this.options.frequency = this.options.frequency || 0.4;
- this.options.minChars = this.options.minChars || 1;
- this.options.onShow = this.options.onShow ||
- function(element, update){
- if(!update.style.position || update.style.position=='absolute') {
- update.style.position = 'absolute';
- Position.clone(element, update, {
- setHeight: false,
- offsetTop: element.offsetHeight