4 | <%= link_to "Ban User", ban_user_path(comment.user), :confirm => "Are you certain you want to ban this user? It will delete all of his comments and not allow him to comment again.", :remote => true, :method => :put if comment.user && can?(:ban, comment.user) %>
5 |
Unfortunately I am unable to answer generic Rails questions which are not specific to RailsCasts. For this I recommend asking on one of the following forums.
RailsCasts is produced by Ryan Bates (<%= link_to "rbates", "http://twitter.com/rbates" %> on Twitter and <%= link_to "ryanb", "https://github.com/ryanb" %> on GitHub). A new episode will be released each Monday featuring tips and tricks with Ruby on Rails. The screencasts are short and focus on one technique so you can quickly move on to applying it to your own project. The topics target the intermediate Rails developer, but beginners and experts will get something out of it as well.
10 |
11 |
ASCIIcasts
12 |
If you prefer text over video, please visit <%= link_to "ASCIIcasts", "http://asciicasts.com/" %> where Eifion Bedford has done a wonderful job of translating the majority of the episodes into textual form.
13 |
14 |
TextMate Theme
15 |
Do you like the TextMate theme used in these screencasts? It is custom made and based off of the theme by idlefingers. I am using the Bitstream Vera Sans Mono font.
If you have any comments, suggestions, questions, etc. I'd love to hear them! Please use the <%= link_to "Feedback Page", feedback_path %> or send an email to .
22 |
23 |
Moderators
24 |
Thank you to all moderators who help keep the site clean and up to date:
25 |
26 | <% for user in User.where(:moderator => true).order(:name) %>
27 |
<%= link_to user.name, user %>
28 | <% end %>
29 |
30 |
If you are interested in becoming a moderator, see the <%= link_to "moderator guidelines", moderators_path %>.
31 |
32 |
Special Thanks
33 |
Special thanks to <%= link_to "Linode", "http://www.linode.com/?utm_source=railscasts.com&utm_medium=Badge&utm_campaign=Railscasts" %> for providing hosting for this site and <%= link_to "SublimeVideo", "http://sublimevideo.net/" %> for providing the episode player.
34 |
35 |
This Site
36 |
This site is available in <%= link_to "open source", "https://github.com/ryanb/railscasts" %>. It is intended to be used as an example Rails app, so feel free to copy bits of it for your own project. If you would like to use it as a starting point for your own site please contact me.
All RailsCasts episodes are under the Creative Commons license. You are free to distribute unedited versions of the episodes for non-commercial purposes. You are also free to translate them into any language. If you would like to edit the video please contact me.
49 |
50 |
51 |
--------------------------------------------------------------------------------
/app/views/info/give_back.html.erb:
--------------------------------------------------------------------------------
1 | <% title "Give Back to Open Source", false %>
2 |
3 |
A lot of effort is put into open source software which is given away for free. In <%= link_to "Episode 200", episode_path(200) %> I am challenging everyone to give back to the open source community.
Thank you to all who are interested in becoming moderators. I currently have enough moderators but may need more in the future. You can still request to become a moderator, and I will consider it when a position is available.
5 |
6 |
Moderators primarily help deal with the spam issues, but also help fix show notes and review unreleased episodes. If you are interested in becoming a moderator, <%= link_to "let me know", feedback_path %> and provide reasons as to why you should become one along with your GitHub username.
7 |
8 |
Editing User Comments
9 |
Moderators are able to edit user comments. This is intended to fix incorrect formatting. Do not alter what the user is saying. If you must add a note, ensure that it is clearly marked as edited by you.
10 |
11 |
Deleting User Comments
12 |
Comments can be removed if they provide no value to the conversation, are offensive, or are spam. Do not delete comments which have replies, instead edit them to remove the content and include a note saying it has been removed by a moderator. If a comment is a simple "thank you" and is over a month old, feel free to delete it.
13 |
14 |
Banning Users
15 |
Users can be banned. When this happens all of their comments will be deleted and they will be unable to add further comments. Users who are spamming the site should be banned. Banning users is not available on older comments because a user account system was not available then. You will need to delete those individually.
16 |
If you are ever uncertain whether it is spam or not, click on their profile and read their other comments. If you are still unsure, leave it alone. We do not want to ban legitimate users.
17 |
Both banning users and deleting comments have a confirmation dialog, so don't worry too much about accidentally hitting the button. If you do accidentally delete a comment or ban a user, let me know immediately and provide as much detail as you can.
18 |
If at any time I find a moderator not following these guidelines I will remove the privilege and revert all actions he has done. A paper trail of all changes are kept.
19 |
20 |
Reviewing Unreleased Episodes
21 |
On the rare occasion I finish recording an episode early, it will show up on the front page for moderators before it is released. Feel free to watch this and provide feedback if you find problems. Please send feedback through email or the <%= link_to "feedback page", feedback_path %>, not the comments section until the episode is released.
22 |
23 |
Editing Episode Show Notes
24 |
Moderators can edit episode show notes. Feel free to add notes based on what users mention in the comments. Also please include links to related episodes, mention problems with specific Rails versions, fix minor problems with the source code, etc. If you are doing significant changes to the show notes, please ask me first.
25 |
26 |
Special Thanks
27 |
Thank you to all who are interested in becoming moderators. I am very grateful to all who can help clean up the site and make it better. Your name will appear in a moderators list in the <%= link_to "About page", about_path %> for credit. If you are interested in becoming a moderator, <%= link_to "let me know", feedback_path %> and provide reasons as to why you should become one along with your GitHub username.
28 |
If you have ideas on how I can improve the moderator experience, please add an issue to the <%= link_to "GitHub project", "https://github.com/ryanb/railscasts" %>.
<%= link_to "Ban this User", ban_user_path(@user), :confirm => "Are you certain you want to ban this user? It will delete all of his comments and not allow him to comment again.", :remote => true, :method => :put if can?(:ban, @user) && !@user.banned? %>
20 |
21 |
Comments by <%= @user.name %>
22 |
23 | <% for comment in @user.comments.recent %>
24 | <%= render comment %>
25 | <% end %>
26 |
27 |
28 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run Railscasts::Application
5 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | require 'net/http'
4 | require 'yaml'
5 | APP_CONFIG = YAML.load(File.read(File.expand_path('../app_config.yml', __FILE__)))
6 |
7 | require 'rails/all'
8 |
9 | # If you have a Gemfile, require the gems listed there, including any gems
10 | # you've limited to :test, :development, or :production.
11 | Bundler.require(:default, Rails.env) if defined?(Bundler)
12 |
13 | module Railscasts
14 | class Application < Rails::Application
15 | # Settings in config/environments/* take precedence over those specified here.
16 | # Application configuration should go into files in config/initializers
17 | # -- all .rb files in that directory are automatically loaded.
18 |
19 | # Custom directories with classes and modules you want to be autoloadable.
20 | # config.autoload_paths += %W(#{config.root}/extras)
21 |
22 | # Only load the plugins named here, in the order given (default is alphabetical).
23 | # :all can be used as a placeholder for all plugins not explicitly named.
24 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
25 |
26 | # Activate observers that should always be running.
27 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
28 |
29 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
30 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
31 | # config.time_zone = 'Central Time (US & Canada)'
32 |
33 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
34 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
35 | # config.i18n.default_locale = :de
36 |
37 | # JavaScript files you want as :defaults (application.js is always included).
38 | # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
39 |
40 | # Configure the default encoding used in templates for Ruby 1.9.
41 | config.encoding = "utf-8"
42 |
43 | # Configure sensitive parameters which will be filtered from the log file.
44 | config.filter_parameters += [:password]
45 |
46 | config.time_zone = 'Pacific Time (US & Canada)'
47 |
48 | config.autoload_paths += %W(#{Rails.root}/lib)
49 | end
50 | end
51 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 |
3 | # Set up gems listed in the Gemfile.
4 | gemfile = File.expand_path('../../Gemfile', __FILE__)
5 | begin
6 | ENV['BUNDLE_GEMFILE'] = gemfile
7 | require 'bundler'
8 | Bundler.setup
9 | rescue Bundler::GemNotFound => e
10 | STDERR.puts e.message
11 | STDERR.puts "Try running `bundle install`."
12 | exit!
13 | end if File.exist?(gemfile)
14 |
--------------------------------------------------------------------------------
/config/deploy.rb:
--------------------------------------------------------------------------------
1 | set :whenever_command, "bundle exec whenever"
2 | require "bundler/capistrano"
3 | require "whenever/capistrano"
4 | require "thinking_sphinx/deploy/capistrano"
5 |
6 | set :application, "railscasts.com"
7 | role :app, application
8 | role :web, application
9 | role :db, application, :primary => true
10 |
11 | set :user, "rbates"
12 | set :deploy_to, "/var/apps/railscasts"
13 | set :deploy_via, :remote_cache
14 | set :use_sudo, false
15 |
16 | set :scm, "git"
17 | set :repository, "git://github.com/ryanb/railscasts.git"
18 | set :branch, "master"
19 |
20 | namespace :deploy do
21 | desc "Tell Passenger to restart."
22 | task :restart, :roles => :web do
23 | run "touch #{deploy_to}/current/tmp/restart.txt"
24 | end
25 |
26 | desc "Do nothing on startup so we don't get a script/spin error."
27 | task :start do
28 | puts "You may need to restart Apache."
29 | end
30 |
31 | desc "Symlink extra configs and folders."
32 | task :symlink_extras do
33 | run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
34 | run "ln -nfs #{shared_path}/config/app_config.yml #{release_path}/config/app_config.yml"
35 | run "ln -nfs #{shared_path}/config/production.sphinx.conf #{release_path}/config/production.sphinx.conf"
36 | run "ln -nfs #{shared_path}/assets #{release_path}/public/assets"
37 | run "ln -nfs #{shared_path}/db/sphinx #{release_path}/db/sphinx"
38 | end
39 |
40 | desc "Setup shared directory."
41 | task :setup_shared do
42 | run "mkdir #{shared_path}/assets"
43 | run "mkdir #{shared_path}/config"
44 | run "mkdir #{shared_path}/db"
45 | run "mkdir #{shared_path}/db/sphinx"
46 | put File.read("config/examples/database.yml"), "#{shared_path}/config/database.yml"
47 | put File.read("config/examples/app_config.yml"), "#{shared_path}/config/app_config.yml"
48 | put File.read("config/examples/production.sphinx.conf"), "#{shared_path}/config/production.sphinx.conf"
49 | puts "Now edit the config files and fill assets folder in #{shared_path}."
50 | end
51 |
52 | desc "Sync the public/assets directory."
53 | task :assets do
54 | system "rsync -vr --exclude='.DS_Store' public/assets #{user}@#{application}:/var/apps/railscasts/shared/"
55 | end
56 |
57 | desc "Make sure there is something to deploy"
58 | task :check_revision, :roles => :web do
59 | unless `git rev-parse HEAD` == `git rev-parse origin/master`
60 | puts "WARNING: HEAD is not the same as origin/master"
61 | puts "Run `git push` to sync changes."
62 | exit
63 | end
64 | end
65 | end
66 |
67 | before "deploy", "deploy:check_revision"
68 | after "deploy", "deploy:cleanup" # keeps only last 5 releases
69 | after "deploy:setup", "deploy:setup_shared"
70 | after "deploy:update_code", "deploy:symlink_extras"
71 | before "deploy:update_code", "thinking_sphinx:stop"
72 | after "deploy:update_code", "thinking_sphinx:start"
73 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the rails application
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the rails application
5 | Railscasts::Application.initialize!
6 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Railscasts::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the webserver when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Log error messages when you accidentally call methods on nil.
10 | config.whiny_nils = true
11 |
12 | # Show full error reports and disable caching
13 | config.consider_all_requests_local = true
14 | config.action_view.debug_rjs = true
15 | config.action_controller.perform_caching = false
16 |
17 | # Don't care if the mailer can't send
18 | config.action_mailer.raise_delivery_errors = false
19 |
20 | # Print deprecation notices to the Rails logger
21 | config.active_support.deprecation = :log
22 |
23 | # Only use best-standards-support built into browsers
24 | config.action_dispatch.best_standards_support = :builtin
25 |
26 | config.action_mailer.default_url_options = { :host => "railscasts.dev" }
27 | end
28 |
29 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Railscasts::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # The production environment is meant for finished, "live" apps.
5 | # Code is not reloaded between requests
6 | config.cache_classes = true
7 |
8 | # Full error reports are disabled and caching is turned on
9 | config.consider_all_requests_local = false
10 | config.action_controller.perform_caching = true
11 |
12 | # Specifies the header that your server uses for sending files
13 | config.action_dispatch.x_sendfile_header = "X-Sendfile"
14 |
15 | # For nginx:
16 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17 |
18 | # If you have no front-end server that supports something like X-Sendfile,
19 | # just comment this out and Rails will serve the files
20 |
21 | # See everything in the log (default is :info)
22 | config.log_level = :warn
23 |
24 | # Use a different logger for distributed setups
25 | # config.logger = SyslogLogger.new
26 |
27 | # Use a different cache store in production
28 | # config.cache_store = :mem_cache_store
29 |
30 | # Disable Rails's static asset server
31 | # In production, Apache or nginx will already do this
32 | config.serve_static_assets = false
33 |
34 | # Enable serving of images, stylesheets, and javascripts from an asset server
35 | # config.action_controller.asset_host = "http://assets.example.com"
36 |
37 | # Disable delivery errors, bad email addresses will be ignored
38 | # config.action_mailer.raise_delivery_errors = false
39 |
40 | # Enable threaded mode
41 | # config.threadsafe!
42 |
43 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44 | # the I18n.default_locale when a translation can not be found)
45 | config.i18n.fallbacks = true
46 |
47 | # Send deprecation notices to registered listeners
48 | config.active_support.deprecation = :notify
49 |
50 | config.action_mailer.delivery_method = :sendmail
51 | ignore_exceptions = ExceptionNotifier.default_ignore_exceptions + [ActionView::MissingTemplate]
52 | config.middleware.use ExceptionNotifier, :email_prefix => "[ERROR] ", :sender_address => 'noreply@railscasts.com', :exception_recipients => "ryan@railscasts.com", :ignore_exceptions => ignore_exceptions
53 |
54 | config.action_mailer.default_url_options = { :host => "railscasts.com" }
55 | end
56 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Railscasts::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Log error messages when you accidentally call methods on nil.
11 | config.whiny_nils = true
12 |
13 | # Show full error reports and disable caching
14 | config.consider_all_requests_local = true
15 | config.action_controller.perform_caching = false
16 |
17 | # Raise exceptions instead of rendering exception templates
18 | config.action_dispatch.show_exceptions = false
19 |
20 | # Disable request forgery protection in test environment
21 | config.action_controller.allow_forgery_protection = false
22 |
23 | # Tell Action Mailer not to deliver emails to the real world.
24 | # The :test delivery method accumulates sent emails in the
25 | # ActionMailer::Base.deliveries array.
26 | config.action_mailer.delivery_method = :test
27 |
28 | # Use SQL instead of Active Record's schema dumper when creating the test database.
29 | # This is necessary if your schema can't be completely dumped by the schema dumper,
30 | # like if you have constraints or database-specific column types
31 | # config.active_record.schema_format = :sql
32 |
33 | # Print deprecation notices to the stderr
34 | config.active_support.deprecation = :stderr
35 |
36 | config.action_mailer.default_url_options = { :host => "www.example.com" }
37 | end
38 |
--------------------------------------------------------------------------------
/config/examples/app_config.yml:
--------------------------------------------------------------------------------
1 | session_key: "_railscasts_session"
2 | session_secret: 40bc73b6a7be494f7de7d9d3b27a3cd81b1d7857f1fbc48445222d728677cb2378f93a96b780542d9fbf92bc18725556d3320ef4d21f4394b7c6b9f94705f78b
3 | thinking_sphinx: false
4 | github_id: oauth_id
5 | github_secret: oauth_secret
6 |
--------------------------------------------------------------------------------
/config/examples/database.yml:
--------------------------------------------------------------------------------
1 | # MySQL. Versions 4.1 and 5.0 are recommended.
2 | #
3 | # Install the MySQL driver:
4 | # gem install mysql2
5 | #
6 | # And be sure to use new-style password hashing:
7 | # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
8 | development:
9 | adapter: mysql2
10 | encoding: utf8
11 | reconnect: false
12 | database: railscasts_development
13 | pool: 5
14 | username: root
15 | password:
16 | host: localhost
17 |
18 | # Warning: The database defined as "test" will be erased and
19 | # re-generated from your development database when you run "rake".
20 | # Do not set this db to the same as development or production.
21 | test:
22 | adapter: mysql2
23 | encoding: utf8
24 | reconnect: false
25 | database: railscasts_test
26 | pool: 5
27 | username: root
28 | password:
29 | host: localhost
30 |
31 | production:
32 | adapter: mysql2
33 | encoding: utf8
34 | reconnect: false
35 | database: railscasts_production
36 | pool: 5
37 | username: root
38 | password:
39 | host: localhost
40 |
--------------------------------------------------------------------------------
/config/examples/production.sphinx.conf:
--------------------------------------------------------------------------------
1 | indexer
2 | {
3 | mem_limit = 64M
4 | }
5 |
6 | searchd
7 | {
8 | address = 127.0.0.1
9 | port = 3312
10 | log = /var/apps/railscasts/shared/log/searchd.log
11 | query_log = /var/apps/railscasts/shared/log/searchd.query.log
12 | read_timeout = 5
13 | max_children = 30
14 | pid_file = /var/apps/railscasts/shared/log/searchd.development.pid
15 | max_matches = 1000
16 | }
17 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format
4 | # (all these examples are active by default):
5 | # ActiveSupport::Inflector.inflections do |inflect|
6 | # inflect.plural /^(ox)$/i, '\1en'
7 | # inflect.singular /^(ox)en/i, '\1'
8 | # inflect.irregular 'person', 'people'
9 | # inflect.uncountable %w( fish sheep )
10 | # end
11 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 | # Mime::Type.register_alias "text/html", :iphone
6 |
--------------------------------------------------------------------------------
/config/initializers/omniauth.rb:
--------------------------------------------------------------------------------
1 | Rails.application.config.middleware.use OmniAuth::Builder do
2 | # Sign up at https://github.com/account/applications
3 | provider :github, APP_CONFIG["github_id"], APP_CONFIG["github_secret"]
4 | end
5 |
--------------------------------------------------------------------------------
/config/initializers/secret_token.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 | # Make sure the secret is at least 30 characters and all random,
6 | # no regular words or you'll be exposed to dictionary attacks.
7 | Railscasts::Application.config.secret_token = APP_CONFIG['session_secret']
8 |
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Railscasts::Application.config.session_store :cookie_store, :key => APP_CONFIG['session_key']
4 |
5 | # Use the database for sessions instead of the cookie-based default,
6 | # which shouldn't be used to store highly confidential information
7 | # (create the session table with "rails generate session_migration")
8 | # Railscasts::Application.config.session_store :active_record_store
9 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Sample localization file for English. Add more files in this directory for other locales.
2 | # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3 |
4 | en:
5 | hello: "Hello world"
6 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Railscasts::Application.routes.draw do
2 | root :to => "episodes#index"
3 |
4 | match "auth/:provider/callback" => "users#create"
5 | match "about" => "info#about", :as => "about"
6 | match "give_back" => "info#give_back", :as => "give_back"
7 | match "moderators" => "info#moderators", :as => "moderators"
8 | match "login" => "users#login", :as => "login"
9 | match "logout" => "users#logout", :as => "logout"
10 | match "feedback" => "feedback_messages#new", :as => "feedback"
11 | match "episodes/archive" => redirect("/?view=list")
12 | match 'unsubscribe/:token' => 'users#unsubscribe', :as => "unsubscribe"
13 | post "versions/:id/revert" => "versions#revert", :as => "revert_version"
14 |
15 | resources :users do
16 | member { put :ban }
17 | end
18 | resources :comments
19 | resources :episodes
20 | resources :feedback_messages
21 |
22 | match "tags/:id" => redirect("/?tag_id=%{id}")
23 | end
24 |
--------------------------------------------------------------------------------
/config/schedule.rb:
--------------------------------------------------------------------------------
1 | every 1.day, :at => "2:34 am" do
2 | rake "thinking_sphinx:index"
3 | end
4 |
5 | every 1.day, :at => "1:15 am" do
6 | rake "asciicasts"
7 | end
8 |
9 | every :reboot do
10 | rake "thinking_sphinx:start"
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20080509050853_create_episodes.rb:
--------------------------------------------------------------------------------
1 | class CreateEpisodes < ActiveRecord::Migration
2 | def self.up
3 | create_table :episodes do |t|
4 | t.string :name
5 | t.string :permalink
6 | t.text :description
7 | t.text :notes
8 | t.datetime :published_at
9 | t.timestamps
10 | end
11 | end
12 |
13 | def self.down
14 | drop_table :episodes
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/db/migrate/20080620015230_create_tags.rb:
--------------------------------------------------------------------------------
1 | class CreateTags < ActiveRecord::Migration
2 | def self.up
3 | create_table :tags do |t|
4 | t.string :name
5 | t.timestamps
6 | end
7 | end
8 |
9 | def self.down
10 | drop_table :tags
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/db/migrate/20080620015432_create_taggings.rb:
--------------------------------------------------------------------------------
1 | class CreateTaggings < ActiveRecord::Migration
2 | def self.up
3 | create_table :taggings do |t|
4 | t.belongs_to :episode
5 | t.belongs_to :tag
6 | t.timestamps
7 | end
8 | end
9 |
10 | def self.down
11 | drop_table :taggings
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/db/migrate/20080620022227_create_comments.rb:
--------------------------------------------------------------------------------
1 | class CreateComments < ActiveRecord::Migration
2 | def self.up
3 | create_table :comments do |t|
4 | t.belongs_to :episode
5 | t.text :content
6 | t.string :name
7 | t.string :email
8 | t.string :site_url
9 | t.string :user_ip
10 | t.string :user_agent
11 | t.string :referrer
12 | t.timestamps
13 | end
14 | end
15 |
16 | def self.down
17 | drop_table :comments
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/db/migrate/20080702045900_add_position_to_episodes.rb:
--------------------------------------------------------------------------------
1 | class AddPositionToEpisodes < ActiveRecord::Migration
2 | def self.up
3 | add_column :episodes, :position, :integer, :default => 0
4 | Episode.all.each_with_index { |e, i| e.update_attribute(:position, i+1) }
5 | end
6 |
7 | def self.down
8 | remove_column :episodes, :position
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20080721011326_create_downloads.rb:
--------------------------------------------------------------------------------
1 | class CreateDownloads < ActiveRecord::Migration
2 | def self.up
3 | create_table :downloads do |t|
4 | t.integer :episode_id
5 | t.string :url
6 | t.string :format
7 | t.integer :bytes
8 | t.integer :seconds
9 | t.timestamps
10 | end
11 | end
12 |
13 | def self.down
14 | drop_table :downloads
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/db/migrate/20080722025256_create_sponsors.rb:
--------------------------------------------------------------------------------
1 | class CreateSponsors < ActiveRecord::Migration
2 | def self.up
3 | create_table :sponsors do |t|
4 | t.string :name
5 | t.boolean :active, :default => false, :null => false
6 | t.string :site_url
7 | t.string :image_url
8 | t.timestamps
9 | end
10 | end
11 |
12 | def self.down
13 | drop_table :sponsors
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/db/migrate/20080727044942_add_foreign_key_indexes.rb:
--------------------------------------------------------------------------------
1 | class AddForeignKeyIndexes < ActiveRecord::Migration
2 | def self.up
3 | add_index :comments, :episode_id
4 | add_index :downloads, :episode_id
5 | add_index :taggings, :episode_id
6 | add_index :taggings, :tag_id
7 | end
8 |
9 | def self.down
10 | remove_index :comments, :episode_id
11 | remove_index :downloads, :episode_id
12 | remove_index :taggings, :episode_id
13 | remove_index :taggings, :tag_id
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/db/migrate/20080730035149_add_comments_count_to_episodes.rb:
--------------------------------------------------------------------------------
1 | class AddCommentsCountToEpisodes < ActiveRecord::Migration
2 | def self.up
3 | add_column :episodes, :comments_count, :integer, :default => 0, :null => false
4 | execute "UPDATE episodes SET comments_count=(SELECT COUNT(*) FROM comments WHERE episode_id=episodes.id)"
5 | end
6 |
7 | def self.down
8 | remove_column :episodes, :comments_count
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20080820014608_add_position_to_comments.rb:
--------------------------------------------------------------------------------
1 | class AddPositionToComments < ActiveRecord::Migration
2 | def self.up
3 | add_column :comments, :position, :integer
4 |
5 | # terribly inefficient, but it gets the job done.
6 | Episode.all.each do |episode|
7 | episode.comments.each_with_index do |comment, index|
8 | comment.update_attribute :position, index+1
9 | end
10 | end
11 | end
12 |
13 | def self.down
14 | remove_column :comments, :position
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/db/migrate/20090128014441_add_force_top_to_sponsors.rb:
--------------------------------------------------------------------------------
1 | class AddForceTopToSponsors < ActiveRecord::Migration
2 | def self.up
3 | add_column :sponsors, :force_top, :boolean, :default => false, :null => false
4 | end
5 |
6 | def self.down
7 | remove_column :sponsors, :force_top
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20090228183216_add_seconds_to_episodes.rb:
--------------------------------------------------------------------------------
1 | class AddSecondsToEpisodes < ActiveRecord::Migration
2 | def self.up
3 | add_column :episodes, :seconds, :integer
4 | Episode.reset_column_information
5 | Episode.all(:include => :downloads).each do |episode|
6 | # there are more efficient ways to do this, but it is just a one time deal so it's okay.
7 | episode.update_attribute(:seconds, episode.downloads.first.seconds)
8 | end
9 | end
10 |
11 | def self.down
12 | remove_column :episodes, :seconds
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/db/migrate/20090228184049_remove_seconds_from_downloads.rb:
--------------------------------------------------------------------------------
1 | class RemoveSecondsFromDownloads < ActiveRecord::Migration
2 | def self.up
3 | remove_column :downloads, :seconds
4 | end
5 |
6 | def self.down
7 | add_column :downloads, :seconds, :integer
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20090311165121_create_spam_reports.rb:
--------------------------------------------------------------------------------
1 | class CreateSpamReports < ActiveRecord::Migration
2 | def self.up
3 | create_table :spam_reports do |t|
4 | t.integer :comment_id
5 | t.string :comment_ip
6 | t.string :comment_site_url
7 | t.string :comment_name
8 | t.string :user_ip
9 | t.datetime :confirmed_at
10 | t.timestamps
11 | end
12 | end
13 |
14 | def self.down
15 | drop_table :spam_reports
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/db/migrate/20090311181239_add_hit_count_to_spam_reports.rb:
--------------------------------------------------------------------------------
1 | class AddHitCountToSpamReports < ActiveRecord::Migration
2 | def self.up
3 | add_column :spam_reports, :hit_count, :integer
4 | end
5 |
6 | def self.down
7 | remove_column :spam_reports, :hit_count
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20090318164300_remove_user_ip_from_spam_reports.rb:
--------------------------------------------------------------------------------
1 | class RemoveUserIpFromSpamReports < ActiveRecord::Migration
2 | def self.up
3 | remove_column :spam_reports, :user_ip
4 | end
5 |
6 | def self.down
7 | add_column :spam_reports, :user_ip, :string
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20090403023001_add_asciicasts_to_episodes.rb:
--------------------------------------------------------------------------------
1 | class AddAsciicastsToEpisodes < ActiveRecord::Migration
2 | def self.up
3 | add_column :episodes, :asciicasts, :boolean, :default => false, :null => false
4 | end
5 |
6 | def self.down
7 | remove_column :episodes, :asciicasts
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20091121172820_create_spam_checks.rb:
--------------------------------------------------------------------------------
1 | class CreateSpamChecks < ActiveRecord::Migration
2 | def self.up
3 | create_table :spam_checks do |t|
4 | t.string :regexp
5 | t.integer :weight
6 | t.timestamps
7 | end
8 | end
9 |
10 | def self.down
11 | drop_table :spam_checks
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/db/migrate/20091121181751_create_spam_questions.rb:
--------------------------------------------------------------------------------
1 | class CreateSpamQuestions < ActiveRecord::Migration
2 | def self.up
3 | create_table :spam_questions do |t|
4 | t.string :question
5 | t.string :answer
6 | t.timestamps
7 | end
8 | end
9 |
10 | def self.down
11 | drop_table :spam_questions
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/db/migrate/20101117191759_create_users.rb:
--------------------------------------------------------------------------------
1 | class CreateUsers < ActiveRecord::Migration
2 | def self.up
3 | create_table :users do |t|
4 | t.string :token
5 | t.string :name
6 | t.string :github_username
7 | t.string :email
8 | t.string :site_url
9 | t.string :avatar_url
10 | t.boolean :admin
11 | t.timestamps
12 | end
13 | end
14 |
15 | def self.down
16 | drop_table :users
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/db/migrate/20101209224952_add_github_uid_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddGithubUidToUsers < ActiveRecord::Migration
2 | def self.up
3 | add_column :users, :github_uid, :string
4 | end
5 |
6 | def self.down
7 | remove_column :users, :github_uid
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20101209230056_rename_avatar_url_to_gravatar_token.rb:
--------------------------------------------------------------------------------
1 | class RenameAvatarUrlToGravatarToken < ActiveRecord::Migration
2 | def self.up
3 | rename_column :users, :avatar_url, :gravatar_token
4 | end
5 |
6 | def self.down
7 | rename_column :users, :gravatar_token, :avatar_url
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20101210220007_add_user_id_to_comments.rb:
--------------------------------------------------------------------------------
1 | class AddUserIdToComments < ActiveRecord::Migration
2 | def self.up
3 | add_column :comments, :user_id, :integer
4 | end
5 |
6 | def self.down
7 | remove_column :comments, :user_id
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110416201115_add_ancestry_to_comments.rb:
--------------------------------------------------------------------------------
1 | class AddAncestryToComments < ActiveRecord::Migration
2 | def self.up
3 | add_column :comments, :ancestry, :string
4 | add_index :comments, :ancestry
5 | end
6 |
7 | def self.down
8 | remove_column :comments, :ancestry
9 | remove_index :comments, :ancestry
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20110416214833_add_legacy_to_episodes.rb:
--------------------------------------------------------------------------------
1 | class AddLegacyToEpisodes < ActiveRecord::Migration
2 | def self.up
3 | add_column :episodes, :legacy, :boolean, :default => false, :null => false
4 | end
5 |
6 | def self.down
7 | remove_column :episodes, :legacy
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110416232852_create_feedback_messages.rb:
--------------------------------------------------------------------------------
1 | class CreateFeedbackMessages < ActiveRecord::Migration
2 | def self.up
3 | create_table :feedback_messages do |t|
4 | t.string :name
5 | t.string :email
6 | t.string :concerning
7 | t.text :content
8 | t.timestamps
9 | end
10 | end
11 |
12 | def self.down
13 | drop_table :feedback_messages
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/db/migrate/20110421060544_cleanup.rb:
--------------------------------------------------------------------------------
1 | class Cleanup < ActiveRecord::Migration
2 | def self.up
3 | drop_table :downloads
4 | drop_table :spam_questions
5 | drop_table :spam_checks
6 | drop_table :spam_reports
7 | drop_table :sponsors
8 | remove_column :feedback_messages, :concerning
9 | end
10 |
11 | def self.down
12 | create_table "downloads" do |t|
13 | t.integer "episode_id"
14 | t.string "url"
15 | t.string "format"
16 | t.integer "bytes"
17 | t.datetime "created_at"
18 | t.datetime "updated_at"
19 | end
20 | add_index "downloads", ["episode_id"], :name => "index_downloads_on_episode_id"
21 |
22 | add_column :feedback_messages, :concerning, :string
23 |
24 | create_table "spam_checks" do |t|
25 | t.string "regexp"
26 | t.integer "weight"
27 | t.datetime "created_at"
28 | t.datetime "updated_at"
29 | end
30 |
31 | create_table "spam_questions" do |t|
32 | t.string "question"
33 | t.string "answer"
34 | t.datetime "created_at"
35 | t.datetime "updated_at"
36 | end
37 |
38 | create_table "spam_reports" do |t|
39 | t.integer "comment_id"
40 | t.string "comment_ip"
41 | t.string "comment_site_url"
42 | t.string "comment_name"
43 | t.datetime "confirmed_at"
44 | t.datetime "created_at"
45 | t.datetime "updated_at"
46 | t.integer "hit_count"
47 | end
48 |
49 | create_table "sponsors" do |t|
50 | t.string "name"
51 | t.boolean "active", :default => false, :null => false
52 | t.string "site_url"
53 | t.string "image_url"
54 | t.datetime "created_at"
55 | t.datetime "updated_at"
56 | t.boolean "force_top", :default => false, :null => false
57 | end
58 | end
59 | end
60 |
--------------------------------------------------------------------------------
/db/migrate/20110423184218_add_legacy_to_comments.rb:
--------------------------------------------------------------------------------
1 | class AddLegacyToComments < ActiveRecord::Migration
2 | def self.up
3 | add_column :comments, :legacy, :boolean, :default => false, :null => false
4 | end
5 |
6 | def self.down
7 | remove_column :comments, :legacy
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110503025228_add_file_sizes_to_episodes.rb:
--------------------------------------------------------------------------------
1 | class AddFileSizesToEpisodes < ActiveRecord::Migration
2 | def self.up
3 | add_column :episodes, :file_sizes, :text
4 | end
5 |
6 | def self.down
7 | remove_column :episodes, :file_sizes
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110504180955_add_hidden_to_comments.rb:
--------------------------------------------------------------------------------
1 | class AddHiddenToComments < ActiveRecord::Migration
2 | def self.up
3 | add_column :comments, :hidden, :boolean, :default => false, :null => false
4 | end
5 |
6 | def self.down
7 | remove_column :comments, :hidden
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110630221611_create_versions.rb:
--------------------------------------------------------------------------------
1 | class CreateVersions < ActiveRecord::Migration
2 | def self.up
3 | create_table :versions do |t|
4 | t.string :item_type, :null => false
5 | t.integer :item_id, :null => false
6 | t.string :event, :null => false
7 | t.string :whodunnit
8 | t.text :object
9 | t.datetime :created_at
10 | end
11 | add_index :versions, [:item_type, :item_id]
12 | end
13 |
14 | def self.down
15 | remove_index :versions, [:item_type, :item_id]
16 | drop_table :versions
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/db/migrate/20110630234413_add_moderator_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddModeratorToUsers < ActiveRecord::Migration
2 | def self.up
3 | add_column :users, :moderator, :boolean, :default => false, :null => false
4 | end
5 |
6 | def self.down
7 | remove_column :users, :moderator
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110701001805_add_banned_at_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddBannedAtToUsers < ActiveRecord::Migration
2 | def self.up
3 | add_column :users, :banned_at, :datetime
4 | end
5 |
6 | def self.down
7 | remove_column :users, :banned_at
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110701025738_remove_hidden_from_comments.rb:
--------------------------------------------------------------------------------
1 | class RemoveHiddenFromComments < ActiveRecord::Migration
2 | def self.up
3 | remove_column :comments, :hidden
4 | end
5 |
6 | def self.down
7 | add_column :comments, :hidden, :boolean, :default => false, :null => false
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20110725215614_add_email_on_reply_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddEmailOnReplyToUsers < ActiveRecord::Migration
2 | def self.up
3 | add_column :users, :email_on_reply, :boolean, :default => false, :null => false
4 | add_column :users, :unsubscribe_token, :string
5 | end
6 |
7 | def self.down
8 | remove_column :users, :unsubscribe_token
9 | remove_column :users, :email_on_reply
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # encoding: UTF-8
2 | # This file is auto-generated from the current state of the database. Instead
3 | # of editing this file, please use the migrations feature of Active Record to
4 | # incrementally modify your database, and then regenerate this schema definition.
5 | #
6 | # Note that this schema.rb definition is the authoritative source for your
7 | # database schema. If you need to create the application database on another
8 | # system, you should be using db:schema:load, not running all the migrations
9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10 | # you'll amass, the slower it'll run and the greater likelihood for issues).
11 | #
12 | # It's strongly recommended to check this file into your version control system.
13 |
14 | ActiveRecord::Schema.define(:version => 20110725215614) do
15 |
16 | create_table "comments", :force => true do |t|
17 | t.integer "episode_id"
18 | t.text "content"
19 | t.string "name"
20 | t.string "email"
21 | t.string "site_url"
22 | t.string "user_ip"
23 | t.string "user_agent"
24 | t.string "referrer"
25 | t.datetime "created_at"
26 | t.datetime "updated_at"
27 | t.integer "position"
28 | t.integer "user_id"
29 | t.string "ancestry"
30 | t.boolean "legacy", :default => false, :null => false
31 | end
32 |
33 | add_index "comments", ["ancestry"], :name => "index_comments_on_ancestry"
34 | add_index "comments", ["episode_id"], :name => "index_comments_on_episode_id"
35 |
36 | create_table "episodes", :force => true do |t|
37 | t.string "name"
38 | t.string "permalink"
39 | t.text "description"
40 | t.text "notes"
41 | t.datetime "published_at"
42 | t.datetime "created_at"
43 | t.datetime "updated_at"
44 | t.integer "position", :default => 0
45 | t.integer "comments_count", :default => 0, :null => false
46 | t.integer "seconds"
47 | t.boolean "asciicasts", :default => false, :null => false
48 | t.boolean "legacy", :default => false, :null => false
49 | t.text "file_sizes"
50 | end
51 |
52 | create_table "feedback_messages", :force => true do |t|
53 | t.string "name"
54 | t.string "email"
55 | t.text "content"
56 | t.datetime "created_at"
57 | t.datetime "updated_at"
58 | end
59 |
60 | create_table "taggings", :force => true do |t|
61 | t.integer "episode_id"
62 | t.integer "tag_id"
63 | t.datetime "created_at"
64 | t.datetime "updated_at"
65 | end
66 |
67 | add_index "taggings", ["episode_id"], :name => "index_taggings_on_episode_id"
68 | add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
69 |
70 | create_table "tags", :force => true do |t|
71 | t.string "name"
72 | t.datetime "created_at"
73 | t.datetime "updated_at"
74 | end
75 |
76 | create_table "users", :force => true do |t|
77 | t.string "token"
78 | t.string "name"
79 | t.string "github_username"
80 | t.string "email"
81 | t.string "site_url"
82 | t.string "gravatar_token"
83 | t.boolean "admin"
84 | t.datetime "created_at"
85 | t.datetime "updated_at"
86 | t.string "github_uid"
87 | t.boolean "moderator", :default => false, :null => false
88 | t.datetime "banned_at"
89 | t.boolean "email_on_reply", :default => false, :null => false
90 | t.string "unsubscribe_token"
91 | end
92 |
93 | create_table "versions", :force => true do |t|
94 | t.string "item_type", :null => false
95 | t.integer "item_id", :null => false
96 | t.string "event", :null => false
97 | t.string "whodunnit"
98 | t.text "object"
99 | t.datetime "created_at"
100 | end
101 |
102 | add_index "versions", ["item_type", "item_id"], :name => "index_versions_on_item_type_and_item_id"
103 |
104 | end
105 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7 | # Mayor.create(:name => 'Daley', :city => cities.first)
8 |
--------------------------------------------------------------------------------
/lib/code_formatter.rb:
--------------------------------------------------------------------------------
1 | class CodeFormatter
2 | def initialize(text)
3 | @text = text
4 | end
5 |
6 | def to_html
7 | text = @text.clone
8 | codes = []
9 | text.gsub!(/^``` ?(.*?)\r?\n(.+?)\r?\n```\r?$/m) do |match|
10 | code = { :id => "CODE#{codes.size}ENDCODE", :name => ($1.empty? ? nil : $1), :content => $2 }
11 | codes << code
12 | "\n\n#{code[:id]}\n\n"
13 | end
14 | html = Redcarpet.new(text, :filter_html, :hard_wrap, :autolink, :no_intraemphasis).to_html
15 | codes.each do |code|
16 | html.sub!("
25 | EOS
26 | end
27 | end
28 | html
29 | end
30 |
31 | def language(path)
32 | case path.to_s.strip
33 | when /\.yml$/ then "yaml"
34 | when /\.js$/ then "java_script"
35 | when /\.scss$/ then "css"
36 | when /\.erb$/, /\.html$/ then "rhtml"
37 | when /\.rb$/, /\.rake$/, /\.gemspec/, /file$/, /console$/, "rails" then "ruby"
38 | when /([a-z0-9]+)$/i then $1
39 | else "text"
40 | end
41 | end
42 |
43 | def clippy(text)
44 | id = "clippy_#{rand(10000000)}"
45 | <<-EOS
46 |
47 | #{CGI.escapeHTML(text)}
48 |
49 |
57 |
58 | EOS
59 | end
60 | end
61 |
--------------------------------------------------------------------------------
/lib/tasks/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryanb/railscasts/010f1927c9ccb9604d0af1c6326419bd5371b56c/lib/tasks/.gitkeep
--------------------------------------------------------------------------------
/lib/tasks/application.rake:
--------------------------------------------------------------------------------
1 | desc "Check if ASCIIcasts are available for episodes."
2 | task :asciicasts => :environment do
3 | require 'thinking_sphinx' # for some reason this isn't being loaded in the environment
4 | Episode.all(:conditions => { :asciicasts => false }).each do |episode|
5 | response = Net::HTTP.get_response(URI.parse("http://asciicasts.com/episodes/#{episode.to_param}"))
6 | episode.update_attribute(:asciicasts, true) if response.code == "200"
7 | sleep 3 # so we don't hammer the server
8 | end
9 | end
10 |
11 | desc "Reset position attribute for all comments, sometimes it gets out of sync"
12 | task :reset_comment_positions => :environment do
13 | Episode.find_each do |episode|
14 | episode.comments.all(:order => "created_at").each_with_index do |comment, index|
15 | comment.update_attribute(:position, index+1)
16 | end
17 | episode.update_attribute(:comments_count, episode.comments.count)
18 | end
19 | end
20 |
21 | desc "Fix the code blocks in all episodes"
22 | task :fix_episodes => :environment do
23 | Episode.find_each do |episode|
24 | notes = episode.notes.dup
25 | notes.gsub!("\r\n", "\n")
26 | notes.gsub!(/^\/\* (.+) \*\/$|^\<\!\-\- (.+) \-\-\>$|^\# (.+)$|^\/\/ (.+)$/) do |match|
27 | path = $1 || $2 || $3 || $4
28 | if path =~ /\.\w+$/ || path =~ /file$/ || path =~ /console$/
29 | "@@@\n\n@@@ #{path}"
30 | else
31 | match
32 | end
33 | end
34 | notes.gsub!("\n\n@@@\n", "\n@@@\n")
35 | notes.gsub!(/@@@ .+\n@@@\n\n/, "")
36 | notes.gsub!("@@@", "```")
37 | notes.gsub!(/\*(\w+?)\*/, '**\1**')
38 | notes.gsub!("**\n* ", "**\n\n* ")
39 | notes.gsub!(/"(.+?)"\:(\S+)/, '[\1](\2)')
40 | notes.gsub!("\n", "\r\n")
41 | episode.notes = notes
42 | episode.legacy = true
43 | episode.save!
44 | end
45 | end
46 |
47 | desc "Mark legacy comments"
48 | task :fix_comments => :environment do
49 | Comment.update_all(:legacy => true)
50 | end
51 |
52 | desc "Fill the episode file size values"
53 | task :episode_file_sizes => :environment do
54 | Episode.order("position desc").each do |episode|
55 | episode.load_file_sizes
56 | sleep 1
57 | puts "File sizes for episode #{episode.position}: #{episode.file_sizes.inspect}"
58 | episode.save!
59 | end
60 | end
61 |
--------------------------------------------------------------------------------
/log/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ryanb/railscasts/010f1927c9ccb9604d0af1c6326419bd5371b56c/log/.gitignore
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Not Found - RailsCasts
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |