Skip to content

Commit

Permalink
Initial upgrade to rails 3
Browse files Browse the repository at this point in the history
Ran rails new
Fixed a few deprecated helpers
Fixed the requires
Sesssion store config
New will_paginate plugin (as gem)
  • Loading branch information
johnl committed Jun 8, 2012
1 parent dfa4b08 commit 2694186
Show file tree
Hide file tree
Showing 87 changed files with 3,961 additions and 5,623 deletions.
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
source :rubygems

gem "rack"
gem "rails", "2.3.11"
gem "rails", "3.0.6"
gem "mysql"
gem "simple-rss"
gem 'will_paginate', '~> 3.0'

# requires ubuntu packages libcurl3 libcurl3-gnutls libcurl4-openssl-dev
gem "curb", "0.8.0"
Expand Down
87 changes: 67 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,37 +1,83 @@
GEM
remote: http://rubygems.org/
specs:
actionmailer (2.3.11)
actionpack (= 2.3.11)
actionpack (2.3.11)
activesupport (= 2.3.11)
rack (~> 1.1.0)
activerecord (2.3.11)
activesupport (= 2.3.11)
activeresource (2.3.11)
activesupport (= 2.3.11)
activesupport (2.3.11)
abstract (1.0.0)
actionmailer (3.0.6)
actionpack (= 3.0.6)
mail (~> 2.2.15)
actionpack (3.0.6)
activemodel (= 3.0.6)
activesupport (= 3.0.6)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
rack (~> 1.2.1)
rack-mount (~> 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.6)
activesupport (= 3.0.6)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.6)
activemodel (= 3.0.6)
activesupport (= 3.0.6)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.6)
activemodel (= 3.0.6)
activesupport (= 3.0.6)
activesupport (3.0.6)
arel (2.0.10)
builder (2.1.2)
curb (0.8.0)
diff-lcs (1.1.3)
erubis (2.6.6)
abstract (>= 1.0.0)
htmlentities (4.3.1)
i18n (0.5.0)
json (1.6.5)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.18)
mysql (2.8.1)
oniguruma (1.1.0)
rack (1.1.2)
rails (2.3.11)
actionmailer (= 2.3.11)
actionpack (= 2.3.11)
activerecord (= 2.3.11)
activeresource (= 2.3.11)
activesupport (= 2.3.11)
rake (>= 0.8.3)
polyglot (0.3.3)
rack (1.2.5)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.6)
actionmailer (= 3.0.6)
actionpack (= 3.0.6)
activerecord (= 3.0.6)
activeresource (= 3.0.6)
activesupport (= 3.0.6)
bundler (~> 1.0)
railties (= 3.0.6)
railties (3.0.6)
actionpack (= 3.0.6)
activesupport (= 3.0.6)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.9.2.2)
rdoc (3.11)
json (~> 1.4)
simple-rss (1.2.3)
sqlite3 (1.3.6)
thor (0.14.6)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
web-page-parser (0.25)
htmlentities (>= 4.0.0)
oniguruma (>= 1.1.0)
will_paginate (3.0.3)
xapian-fu (1.3.2)

PLATFORMS
Expand All @@ -41,9 +87,10 @@ DEPENDENCIES
curb (= 0.8.0)
diff-lcs (= 1.1.3)
mysql
rack
rails (= 2.3.11)
rails (= 3.0.6)
rdoc
simple-rss
sqlite3
web-page-parser (= 0.25)
will_paginate (~> 3.0)
xapian-fu (= 1.3.2)
7 changes: 2 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +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 'rdoc/task'

require 'tasks/rails'
NewsSniffer::Application.load_tasks
3 changes: 2 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# News Sniffer
# Copyright (C) 2007-2008 John Leach
# Copyright (C) 2007-2012 John Leach
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
Expand All @@ -18,6 +18,7 @@
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all
protect_from_forgery

layout 'newsniffer'

Expand Down
1 change: 1 addition & 0 deletions app/controllers/versions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require "diff_html"
class VersionsController < ApplicationController

def index
Expand Down
4 changes: 2 additions & 2 deletions app/models/news_article.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# News Sniffer
# Copyright (C) 2007-2009 John Leach
# Copyright (C) 2007-2012 John Leach
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
Expand Down Expand Up @@ -27,7 +27,7 @@ class NewsArticle < ActiveRecord::Base

before_validation :set_initial_next_check_period, :unless => :next_check_after?

named_scope :due_check, lambda {
scope :due_check, lambda {
{
:order => 'next_check_after asc',
:conditions => ["check_period < ? AND next_check_after < ?", 40.days.to_i, Time.now.utc],
Expand Down
18 changes: 17 additions & 1 deletion app/models/news_article_feed.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
# News Sniffer
# Copyright (C) 2007-2012 John Leach
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

class NewsArticleFeed < ActiveRecord::Base
validates_presence_of :name, :url, :source
validates_uniqueness_of :name, :url
validates_numericality_of :check_period, :greater_than_or_equal_to => 300
validates_presence_of :next_check_after
before_validation :update_next_check_after, :unless => :next_check_after?

named_scope :due_check, lambda {
scope :due_check, lambda {
{
:conditions => ['next_check_after < ?', Time.now.utc]
}
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/newsniffer.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<footer>
<div id="footer">
<% cache(:footer_stats, :ttl => 2.hours) do %>
<p>Currently monitoring <%= number_with_delimiter(NewsArticle.count, ",") %> news articles
with <%= number_with_delimiter(NewsArticleVersion.count, ",") %> different versions.</p>
<p>Currently monitoring <%= number_with_delimiter(NewsArticle.count, :separator => ",") %> news articles
with <%= number_with_delimiter(NewsArticleVersion.count, :separator => ",") %> different versions.</p>
<% end %>
</div>
</footer>
Expand Down
9 changes: 1 addition & 8 deletions app/views/versions/diff.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ It last changed over 40 days ago and won't be checked again for changes.
The next check for changes will be <time datetime='<%= @article.next_check_after.iso8601 %>'><%= @article.next_check_after.to_s(:long) %></time>
<% end %>
</p>
<!--
<p>It has <span id="reccounter<%=@va.id %>"><%= @va.votes %> recommendations</span> -
<span id="recommend-<%=@va.id %>">
<%= link_to_remote 'Recommend this revision', { :url => vote_version_url(@va) },
:title => "Vote for this revision" %>.
</span>
</p>-->

<p>You can find the current article at its original source at <cite class="article_url"><%= link_to @article.url, @article.url, :rel => "alternate external author" %></cite></p>

Expand Down Expand Up @@ -80,5 +73,5 @@ diff_url(@article, version.version - 1, version.version),
(<%= distance_of_time_in_words(@vb.created_at, @va.created_at) %> <%= @va.created_at > @vb.created_at ? "later" : "earlier" %>)
</td>
</tr>
<%= @diff %>
<%= raw @diff %>
</table>
4 changes: 4 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run NewsSniffer::Application
66 changes: 66 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Put this in config/application.rb
require File.expand_path('../boot', __FILE__)

require 'rails/all'

Bundler.require(:default, Rails.env) if defined?(Bundler)

module NewsSniffer
class Application < Rails::Application
config.autoload_paths += [config.root.join('lib')]
config.encoding = 'utf-8'
# 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.
# You have to specify the :lib option for libraries, where the Gem name (sqlite3-ruby) differs from the file itself (sqlite3)
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "sqlite3-ruby", :lib => "sqlite3"
# 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. Comment line to use default local time.
config.time_zone = 'UTC'


# The internationalization framework can be changed to have another default locale (standard is :en) or more load paths.
# All files from config/locales/*.rb,yml are added automatically.
# config.i18n.load_path << Dir[File.join(RAILS_ROOT, 'my', 'locales', '*.{rb,yml}')]
# config.i18n.default_locale = :de

# 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
# Please note that observers generated using script/generate observer need to have an _observer suffix
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
end
end
Loading

0 comments on commit 2694186

Please sign in to comment.