Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial work in getting to Rails 3

  • Loading branch information...
commit 69eec430045595b8b2913cfb905a74e2db6735ee 1 parent d47af88
Tim Morgan seven1m authored
Showing with 5,985 additions and 2,661 deletions.
  1. +2 −2 .gitignore
  2. +1 −0  .rvmrc
  3. +6 −0 BROKEN.md
  4. +22 −0 Gemfile
  5. +111 −0 Gemfile.lock
  6. +9 −11 Rakefile
  7. +3 −2 app/controllers/application_controller.rb
  8. +1 −1  app/models/family.rb
  9. +2 −2 app/models/group.rb
  10. +1 −1  app/models/message.rb
  11. +2 −2 app/models/person.rb
  12. +5 −1 app/models/relationship.rb
  13. +4 −0 config.ru
  14. +36 −0 config/application.rb
  15. +13 −109 config/boot.rb
  16. +4 −36 config/environment.rb
  17. +21 −15 config/environments/development.rb
  18. +44 −13 config/environments/production.rb
  19. +35 −33 config/environments/test.rb
  20. +2 −1  config/initializers/_libs.rb
  21. +2 −3 config/initializers/_settings.rb
  22. +7 −0 config/initializers/backtrace_silencers.rb
  23. +1 −1  config/initializers/date_time.rb
  24. +10 −0 config/initializers/inflections.rb
  25. +7 −0 config/initializers/secret_token.rb
  26. +8 −0 config/initializers/session_store.rb
  27. +0 −23 config/initializers/sessions_patch.rb
  28. +214 −107 config/routes.rb
  29. +7 −0 db/seeds.rb
  30. +0 −12 features/news/flag.feature
  31. +0 −8 features/news/manage.feature
  32. +0 −47 features/news/submit.feature
  33. +0 −15 features/step_definitions/news_steps.rb
  34. +0 −5 features/step_definitions/session_steps.rb
  35. +0 −8 features/step_definitions/setting_steps.rb
  36. +0 −119 features/step_definitions/webrat_steps.rb
  37. +0 −18 features/support/env.rb
  38. +0 −29 features/support/paths.rb
  39. +2 −1  lib/db_tools.rb
  40. +6 −0 lib/rake_abandon.rb
  41. 0  lib/tasks/.gitkeep
  42. +0 −15 lib/tasks/cucumber.rake
  43. +22 −6 public/404.html
  44. +26 −0 public/422.html
  45. +22 −8 public/500.html
  46. BIN  public/images/rails.png
  47. +0 −12 public/javascripts/application.js
  48. +5 −3 public/javascripts/controls.js
  49. +7 −6 public/javascripts/dragdrop.js
  50. +8 −13 public/javascripts/effects.js
  51. +3,381 −1,700 public/javascripts/prototype.js
  52. +175 −0 public/javascripts/rails.js
  53. +5 −1 public/robots.txt
  54. 0  public/stylesheets/.gitkeep
  55. +0 −3  script/about
  56. +0 −3  script/breakpointer
  57. +0 −3  script/console
  58. +0 −8 script/cucumber
  59. +0 −3  script/dbconsole
  60. +0 −3  script/destroy
  61. +0 −3  script/generate
  62. +0 −3  script/performance/benchmarker
  63. +0 −3  script/performance/profiler
  64. +0 −3  script/performance/request
  65. +0 −3  script/plugin
  66. +0 −3  script/process/inspector
  67. +0 −3  script/process/reaper
  68. +0 −3  script/process/spawner
  69. +6 −0 script/rails
  70. +0 −3  script/runner
  71. +0 −3  script/server
  72. +0 −113 script/sync
  73. +0 −93 script/twitter
  74. +9 −0 test/performance/browsing_test.rb
  75. +5 −8 test/test_helper.rb
  76. +0 −2  test/unit/notifier_test.rb
  77. 0  vendor/plugins/.gitkeep
  78. +3 −3 vendor/plugins/acts_as_scoped_globally/lib/acts_as_scoped_globally.rb
  79. +20 −0 vendor/plugins/rails_upgrade/MIT-LICENSE
  80. +20 −0 vendor/plugins/rails_upgrade/README
  81. +22 −0 vendor/plugins/rails_upgrade/Rakefile
  82. +2 −0  vendor/plugins/rails_upgrade/init.rb
  83. +38 −0 vendor/plugins/rails_upgrade/install.rb
  84. +472 −0 vendor/plugins/rails_upgrade/lib/application_checker.rb
  85. +95 −0 vendor/plugins/rails_upgrade/lib/gemfile_generator.rb
  86. +51 −0 vendor/plugins/rails_upgrade/lib/new_configuration_generator.rb
  87. 0  vendor/plugins/rails_upgrade/lib/rails_upgrade.rb
  88. +349 −0 vendor/plugins/rails_upgrade/lib/routes_upgrader.rb
  89. +78 −0 vendor/plugins/rails_upgrade/lib/tasks/rails_upgrade_tasks.rake
  90. +293 −0 vendor/plugins/rails_upgrade/test/application_checker_test.rb
  91. +72 −0 vendor/plugins/rails_upgrade/test/gemfile_generator_test.rb
  92. +63 −0 vendor/plugins/rails_upgrade/test/new_configuration_generator_test.rb
  93. +142 −0 vendor/plugins/rails_upgrade/test/routes_upgrader_test.rb
  94. +5 −0 vendor/plugins/rails_upgrade/test/test_helper.rb
  95. +1 −0  vendor/plugins/rails_upgrade/uninstall.rb
4 .gitignore
View
@@ -1,4 +1,4 @@
-db/*.db
+.bundle
db/schema.rb
db/*.sql
db/*.backup.*
@@ -18,4 +18,4 @@ vendor/plugins/query_reviewer
pkg
*.deb
script/package
-db/bible.web.osis.xml
+db/bible.web.osis.xml
1  .rvmrc
View
@@ -0,0 +1 @@
+rvm use ree@rails3
6 BROKEN.md
View
@@ -0,0 +1,6 @@
+= Stuff that's broken/disabled for OneBody@rails3
+
+* feedzirra (not Rails 3 compatible)
+* whenever (maybe Rails 3 compatible)
+* `config.plugin_paths`
+* csv serialization `lib/csv_serialization.rb`
22 Gemfile
View
@@ -0,0 +1,22 @@
+source 'http://rubygems.org'
+
+gem 'rails', ' 3.0.0'
+gem 'mysql', '~> 2.8.1'
+gem 'liquid', '~> 2.0.0'
+gem 'highline', '~> 1.6.1'
+gem 'mini_magick', '>= 1.2.5'
+gem 'campaign_monitor_party', '>= 0.2.1'
+# FIXME
+#gem 'whenever', '~> 0.4.0'
+gem 'nokogiri', '~> 1.4.0'
+gem 'builder', '>= 2.1.2'
+# FIXME
+#gem 'feedzirra', '>= 0.0.23'
+gem 'fastercsv', '~> 1.5.0'
+gem 'pdf-writer', '~> 1.1.8', :require => 'pdf/writer'
+gem 'rubyzip', '~> 0.9.4', :require => 'zip/zip'
+
+group :development, :test do
+ gem 'faker', '>= 0.3.1'
+ gem 'shoulda', '~> 2.11.3'
+end
111 Gemfile.lock
View
@@ -0,0 +1,111 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ abstract (1.0.0)
+ actionmailer (3.0.0)
+ actionpack (= 3.0.0)
+ mail (~> 2.2.5)
+ actionpack (3.0.0)
+ activemodel (= 3.0.0)
+ activesupport (= 3.0.0)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.4.1)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.12)
+ rack-test (~> 0.5.4)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.0)
+ activesupport (= 3.0.0)
+ builder (~> 2.1.2)
+ i18n (~> 0.4.1)
+ activerecord (3.0.0)
+ activemodel (= 3.0.0)
+ activesupport (= 3.0.0)
+ arel (~> 1.0.0)
+ tzinfo (~> 0.3.23)
+ activeresource (3.0.0)
+ activemodel (= 3.0.0)
+ activesupport (= 3.0.0)
+ activesupport (3.0.0)
+ arel (1.0.1)
+ activesupport (~> 3.0.0)
+ builder (2.1.2)
+ campaign_monitor_party (0.2.1)
+ httparty
+ color (1.4.1)
+ crack (0.1.8)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ faker (0.3.1)
+ fastercsv (1.5.3)
+ highline (1.6.1)
+ hoe (2.6.2)
+ rake (>= 0.8.7)
+ rubyforge (>= 2.0.4)
+ httparty (0.6.1)
+ crack (= 0.1.8)
+ i18n (0.4.1)
+ json_pure (1.4.6)
+ liquid (2.0.0)
+ mail (2.2.7)
+ activesupport (>= 2.3.6)
+ mime-types
+ treetop (>= 1.4.5)
+ mime-types (1.16)
+ mini_magick (2.3)
+ subexec (~> 0.0.4)
+ mysql (2.8.1)
+ nokogiri (1.4.3.1)
+ pdf-writer (1.1.8)
+ color (>= 1.4.0)
+ transaction-simple (~> 1.3)
+ 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.0)
+ actionmailer (= 3.0.0)
+ actionpack (= 3.0.0)
+ activerecord (= 3.0.0)
+ activeresource (= 3.0.0)
+ activesupport (= 3.0.0)
+ bundler (~> 1.0.0)
+ railties (= 3.0.0)
+ railties (3.0.0)
+ actionpack (= 3.0.0)
+ activesupport (= 3.0.0)
+ rake (>= 0.8.4)
+ thor (~> 0.14.0)
+ rake (0.8.7)
+ rubyforge (2.0.4)
+ json_pure (>= 1.1.7)
+ rubyzip (0.9.4)
+ shoulda (2.11.3)
+ subexec (0.0.4)
+ thor (0.14.3)
+ transaction-simple (1.4.0)
+ hoe (>= 1.1.7)
+ treetop (1.4.8)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.23)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ builder (>= 2.1.2)
+ campaign_monitor_party (>= 0.2.1)
+ faker (>= 0.3.1)
+ fastercsv (~> 1.5.0)
+ highline (~> 1.6.1)
+ liquid (~> 2.0.0)
+ mini_magick (>= 1.2.5)
+ mysql (~> 2.8.1)
+ nokogiri (~> 1.4.0)
+ pdf-writer (~> 1.1.8)
+ rails (= 3.0.0)
+ rubyzip (~> 0.9.4)
+ shoulda (~> 2.11.3)
20 Rakefile
View
@@ -1,16 +1,14 @@
-require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+require File.expand_path('../config/application', __FILE__)
require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
+#require 'rake/testtask'
+#require 'rake/rdoctask'
-class Rake::Task
- def abandon
- prerequisites.clear
- @actions.clear
- end
-end
+require Rails.root.join('lib/rake_abandon')
-require 'tasks/rails'
+OneBody::Application.load_tasks
+
+Dir["#{Rails.root}/plugins/*/**/tasks/**/*.rake"].sort.each { |ext| load ext }
-Dir["#{RAILS_ROOT}/plugins/*/**/tasks/**/*.rake"].sort.each { |ext| load ext }
5 app/controllers/application_controller.rb
View
@@ -1,6 +1,6 @@
-# Filters added to this controller will be run for all controllers in the application.
-# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
+ #protect_from_forgery
+
include ExceptionNotifiable
cache_sweeper :stream_item_sweeper, :only => %w(create update destroy)
@@ -232,3 +232,4 @@ def can_export?
end
end
+
2  app/models/family.rb
View
@@ -49,7 +49,7 @@ class Family < ActiveRecord::Base
attr_accessible :legacy_id, :barcode_id, :alternate_barcode_id, :people_attributes, :if => Proc.new { Person.logged_in and Person.logged_in.admin?(:edit_profiles) }
has_one_photo :path => "#{DB_PHOTO_PATH}/families", :sizes => PHOTO_SIZES
- acts_as_logger LogItem
+ #acts_as_logger LogItem
alias_method 'photo_without_logging=', 'photo='
def photo=(p)
4 app/models/group.rb
View
@@ -49,7 +49,7 @@ class Group < ActiveRecord::Base
belongs_to :parents_of_group, :class_name => 'Group', :foreign_key => 'parents_of'
belongs_to :site
- named_scope :active, :conditions => {:hidden => false}
+ scope :active, :conditions => {:hidden => false}
scope_by_site_id
@@ -83,7 +83,7 @@ def photo=(p)
self.photo_without_logging = p
end
- named_scope :checkin_destinations, :include => :group_times, :conditions => ['group_times.checkin_time_id is not null'], :order => 'group_times.ordering'
+ scope :checkin_destinations, :include => :group_times, :conditions => ['group_times.checkin_time_id is not null'], :order => 'group_times.ordering'
def name_group # returns something like "Morgan group"
"#{name}#{name =~ /group$/i ? '' : ' group'}"
2  app/models/message.rb
View
@@ -75,7 +75,7 @@ def before_save
body.gsub! /http:\/\/.*?person_id=\d+&code=\d+/i, '--removed--'
end
- validate_on_create do |record|
+ validate :on => :create do |record|
if Message.find_by_person_id_and_subject_and_body(record.person_id, record.subject, record.body, :conditions => ['created_at >= ?', Date.today-1])
record.errors.add_to_base 'already saved' # Notifier relies on this message (don't change it)
end
4 app/models/person.rb
View
@@ -130,8 +130,8 @@ class Person < ActiveRecord::Base
attr_accessible :classes, :shepherd, :mail_group, :legacy_id, :account_frozen, :member, :staff, :elder, :deacon, :can_sign_in, :visible_to_everyone, :visible_on_printed_directory, :full_access, :legacy_family_id, :child, :custom_type, :custom_fields, :medical_notes, :if => Proc.new { Person.logged_in and Person.logged_in.admin?(:edit_profiles) }
attr_accessible :id, :sequence, :can_pick_up, :cannot_pick_up, :family_id, :if => Proc.new { l = Person.logged_in and l.admin?(:edit_profiles) and l.admin?(:import_data) and Person.import_in_progress }
- named_scope :unsynced_to_donortools, lambda { {:conditions => ["synced_to_donortools = ? and deleted = ? and (child = ? or birthday <= ?)", false, false, false, 18.years.ago]} }
- named_scope :can_sign_in, :conditions => {:can_sign_in => true, :deleted => false}
+ scope :unsynced_to_donortools, lambda { {:conditions => ["synced_to_donortools = ? and deleted = ? and (child = ? or birthday <= ?)", false, false, false, 18.years.ago]} }
+ scope :can_sign_in, :conditions => {:can_sign_in => true, :deleted => false}
acts_as_password
has_one_photo :path => "#{DB_PHOTO_PATH}/people", :sizes => PHOTO_SIZES
6 app/models/relationship.rb
View
@@ -20,12 +20,16 @@ class Relationship < ActiveRecord::Base
scope_by_site_id
validates_presence_of :name
- validates_inclusion_of :name, :in => I18n.t('relationships.names').keys.map { |r| r.to_s }
validates_presence_of :other_name, :if => Proc.new { |r| r.name == 'other' }
validates_presence_of :person_id
validates_presence_of :related_id
validates_uniqueness_of :name, :scope => [:other_name, :person_id, :related_id]
validates_uniqueness_of :other_name, :scope => [:name, :person_id, :related_id]
+ validates_each :name do |record, attribute, value|
+ unless I18n.t('relationships.names').keys.map { |r| r.to_s }.include?(value)
+ record.errors.add attribute, :inclusion
+ end
+ end
acts_as_logger LogItem
4 config.ru
View
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run OneBody::Application
36 config/application.rb
View
@@ -0,0 +1,36 @@
+require File.expand_path('../boot', __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 OneBody
+ class Application < Rails::Application
+ # Custom directories with classes and modules you want to be autoloadable.
+ config.autoload_paths << "#{config.root}/app/sweepers"
+
+ # Custom directory for plugins
+ # FIXME
+ #config.plugin_paths << "#{config.root}/plugins"
+
+ # Cache store location
+ config.action_controller.cache_store = [:file_store, "#{config.root}/cache"]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ config.i18n.default_locale = File.exist?("#{config.root}/config/locale") ? File.read("#{config.root}/config/locale").strip.to_sym : :en
+ config.i18n.load_path += Dir["#{config.root}/plugins/**/config/locales/*.{rb,yml}"]
+
+ # 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]
+ end
+end
+
+(Setting.update_all if Setting.table_exists?) rescue nil
122 config/boot.rb
View
@@ -1,109 +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)
- 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)
40 config/environment.rb
View
@@ -1,37 +1,5 @@
-RAILS_GEM_VERSION = '2.3.9' unless defined? RAILS_GEM_VERSION
-require File.join(File.dirname(__FILE__), 'boot')
+# Load the rails application
+require File.expand_path('../application', __FILE__)
-unless File.exist?(config_filename = "#{Rails.root}/config/database.yml")
- puts config_filename
- require 'fileutils'
- FileUtils.cp("#{config_filename}.example", config_filename)
-end
-
-Rails::Initializer.run do |config|
- config.action_controller.session_store = :active_record_store
- config.action_controller.cache_store = :file_store, "#{Rails.root}/cache"
- config.log_path = File.join(File.dirname(__FILE__), "../log/#{RAILS_ENV}.log")
- config.database_configuration_file = File.expand_path(File.join(File.dirname(__FILE__), 'database.yml'))
- config.autoload_paths << "#{Rails.root}/app/sweepers"
- config.plugin_paths << "#{Rails.root}/plugins"
- config.time_zone = 'UTC'
- config.i18n.default_locale = File.exist?("#{RAILS_ROOT}/config/locale") ? File.read("#{RAILS_ROOT}/config/locale").strip.to_sym : :en
- config.i18n.load_path << Dir["#{RAILS_ROOT}/plugins/**/config/locales/*.{rb,yml}"]
- # dependencies
- config.gem 'transaction-simple', :version => '~> 1.4.0', :lib => 'transaction/simple'
- config.gem 'color', :version => '~> 1.4.0'
- config.gem 'pdf-writer', :version => '~> 1.1.8', :lib => 'pdf/writer'
- config.gem 'liquid', :version => '~> 2.0.0'
- config.gem 'highline', :version => '~> 1.6.1'
- config.gem 'mini_magick', :version => '>= 1.2.5'
- config.gem 'campaign_monitor_party', :version => '>= 0.2.1'
- config.gem 'whenever', :version => '~> 0.4.0'
- config.gem 'nokogiri', :version => '~> 1.4.0'
- config.gem 'builder', :version => '>= 2.1.2'
- config.gem 'feedzirra', :version => '>= 0.0.23'
- config.gem 'fastercsv', :version => '~> 1.5.0'
- config.gem 'rubyzip', :version => '~> 0.9.4', :lib => 'zip/zip'
- #config.gem 'mongo', :version => '>= 1.0.1'
-end
-
-(Setting.update_all if Setting.table_exists?) rescue nil
+# Initialize the rails application
+OneBody::Application.initialize!
36 config/environments/development.rb
View
@@ -1,20 +1,26 @@
-# Settings specified here will take precedence over those in config/environment.rb
+OneBody::Application.configure do
+ # Settings specified here will take precedence over those in config/environment.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
-# Enable the breakpoint server that script/breakpointer connects to
-#config.breakpoint_server = true
+ # 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
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_controller.perform_caching = true
-config.action_view.debug_rjs = true
+ # 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
57 config/environments/production.rb
View
@@ -1,18 +1,49 @@
-# Settings specified here will take precedence over those in config/environment.rb
+OneBody::Application.configure do
+ # Settings specified here will take precedence over those in config/environment.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
+ # Specifies the header that your server uses for sending files
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
-# Enable serving of images, stylesheets, and javascripts from an asset server
-# config.action_controller.asset_host = "http://assets.example.com"
+ # For nginx:
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
-# Disable delivery errors if you bad email addresses should just be ignored
-# config.action_mailer.raise_delivery_errors = false
+ # If you have no front-end server that supports something like X-Sendfile,
+ # just comment this out and Rails will serve the files
+
+ # 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
68 config/environments/test.rb
View
@@ -1,33 +1,35 @@
-# Settings specified here will take precedence over those in config/environment.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
-
-# 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
-
-# Tell ActionMailer 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
-
-config.gem 'faker', :version => '>= 0.3.1'
-config.gem 'shoulda', :version => '>= 2.10.2'
-
-# these have to be loaded a bit earlier than usual
-# don't really know why
-require "#{Rails.root}/config/initializers/paths"
-require "#{Rails.root}/config/initializers/photos"
-require "#{Rails.root}/config/initializers/email"
-
-config.action_controller.session = {
- :key => "_onebody_session",
- :secret => "not so secret - this is only here for the test environment"
-}
+OneBody::Application.configure do
+ # Settings specified here will take precedence over those in config/environment.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
+
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
3  config/initializers/_libs.rb
View
@@ -9,7 +9,8 @@
require 'date_tools'
require 'cache_extensions'
require 'csv'
-require 'csv_serialization'
+# FIXME
+#require 'csv_serialization'
require 'openssl'
require 'base64'
require 'digest/sha1'
5 config/initializers/_settings.rb
View
@@ -1,5 +1,4 @@
-ActiveRecord::Base.connection rescue nil
-if RAILS_ENV == 'test' and ActiveRecord::Base.connected?
+if Rails.env.test? and ActiveRecord::Base.connected?
%w(settings sites).each do |file|
model = eval(file.singularize.classify)
next unless model.table_exists?
@@ -13,4 +12,4 @@
Site.current = Site.find(1) if Site.table_exists?
end
-SETTINGS = {}
+SETTINGS = {}
7 config/initializers/backtrace_silencers.rb
View
@@ -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!
2  config/initializers/date_time.rb
View
@@ -1,4 +1,4 @@
-ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
+Time::DATE_FORMATS.merge!(
:default => "%m/%d/%Y %I:%M %p",
:date => "%m/%d/%Y",
:time => "%I:%M %p",
10 config/initializers/inflections.rb
View
@@ -0,0 +1,10 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format
+# (all these examples are active by default):
+# ActiveSupport::Inflector.inflections do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
7 config/initializers/secret_token.rb
View
@@ -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.
+OneBody::Application.config.secret_token = '97230925d117b4c2959e6077b16e53dbdc25816582db8ad90985481b740d0cbe57d13bd648add18387e7bbd026696a2ef7b145a47488975d1a91ccadfb039ce3'
8 config/initializers/session_store.rb
View
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+OneBody::Application.config.session_store :cookie_store, :key => '_onebody_session'
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rake db:sessions:create")
+# OneBody::Application.config.session_store :active_record_store
23 config/initializers/sessions_patch.rb
View
@@ -1,23 +0,0 @@
-# patch for Rails 2.3.9 (ticket #5581)
-# (drop in your config/initializers/ dir)
-affected = %w[ActiveRecord::SessionStore ActionController::Session::MemCacheStore]
-
-target = Rails.configuration.middleware.detect do |mid|
- mid.klass.is_a? Class and affected.include? mid.klass.to_s
-end
-
-if target
- class RailsCookieMonster
- def initialize(app)
- @app = app
- end
-
- def call(env)
- # monster MUST HAVE COOKIES om nom nom nom
- env['HTTP_COOKIE'] ||= ""
- @app.call(env)
- end
- end
-
- Rails.configuration.middleware.insert_before target, RailsCookieMonster
-end
321 config/routes.rb
View
@@ -1,130 +1,237 @@
-ActionController::Routing::Routes.draw do |map|
-
- PHOTO_SIZE_METHODS = {:tn => :get, :small => :get, :medium => :get, :large => :get}
-
- map.home '', :controller => 'pages', :action => 'show_for_public'
-
- map.resource :setup
-
- map.resource :stream
-
- map.resource :account, :member => {:verify_code => :any, :select => :any}
-
- map.resources :people,
- :collection => {:import => :any, :hashify => :post, :schema => :get, :batch => :post},
- :member => {:favs => :get, :testimony => :get} do |people|
- people.resources :groups
- people.resources :pictures
- people.resources :friends, :collection => {:reorder => :post}
- people.resources :relationships, :collection => {:batch => :post}
- people.resources :groupies
- people.resources :services
- people.resources :albums
- people.resources :feeds
- people.resources :notes
- people.resources :verses
- people.resources :recipes
- people.resources :contributions, :collection => {:sync => [:get, :post]}
- people.resource :account, :member => {:verify_code => :any, :select => :any}
- people.resource :privacy
- people.resource :blog
- people.resource :wall, :member => {:with => :get}
- people.resource :photo, :member => PHOTO_SIZE_METHODS
- people.resource :calendar
- end
+OneBody::Application.routes.draw do
- map.resources :families,
- :collection => {:hashify => :post, :schema => :get, :batch => :post, :select => :post},
- :member => {:reorder => :post} do |families|
- families.resources :relationships
- families.resource :photo, :member => PHOTO_SIZE_METHODS
- end
+ root :to => 'pages#show_for_public'
- map.resources :groups,
- :collection => {:batch => :any} do |groups|
- groups.resources :memberships, :collection => {:batch => :any}, :has_one => :privacy
- groups.resources :notes
- groups.resources :messages, :collection => {:new => :any}
- groups.resources :prayer_requests
- groups.resources :attendance, :collection => {:batch => :post}
- groups.resources :albums
- groups.resources :attachments
- groups.resource :photo, :member => PHOTO_SIZE_METHODS
- groups.resource :calendar
+ resource :account do
+ member do
+ get :verify_code
+ post :verify_code
+ get :select
+ post :select
+ end
end
- map.resources :memberships, :collection => {:batch => :any}
+ resources :people do
+ collection do
+ get :schema
+ get :import
+ post :import
+ post :hashfiy
+ post :batch
+ end
+ member do
+ get :favs
+ get :testimony
+ end
+ resources :friends do
+ collection do
+ post :reorder
+ end
+ end
+ resources :relationships do
+ collection do
+ post :batch
+ end
+ end
+ resources :contributions do
+ collection do
+ get :sync
+ post :sync
+ end
+ end
+ resource :account do
+ member do
+ get :verify_code
+ post :verify_code
+ get :select
+ post :select
+ end
+ end
+ resource :wall do
+ member do
+ get :with
+ end
+ end
+ resource :photo do
+ member do
+ get :tn
+ get :small
+ get :medium
+ get :large
+ end
+ end
+ resources :groups, :pictures, :groupies, :services, :albums, :feeds, :notes, :verses, :recipes
+ resource :privacy, :blog, :calendar
+ end
- map.resources :contributions, :collection => {:sync => [:get, :post]}
+ resources :families do
+ collection do
+ get :schema
+ post :hashfiy
+ post :batch
+ post :select
+ end
+ member do
+ post :reorder
+ end
+ resource :photo do
+ member do
+ get :tn
+ get :small
+ get :medium
+ get :large
+ end
+ end
+ resources :relationships
+ end
- map.resources :service_categories, :collection => {:batch_edit => :get, :close_batch_edit => :get}
+ resources :groups do
+ collection do
+ get :batch
+ post :batch
+ end
+ resources :memberships do
+ collection do
+ get :batch
+ post :batch
+ end
+ resource :privacy
+ end
+ resources :messages do
+ collection do
+ post :new
+ end
+ end
+ resources :attendance do
+ collection do
+ post :batch
+ end
+ end
+ resource :photo do
+ member do
+ get :tn
+ get :small
+ get :medium
+ get :large
+ end
+ end
+ resources :notes, :prayer_requests, :albums, :attachments
+ resource :calendar
+ end
- map.resources :albums do |albums|
- albums.resources :pictures, :member => {:next => :get, :prev => :get} do |pictures|
- pictures.resource :photo, :member => PHOTO_SIZE_METHODS
+ resources :memberships do
+ collection do
+ get :batch
+ post :batch
end
end
- map.resources :pictures
+ resources :contributions do
+ collection do
+ get :sync
+ post :sync
+ end
+ end
- map.resources :prayer_signups
+ resources :service_categories do
+ collection do
+ get :batch_edit
+ get :close_batch_edit
+ end
+ end
- map.resources :recipes do |recipes|
- recipes.resource :photo, :member => PHOTO_SIZE_METHODS
+ resources :albums do
+ resources :pictures do
+ member do
+ get :next
+ get :prev
+ end
+ resource :photo do
+ member do
+ get :tn
+ get :small
+ get :medium
+ get :large
+ end
+ end
+ end
end
- map.resources :messages do |messages|
- messages.resources :attachments
+ resources :recipes do
+ resource :photo do
+ member do
+ get :tn
+ get :small
+ get :medium
+ get :large
+ end
+ end
end
- map.resources :authentications
- map.resources :feeds
- map.resources :verses
- map.resources :publications
- map.resources :notes
- map.resources :tags
- map.resources :news, :singular => 'news_item'
- map.resources :comments
- map.resources :attachments, :member => {:get => :get}
- map.resources :prayer_requests
- map.resources :podcasts
-
- map.resource :session
- map.resource :search
- map.resource :printable_directory
- map.resource :privacy
- map.resource :tour
-
- map.bible 'bible/:book/:chapter', :controller => 'bibles', :action => 'show',
- :book => 'x', :chapter => 0,
- :requirements => {:book => /[A-Za-z0-9 \+(%20)]+/, :chapter => /\d{1,3}/}
-
- map.resources :pages, :as => 'pages/admin' do |pages|
- pages.resources :attachments
+ resources :messages do
+ resources :attachments
end
- map.with_options :controller => 'pages' do |pages|
- pages.page_for_public 'pages/*path', :action => 'show_for_public', :conditions => {:method => :get}
+ resources :pictures, :prayer_signups, :authentications, :feeds, :verses,
+ :publications, :notes, :tags, :comments, :prayer_requests, :podcasts
+
+ resource :setup, :stream, :session, :search, :printable_directory,
+ :privacy, :tour, :pc_sync
+
+ resources :news, :as => :news_item
+
+ resources :attachments do
+ member do
+ get :get
+ end
end
- map.resource :pc_sync
-
- map.resource :admin, :controller => 'administration/dashboards'
- map.namespace :administration, :path_prefix => 'admin' do |admin|
- admin.resource :api_key
- admin.resource :logo
- admin.resources :updates
- admin.resources :emails, :collection => {:batch => :put}
- admin.resources :admins
- admin.resources :membership_requests
- admin.resources :log_items, :collection => {:batch => :put}
- admin.resources :settings, :collection => {:batch => :put, :reload => :put}
- admin.resources :files, :requirements => {:id => /[a-z0-9_]+(\.[a-z0-9_]+)?/}
- admin.resources :attendance, :collection => {:prev => :get, :next => :get}
- admin.resources :syncs, :member => {:create_items => :post}
- admin.resources :deleted_people, :collection => {:batch => :put}
- admin.resources :reports
- admin.resource :theme
+ match 'bible/:book/:chapter', :to => 'bibles#show', :as => :bible,
+ :defaults => {:book => 'x', :chapter => 0},
+ :constraints => {:book => /[A-Za-z0-9 \+(%20)]+/, :chapter => /\d{1,3}/}
+
+ resources :pages, :path => 'pages/admin' do
+ resources :attachments
end
+ match 'pages/*path' => 'pages#show_for_public', :via => :get, :as => :page_for_public
+
+ namespace :admin, :as => :administration do
+ match '/' => 'dashboards#show'
+ resources :emails do
+ collection do
+ put :batch
+ end
+ end
+ resources :log_items do
+ collection do
+ put :batch
+ end
+ end
+ resources :settings do
+ collection do
+ put :batch
+ put :reload
+ end
+ end
+ resources :files, :constraints => {:id => /[a-z0-9_]+(\.[a-z0-9_]+)?/}
+ resources :attendance do
+ collection do
+ get :prev
+ get :next
+ end
+ end
+ resources :syncs do
+ member do
+ post :create_items
+ end
+ end
+ resources :deleted_people do
+ collection do
+ put :batch
+ end
+ end
+ resources :updates, :admins, :membership_requests, :reports
+ resource :theme, :api_key, :logo
+ end
end
7 db/seeds.rb
View
@@ -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)
12 features/news/flag.feature
View
@@ -1,12 +0,0 @@
-Feature: Flag Inappropriate News
- In order to help keep the site clean and safe
- As a user
- I want to flag (and remove) inappropriate submissions
-
- Scenario: Inappropriate submissions get flagged
-
- Scenario: Submissions with many flags are automatically hidden
-
- Scenario: Hidden items are not visible to users on the site
-
- Scenario: Hidden items are visible to admins on the site
8 features/news/manage.feature
View
@@ -1,8 +0,0 @@
-Feature: Admins Manage News
- In order to manage submissions and maintain the site
- As an admin
- I want to edit or delete any submission
-
- Scenario: Edit any submission
-
- Scenario: Delete any submission
47 features/news/submit.feature
View
@@ -1,47 +0,0 @@
-Feature: Users Submit News
- In order to share news and information
- As a user
- I want to submit news
-
- Background:
- Given setting "News Page" in category "Features" is enabled
- And setting "News by Users" in category "Features" is enabled
- And I am signed in as a user
-
- Scenario: User sees no news when there are no posts
- Given there are no news items
- When I go to news
- Then I should see "No news is available at this time."
-
- Scenario: User sees news when there is a post
- Given there is a news item with title "A News Post" and body "This is the first news post."
- When I go to news
- Then I should see "A News Post"
- And I should see "This is the first news post."
-
- Scenario: User submits news
- When I go to new news submission
- And I fill in "Give your post a concise title" with "My News Item"
- And I fill in "Share your announcement, information, or news here" with "This is my first news post."
- And I press "Submit News"
- Then I should see "Your news has been submitted."
- When I go to news
- Then I should see "My News Item"
- And I should see "This is my first news post."
-
- Scenario: User edits own news post
- When I go to new news submission
- And I fill in "Give your post a concise title" with "My News Item"
- And I fill in "Share your announcement, information, or news here" with "This is my first news post."
- And I press "Submit News"
- Then I go to news
- And I should see "edit"
- When I click "edit" on the news item "My News Item"
- Then I should see "Edit News Post"
- And I fill in "Give your post a concise title" with "My Updated News Item"
- And I fill in "Share your announcement, information, or news here" with "This is my first news post, and it has been edited."
- And I press "Submit News"
- Then I should see "Your news has been updated."
- When I go to news
- Then I should see "My Updated News Item"
- And I should see "This is my first news post, and it has been edited."
15 features/step_definitions/news_steps.rb
View
@@ -1,15 +0,0 @@
-Given /^there are no news items$/ do
-end
-
-Given /^there is a news item with title "([^\"]*)" and body "([^\"]*)"$/ do |title, body|
- NewsItem.create!(
- :title => title,
- :body => body
- )
-end
-
-When /^I click "([^\"]*)" on the news item "([^\"]*)"$/ do |link, title|
- response.should have_selector(".news-item a")
- click_link_within(".news-item[:first]", "edit")
-end
-
5 features/step_definitions/session_steps.rb
View
@@ -1,5 +0,0 @@
-Given /^I am signed in as a user$/ do
- @person = Person.forge
- post '/session', :email => @person.email, :password => @person.password
- response.should be_redirect
-end
8 features/step_definitions/setting_steps.rb
View
@@ -1,8 +0,0 @@
-Given /^setting "([^\"]*)" in category "([^\"]*)" is (.+)$/ do |name, category, value|
- value = case value
- when 'enabled' then true
- when 'disabled' then false
- else value
- end
- Setting.set(Site.current.id, category, name, value)
-end
119 features/step_definitions/webrat_steps.rb
View
@@ -1,119 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
-
-# Commonly used webrat steps
-# http://github.com/brynary/webrat
-
-Given /^I am on (.+)$/ do |page_name|
- visit path_to(page_name)
-end
-
-When /^I go to (.+)$/ do |page_name|
- visit path_to(page_name)
-end
-
-When /^I press "([^\"]*)"$/ do |button|
- click_button(button)
-end
-
-When /^I follow "([^\"]*)"$/ do |link|
- click_link(link)
-end
-
-When /^I click "([^\"]*)"$/ do |link|
- click_link(link)
-end
-
-When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
- fill_in(field, :with => value)
-end
-
-When /^I select "([^\"]*)" from "([^\"]*)"$/ do |value, field|
- select(value, :from => field)
-end
-
-# Use this step in conjunction with Rail's datetime_select helper. For example:
-# When I select "December 25, 2008 10:00" as the date and time
-When /^I select "([^\"]*)" as the date and time$/ do |time|
- select_datetime(time)
-end
-
-# Use this step when using multiple datetime_select helpers on a page or
-# you want to specify which datetime to select. Given the following view:
-# <%= f.label :preferred %><br />
-# <%= f.datetime_select :preferred %>
-# <%= f.label :alternative %><br />
-# <%= f.datetime_select :alternative %>
-# The following steps would fill out the form:
-# When I select "November 23, 2004 11:20" as the "Preferred" data and time
-# And I select "November 25, 2004 10:30" as the "Alternative" data and time
-When /^I select "([^\"]*)" as the "([^\"]*)" date and time$/ do |datetime, datetime_label|
- select_datetime(datetime, :from => datetime_label)
-end
-
-# Use this step in conjunction with Rail's time_select helper. For example:
-# When I select "2:20PM" as the time
-# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
-# will convert the 2:20PM to 14:20 and then select it.
-When /^I select "([^\"]*)" as the time$/ do |time|
- select_time(time)
-end
-
-# Use this step when using multiple time_select helpers on a page or you want to
-# specify the name of the time on the form. For example:
-# When I select "7:30AM" as the "Gym" time
-When /^I select "([^\"]*)" as the "([^\"]*)" time$/ do |time, time_label|
- select_time(time, :from => time_label)
-end
-
-# Use this step in conjunction with Rail's date_select helper. For example:
-# When I select "February 20, 1981" as the date
-When /^I select "([^\"]*)" as the date$/ do |date|
- select_date(date)
-end
-
-# Use this step when using multiple date_select helpers on one page or
-# you want to specify the name of the date on the form. For example:
-# When I select "April 26, 1982" as the "Date of Birth" date
-When /^I select "([^\"]*)" as the "([^\"]*)" date$/ do |date, date_label|
- select_date(date, :from => date_label)
-end
-
-When /^I check "([^\"]*)"$/ do |field|
- check(field)
-end
-
-When /^I uncheck "([^\"]*)"$/ do |field|
- uncheck(field)
-end
-
-When /^I choose "([^\"]*)"$/ do |field|
- choose(field)
-end
-
-When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field|
- attach_file(field, path)
-end
-
-Then /^I should see "([^\"]*)"$/ do |text|
- response.should contain(text)
-end
-
-Then /^I should not see "([^\"]*)"$/ do |text|
- response.should_not contain(text)
-end
-
-Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
- field_labeled(field).value.should =~ /#{value}/
- end
-
-Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
- field_labeled(field).value.should_not =~ /#{value}/
- end
-
-Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
- field_labeled(label).should be_checked
-end
-
-Then /^I should be on (.+)$/ do |page_name|
- URI.parse(current_url).path.should == path_to(page_name)
-end
18 features/support/env.rb
View
@@ -1,18 +0,0 @@
-# Sets up the Rails environment for Cucumber
-ENV["RAILS_ENV"] ||= "test"
-require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
-require 'cucumber/rails/world'
-require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
-Cucumber::Rails.use_transactional_fixtures
-Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own error handling
- # (e.g. rescue_action_in_public / rescue_responses / rescue_from)
-
-require 'webrat'
-require 'test/forgeries'
-
-Webrat.configure do |config|
- config.mode = :rails
-end
-
-require 'cucumber/rails/rspec'
-require 'webrat/core/matchers'
29 features/support/paths.rb
View
@@ -1,29 +0,0 @@
-module NavigationHelpers
- # Maps a name to a path. Used by the
- #
- # When /^I go to (.+)$/ do |page_name|
- #
- # step definition in webrat_steps.rb
- #
- def path_to(page_name)
- case page_name
-
- when 'news'
- news_path
- when 'new news submission'
- new_news_item_path
-
- # Add more mappings here.
- # Here is a more fancy example:
- #
- # when /^(.*)'s profile page$/i
- # user_profile_path(User.find_by_login($1))
-
- else
- raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
- "Now, go and add a mapping in #{__FILE__}"
- end
- end
-end
-
-World(NavigationHelpers)
3  lib/db_tools.rb
View
@@ -29,7 +29,8 @@ def sql_random
class ActiveRecord::Base
def self.scope_by_site_id
- acts_as_scoped_globally 'site_id', "(Site.current ? Site.current.id : 0)"
+ #acts_as_scoped_globally 'site_id', "(Site.current ? Site.current.id : 0)"
+ default_scope lambda { where(:site_id => Site.current.id) }
end
def self.hashify(options)
6 lib/rake_abandon.rb
View
@@ -0,0 +1,6 @@
+class Rake::Task
+ def abandon
+ prerequisites.clear
+ @actions.clear
+ end
+end
0  lib/tasks/.gitkeep
View
No changes.
15 lib/tasks/cucumber.rake
View
@@ -1,15 +0,0 @@
-$LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib')
-
-begin
- require 'cucumber/rake/task'
-
- Cucumber::Rake::Task.new(:features) do |t|
- t.cucumber_opts = "--format pretty"
- end
- task :features => 'db:test:prepare'
-rescue LoadError
- desc 'Cucumber rake task not available'
- task :features do
- abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
- end
-end
28 public/404.html
View
@@ -1,10 +1,26 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
+<!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>
- <h1>Oops. We can't find what you're looking for.</h1>
- <p>There is no file/object at this address. If you typed the
- address instead of clicking a link, make sure you spelled
- everything correctly.</p>
+ <!-- This file lives in public/404.html -->
+ <div class="dialog">
+ <h1>The page you were looking for doesn't exist.</h1>
+ <p>You may have mistyped the address or the page may have moved.</p>
+ </div>
</body>
</html>
26 public/422.html
View
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>The change you wanted was rejected (422)</title>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/422.html -->
+ <div class="dialog">
+ <h1>The change you wanted was rejected.</h1>
+ <p>Maybe you tried to change something you didn't have access to.</p>
+ </div>
+</body>
+</html>
30 public/500.html
View
@@ -1,12 +1,26 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
+<!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>
- <h1>Oops. There was an error.</h1>
- <p>The site is feeling a bit sick right now. Feel free to click back
- and try again. If you keep getting this message, give us a few minutes
- to get things back in order, and try again later.</p>
- <p>A detailed report of this error has been sent to the people
- who fix things.</p>
+ <!-- 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>
BIN  public/images/rails.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 public/javascripts/application.js
View
@@ -1,14 +1,2 @@
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
-
-function custom_select_val(select_elm, prompt_text){
- if(val = prompt(prompt_text, '')) {
- var option = document.createElement('option');
- option.setAttribute('value', val);
- option.innerHTML = val;
- option.selected = true;
- select_elm.appendChild(option);
- } else {
- select_elm.options[0].selected = true;
- }
-};
8 public/javascripts/controls.js
View
@@ -1,6 +1,8 @@
-// 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)
+// script.aculo.us controls.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005-2009 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
+// (c) 2005-2009 Jon Tirsen (http://www.tirsen.com)
// Contributors:
// Richard Livsey
// Rahul Bhargava
13 public/javascripts/dragdrop.js
View
@@ -1,5 +1,6 @@
-// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
-// (c) 2005-2008 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
+// script.aculo.us dragdrop.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// 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/
@@ -311,7 +312,7 @@ var Draggable = Class.create({
tag_name=='TEXTAREA')) return;
var pointer = [Event.pointerX(event), Event.pointerY(event)];
- var pos = Position.cumulativeOffset(this.element);
+ var pos = this.element.cumulativeOffset();
this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
Draggables.activate(this);
@@ -454,7 +455,7 @@ var Draggable = Class.create({
},
draw: function(point) {
- var pos = Position.cumulativeOffset(this.element);
+ var pos = this.element.cumulativeOffset();
if(this.options.ghosting) {
var r = Position.realOffset(this.element);
pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
@@ -730,7 +731,7 @@ var Sortable = {
}
// keep reference
- this.sortables[element.id] = options;
+ this.sortables[element.identify()] = options;
// for onupdate
Draggables.addObserver(new SortableObserver(element, options.onUpdate));
@@ -825,7 +826,7 @@ var Sortable = {
hide().addClassName('dropmarker').setStyle({position:'absolute'});
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
}
- var offsets = Position.cumulativeOffset(dropon);
+ var offsets = dropon.cumulativeOffset();
Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'});
if(position=='after')
21 public/javascripts/effects.js
View
@@ -1,4 +1,6 @@
-// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// script.aculo.us effects.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// Contributors:
// Justin Palmer (http://encytemedia.com/)
// Mark Pilgrim (http://diveintomark.org/)
@@ -145,14 +147,13 @@ var Effect = {
'blind': ['BlindDown','BlindUp'],
'appear': ['Appear','Fade']
},
- toggle: function(element, effect) {
+ toggle: function(element, effect, options) {
element = $(element);
- effect = (effect || 'appear').toLowerCase();
- var options = Object.extend({
+ effect = (effect || 'appear').toLowerCase();
+
+ return Effect[ Effect.PAIRS[ effect ][ element.visible() ? 1 : 0 ] ](element, Object.extend({
queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
- }, arguments[2] || { });
- Effect[element.visible() ?
- Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
+ }, options || {}));
}
};
@@ -228,12 +229,6 @@ Effect.Queue = Effect.Queues.get('global');
Effect.Base = Class.create({
position: null,
start: function(options) {
- function codeForEvent(options,eventName){
- return (
- (options[eventName+'Internal'] ? 'this.options.'+eventName+'Internal(this);' : '') +
- (options[eventName] ? 'this.options.'+eventName+'(this);' : '')
- );
- }
if (options && options.transition === false) options.transition = Effect.Transitions.linear;
this.options = Object.extend(Object.extend({ },Effect.DefaultOptions), options || { });
this.currentFrame = 0;
5,081 public/javascripts/prototype.js
View
3,381 additions, 1,700 deletions not shown
175 public/javascripts/rails.js
View
@@ -0,0 +1,175 @@
+(function() {
+ // Technique from Juriy Zaytsev
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+ function isEventSupported(eventName) {
+ var el = document.createElement('div');
+ eventName = 'on' + eventName;
+ var isSupported = (eventName in el);
+ if (!isSupported) {
+ el.setAttribute(eventName, 'return;');
+ isSupported = typeof el[eventName] == 'function';
+ }
+ el = null;
+ return isSupported;
+ }
+
+ function isForm(element) {
+ return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
+ }
+
+ function isInput(element) {
+ if (Object.isElement(element)) {
+ var name = element.nodeName.toUpperCase()
+ return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
+ }
+ else return false
+ }
+
+ var submitBubbles = isEventSupported('submit'),
+ changeBubbles = isEventSupported('change')
+
+ if (!submitBubbles || !changeBubbles) {
+ // augment the Event.Handler class to observe custom events when needed
+ Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
+ function(init, element, eventName, selector, callback) {
+ init(element, eventName, selector, callback)
+ // is the handler being attached to an element that doesn't support this event?
+ if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
+ (!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
+ // "submit" => "emulated:submit"
+ this.eventName = 'emulated:' + this.eventName
+ }
+ }
+ )
+ }
+
+ if (!submitBubbles) {
+ // discover forms on the page by observing focus events which always bubble
+ document.on('focusin', 'form', function(focusEvent, form) {
+ // special handler for the real "submit" event (one-time operation)
+ if (!form.retrieve('emulated:submit')) {
+ form.on('submit', function(submitEvent) {
+ var emulated = form.fire('emulated:submit', submitEvent, true)
+ // if custom event received preventDefault, cancel the real one too
+ if (emulated.returnValue === false) submitEvent.preventDefault()
+ })
+ form.store('emulated:submit', true)
+ }
+ })
+ }
+
+ if (!changeBubbles) {
+ // discover form inputs on the page
+ document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
+ // special handler for real "change" events
+ if (!input.retrieve('emulated:change')) {
+ input.on('change', function(changeEvent) {
+ input.fire('emulated:change', changeEvent, true)
+ })
+ input.store('emulated:change', true)
+ }
+ })
+ }
+
+ function handleRemote(element) {
+ var method, url, params;
+
+ var event = element.fire("ajax:before");
+ if (event.stopped) return false;
+
+ if (element.tagName.toLowerCase() === 'form') {
+ method = element.readAttribute('method') || 'post';
+ url = element.readAttribute('action');
+ params = element.serialize();
+ } else {
+ method = element.readAttribute('data-method') || 'get';
+ url = element.readAttribute('href');
+ params = {};
+ }
+
+ new Ajax.Request(url, {
+ method: method,
+ parameters: params,
+ evalScripts: true,
+
+ onComplete: function(request) { element.fire("ajax:complete", request); },
+ onSuccess: function(request) { element.fire("ajax:success", request); },
+ onFailure: function(request) { element.fire("ajax:failure", request); }
+ });
+
+ element.fire("ajax:after");
+ }
+
+ function handleMethod(element) {
+ var method = element.readAttribute('data-method'),
+ url = element.readAttribute('href'),
+ csrf_param = $$('meta[name=csrf-param]')[0],
+ csrf_token = $$('meta[name=csrf-token]')[0];
+
+ var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
+ element.parentNode.insert(form);
+
+ if (method !== 'post') {
+ var field = new Element('input', { type: 'hidden', name: '_method', value: method });
+ form.insert(field);
+ }
+
+ if (csrf_param) {
+ var param = csrf_param.readAttribute('content'),
+ token = csrf_token.readAttribute('content'),
+ field = new Element('input', { type: 'hidden', name: param, value: token });
+ form.insert(field);
+ }
+
+ form.submit();
+ }
+
+
+ document.on("click", "*[data-confirm]", function(event, element) {
+ var message = element.readAttribute('data-confirm');
+ if (!confirm(message)) event.stop();
+ });
+
+ document.on("click", "a[data-remote]", function(event, element) {
+ if (event.stopped) return;
+ handleRemote(element);
+ event.stop();
+ });
+
+ document.on("click", "a[data-method]", function(event, element) {
+ if (event.stopped) return;
+ handleMethod(element);
+ event.stop();
+ });
+
+ document.on("submit", function(event) {
+ var element = event.findElement(),
+ message = element.readAttribute('data-confirm');
+ if (message && !confirm(message)) {
+ event.stop();
+ return false;
+ }
+
+ var inputs = element.select("input[type=submit][data-disable-with]");
+ inputs.each(function(input) {
+ input.disabled = true;
+ input.writeAttribute('data-original-value', input.value);
+ input.value = input.readAttribute('data-disable-with');
+ });
+
+ var element = event.findElement("form[data-remote]");
+ if (element) {
+ handleRemote(element);
+ event.stop();
+ }
+ });
+
+ document.on("ajax:after", "form", function(event, element) {
+ var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
+ inputs.each(function(input) {
+ input.value = input.readAttribute('data-original-value');
+ input.removeAttribute('data-original-value');
+ input.disabled = false;
+ });
+ });
+})();
6 public/robots.txt
View
@@ -1 +1,5 @@
-# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
+# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
+#
+# To ban all spiders from the entire site uncomment the next two lines:
+# User-Agent: *
+# Disallow: /
0  public/stylesheets/.gitkeep
View
No changes.
3  script/about
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/about'
3  script/breakpointer
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/breakpointer'
3  script/console
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/console'
8 script/cucumber
View
@@ -1,8 +0,0 @@
-#!/usr/bin/env ruby
-begin
- load File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/cucumber/bin/cucumber")
-rescue LoadError => e
- raise unless e.to_s =~ /cucumber/
- require "rubygems"
- load File.join(Gem.bindir, "cucumber")
-end
3  script/dbconsole
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/dbconsole'
3  script/destroy
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/destroy'
3  script/generate
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/generate'
3  script/performance/benchmarker
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot'
-require 'commands/performance/benchmarker'
3  script/performance/profiler
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot'
-require 'commands/performance/profiler'
3  script/performance/request
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot'
-require 'commands/performance/request'
3  script/plugin
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/plugin'
3  script/process/inspector
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot'
-require 'commands/process/inspector'
3  script/process/reaper
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot'
-require 'commands/process/reaper'
3  script/process/spawner
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../config/boot'
-require 'commands/process/spawner'
6 script/rails
View
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
+
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require File.expand_path('../../config/boot', __FILE__)
+require 'rails/commands'
3  script/runner
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/runner'
3  script/server
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/boot'
-require 'commands/server'
113 script/sync
View
@@ -1,113 +0,0 @@
-#!/usr/bin/env ruby
-
-# usage:
-# sync [options] CONNECTOR [connector_args]
-
-# examples:
-# script/sync csv /path/to/people.csv /path/to/families.csv
-# script/sync coms /path/to/comsdata
-
-# multisite example:
-# script/sync -s "Site 1" csv /path/to/people.csv /path/to/families.csv
-
-puts '------------------------------------------'
-puts 'THIS HAS BEEN SUPERCEDED BY updateagent.rb'
-puts 'Maintenance and new development will not'
-puts 'be performed here. Use at your own risk.'
-puts '------------------------------------------'
-
-MAX_ERRORS = 10
-
-require 'optparse'
-options = {}
-parser = OptionParser.new do |opts|
- connectors = Dir[File.join(File.dirname(__FILE__), '../lib/connectors/*.rb')].to_a.map { |f| File.split(f).last.split('.').first }.select { |c| !%w(base test example).include? c }
- opts.banner = "Usage: script/sync [options] CONNECTOR [connector_args]\nAvailable Connectors: #{connectors.join(', ')}"
- opts.on("-s", '--site "Site Name"', "specify site name (if multisite enabled)") do |val|
- options[:site] = val
- end
- opts.on("-e", '--environment production', "specify environment (development, production)") do |val|
- options[:environment] = val
- end
-end
-parser.parse!
-
-unless connector_name = ARGV[0]
- puts parser.help
- exit
-end
-args = ARGV[1..-1]
-
-RAILS_ENV = options[:environment]
-
-require File.dirname(__FILE__) + '/../config/environment'
-require RAILS_ROOT + "/lib/connectors/#{connector_name}"
-
-logger = RAILS_DEFAULT_LOGGER
-
-logger.info "Initializing Sync..."
-connector = eval(connector_name.capitalize+'Connector').new(*args)
-
-unless last_update = Date.parse(ActiveRecord::Base.connection.select_one("SELECT last_update FROM sync_info")['last_update']).to_time rescue nil
- ActiveRecord::Base.connection.delete("DELETE FROM sync_info")
- ActiveRecord::Base.connection.insert("INSERT INTO sync_info (last_update) values (NULL)")
- last_update = Date.new(1970, 1, 1).to_time
-end
-
-update_time = Time.now.strftime '%Y-%m-%d %H:%M'
-
-error_count = 0
-
-if Setting.get(:features, :multisite)
- Site.current = Site.find_by_name(options[:site])
-else
- Site.current = Site.find(1)
-end
-
-logger.info "Syncing people data..."
-connector.each_person(last_update) do |person|
- begin
- p = Person.find_by_legacy_id(person[:legacy_id]) || Person.new(:legacy_id => person[:legacy_id])
- if p.email_changed?
- if person[:email] != p.email
- person.delete(:email)
- else
- person[:email_changed] = false
- end
- end
- [:mobile_phone, :work_phone, :fax].each { |a| person[a] = person[a] ? person[a].to_s.scan(/\d/).join('').to_i : nil }
- p.update_attributes!(person)
- rescue => e
- logger.error e
- error_count += 1
- if error_count > MAX_ERRORS
- raise "Too many errors. Check the log. Last error was:\n#{e}"
- end
- end
-end
-
-logger.info "Syncing family data..."
-connector.each_family(last_update) do |family|
- begin
- f = Family.find_by_legacy_id(family[:legacy_id]) || Family.new(:legacy_id => family[:legacy_id])
- family[:home_phone] = family[:home_phone] ? family[:home_phone].to_s.scan(/\d/).join('').to_i : nil
- f.update_attributes!(family)
- Person.update_all "family_id = #{f.id}", "legacy_family_id = #{f.legacy_id}"
- rescue => e
- logger.error e
- error_count += 1
- if error_count > MAX_ERRORS
- raise "Too many errors. Check the log. Last error was:\n#{e}"
- end
- end
-end
-
-logger.info "Purging data..."
-Person.destroy_all "legacy_id not in (#{connector.people_ids.join(',')})"
-Family.destroy_all "legacy_id not in (#{connector.family_ids.join(',')})"
-Person.destroy_all "(select count(*) from families where id=people.family_id) = 0"
-
-logger.info "Recording update details..."
-ActiveRecord::Base.connection.update("UPDATE sync_info SET last_update = '#{update_time}'")
-
-logger.info "Finished Sync."
93 script/twitter
View
@@ -1,93 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'rubygems'
-require 'twitter'
-require 'time'
-
-class TwitterBot
-
- def initialize(username, password, site_id)
- @twitter = Twitter::Base.new(username, password)
- @site_id = site_id
- @log_filename = File.dirname(__FILE__) + '/../log/twitter.log'
- @log = []
- load_message_log
- end
-
- def load_message_log
- # message log looks like this:
- # 20090304223501 friending seven1m
- # 20090304223601 sending seven1m bla bla bla
- @log_messages = File.read(@log_filename).split(/\n/) rescue []
- @friends = @log_messages.grep(/^\d{14} following/).map { |f| f.split(' ').last }
- @messages = @log_messages.grep(/^\d{14} received/).map { |f| f.split(' ', 5)[2] }
- end
-
- def load_env
- unless @env_loaded
- require File.join(File.dirname(__FILE__), '../config/environment')
- Site.current = Site.find(@site_id)
- @env_loaded = true
- end
- end
-
- def go!
- follow_the_followers
- respond_to_messages
- write_log_file
- end
-
- def follow_the_followers
- @twitter.followers.each do |follower|
- unless @friends.include?(follower.screen_name)
- # already following?