diff --git a/.gitignore b/.gitignore
index 1eae46ae..6a0bc337 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,17 @@
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile ~/.gitignore_global
+
+# Ignore bundler config
+/.bundle
+
+# Ignore the default SQLite database.
+/db/*.sqlite3
+
+# Ignore all logfiles and tempfiles.
+/tmp
*.swp
.DS_Store
log/
@@ -8,7 +22,6 @@ coverage*
public/warpables/*
public/warps/*
public/tms/*
-public/api/0.6/*
db/schema.rb
config/database.yml
config/amazon_s3.yml
@@ -16,6 +29,7 @@ config/initializers/recaptcha.rb
config/config.yml
config/initializers/site_keys.rb
Gemfile.lock
+# these are probably from when we used bundler with rails 2.3.x
vendor/bundler_gems/gems
vendor/bundler_gems/specifications
vendor/bundler_gems/doc
diff --git a/Gemfile b/Gemfile
index f8a89c26..f96c9636 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,18 +1,25 @@
source "https://rubygems.org"
ruby "1.9.3"
-gem "rails", "2.3.15"
+gem "rails", "~>3.2"
# dependencies
gem "mysql", "2.9.1"
-gem "geokit-rails", "1.1.4"
+gem "geokit-rails"
gem "image_science", "1.2.6"
gem "recaptcha", :require => "recaptcha/rails"
-gem "will_paginate", "2.3.16"
+gem "will_paginate"
gem "oa-openid", "0.3.2"
gem "httparty", "0.11.0"
gem "RubyInline"
-gem "rdoc"
+gem "ruby-openid"
+gem "paperclip"
+gem 'open_id_authentication'
+# if you use amazon s3 for warpable image storage
+gem 'aws-sdk', '~> 1.5.7'
+
+# for rake image migration tasks
+gem 'right_aws'
# if you decide to use sqlite3 as the database
gem "sqlite3"
diff --git a/README b/README
index 88ac644d..95e28b49 100644
--- a/README
+++ b/README
@@ -1,94 +1,77 @@
-oooo o8o . .
-`888 `"' .o8 .o8
- 888 oooo ooo. .oo. oooo .o888oo .o888oo .ooooo. oooo d8b
- 888 .8P' `888P"Y88b `888 888 888 d88' `88b `888""8P
- 888888. 888 888 888 888 888 888ooo888 888
- 888 `88b. 888 888 888 888 . 888 . 888 .o 888
-o888o o888o o888o o888o o888o "888" "888" `Y8bod8P' d888b
+MapKnitter
+Use Public Lab's Map Knitter to upload your own aerial photographs (for example those from balloon or kite mapping: http://publiclab.org/wiki/balloon-mapping) and combine them into:
-Use Public Laboratory's Map Knitter to upload your own aerial imagery and combine it into a GeoTiff and TMS/OpenLayers map.
+* web "slippy maps" like Google Maps
+* GeoTiff
+* TMS
+* high resolution JPEG
-Copyright 2010-2011 Jeffrey Warren
+Copyright 2010-2014 Public Lab & Jeffrey Warren
==========================
LICENSE
==========================
-PLOTS Map Knitter is free software: you can redistribute it and/or modify
+Map Knitter is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
-PLOTS Map Knitter is distributed in the hope that it will be useful,
+Map Knitter 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 General Public License for more details.
You should have received a copy of the GNU General Public License
-along with PLOTS Map Knitter. If not, see .
+along with Map Knitter. If not, see .
==========================
ABOUT
==========================
-Use Public Laboratory's Map Knitter to upload your own aerial imagery and combine it into a GeoTiff and TMS/OpenLayers map.
+Use Public Lab's Map Knitter to upload your own aerial imagery and combine it into a GeoTiff and TMS/OpenLayers map.
-Read more about PLOTS Map Knitter at: http://publiclaboratory.org/wiki/plots-map-toolkit
+Read more about Map Knitter at: http://publiclab.org/wiki/plots-map-toolkit
-The Public Laboratory for Open Technology and Science (PLOTS) is a community which develops and applies open-source tools to environmental exploration and investigation. By democratizing inexpensive and accessible “Do-It-Yourself” techniques, Public Laboratory creates a collaborative network of practitioners who actively re-imagine the human relationship with the environment.
+The Public Laboratory for Open Technology and Science (Public Lab) is a community which develops and applies open-source tools to environmental exploration and investigation. By democratizing inexpensive and accessible “Do-It-Yourself” techniques, Public Lab creates a collaborative network of practitioners who actively re-imagine the human relationship with the environment.
-The core PLOTS program is focused on “civic science” in which we research open source hardware and software tools and methods to generate knowledge and share data about community environmental health. Our goal is to increase the ability of underserved communities to identify, redress, remediate, and create awareness and accountability around environmental concerns. PLOTS achieves this by providing online and offline training, education and support, and by focusing on locally-relevant outcomes that emphasize human capacity and understanding.
+The core Public Lab program is focused on “civic science” in which we research open source hardware and software tools and methods to generate knowledge and share data about community environmental health. Our goal is to increase the ability of underserved communities to identify, redress, remediate, and create awareness and accountability around environmental concerns. Public Lab achieves this by providing online and offline training, education and support, and by focusing on locally-relevant outcomes that emphasize human capacity and understanding.
-Join now at: http://publiclaboratory.org/join
+Join now at: http://publiclab.org
==========================
INSTALLATION
==========================
-You'll need Ruby on Rails ~2.3.15, Ruby 1.8.7 (Ruby 1.9.x doesn't work for now as there is no packaged version of the geohash gem yet for 1.9.x), and GDAL >=1.7.x (gdal.org)
-Check the version of ruby installed on your system by "ruby -v" If it displays a version other than 1.8.7, use a version manager like RVM to use ruby 1.8.7 as default.
+You'll need Ruby 1.9.3 and GDAL >=1.7.x (gdal.org)
+Check the version of ruby installed on your system by "ruby -v" If it displays a version other than 1.9.3, use a version manager like RVM to use ruby 1.9.3 as default.
-1) Download source from http://github.com/jywarren/mapknitter
-2) Install the compatible (with ruby 1.8.7) versions of the following gems using "gem install" : mysql(2.9.1), geokit-rails(1.1.4), image_science(1.2.6), recaptcha(0.3.6), will_paginate(2.3.16), oa-openid(0.3.2), httparty(0.11.0).
-For e.g.- use "gem install geokit-rails -v 1.1.4" to install geokit-rails version 1.1.4. The dependent libraries can be viewed by opening /config/environment.rb.
-3) Install davetroy-geohash from github source; first add github source with "gem sources -a http://gems.github.com" then run "gem install davetroy-geohash". (probably not needed anymore really)
-4) Manually run "gem install RubyInline" - this was causing trouble when done from environment.rb
-5) Install Amazon S3 gem with "gem install aws-s3" if you are using Amazon S3 for most image storage
-6) Copy and configure config/database.yml from config/database.yml.example
-7) Initialize database with "rake db:migrate"
-8) Change the Google Maps API key at config/config.yml, which you can copy from config/config.yml.example. If you're running it locally, you can use the default which is provided; it's set up for http://localhost:3000. For a new one visit http://code.google.com/apis/maps/signup.html
-9) Enter the ReCaptcha public and private keys in config/initializers/recaptcha.rb, copied from recaptcha.rb.example
-10) Remove write permissions from the folder you have placed your app in.
-11) Start rails with "script/server -p 3000" or "passenger start -p 3000" from the Rails root and open http://localhost:3000 in a web browser.
+1) Download source from https://github.com/publiclab/mapknitter
+2) Install gems with `bundle install` from the rails root folder
+3) Copy and configure config/database.yml from config/database.yml.example
+4) Initialize database with "rake db:migrate"
+5) Change the Google Maps API key at config/config.yml, which you can copy from config/config.yml.example. If you're running it locally, you can use the default which is provided; it's set up for http://localhost:3000. For a new one visit http://code.google.com/apis/maps/signup.html
+6) Enter the ReCaptcha public and private keys in config/initializers/recaptcha.rb, copied from recaptcha.rb.example
+7) Start rails with "passenger start" from the Rails root and open http://localhost:3000 in a web browser.
==========================
-BITNAMI INSTALLATION
+BUGS AND SUPPORT
==========================
-This is experimental, but if it works, you'll have a local version which you can carry around on a USB stick. We hope it will be useful for low-bandwidth situations. But beware - it hasn't been tested!
+To report bugs and request features, please use the GitHub issue tracker provided at https://github.com/publiclab/mapknitter/issues
-From the Bitnami RubyStack README:
-To install BitNami RubyStack you will need:
+For additional support, join the Public Lab website and mailing list at http://publiclab.org/lists or for urgent requests, email web@publiclab.org
- - Intel x86 or compatible processor
- - Minimum of 512 MB RAM
- - Minimum of 150 MB hard drive space
- - TCP/IP protocol support
- - Compatible operantig systems:
- - An x86 Linux operating system.
- - A 32-bit Windows operating system such as Windows 2000, XP, Vista
- or Windows Server 2003.
- - An OS X operating system (PowerPC or x86).
+For questions related to the use of this software and balloon or kite mapping, the same page links to the "grassrootsmapping" discussion group.
+
+==========================
+DEVELOPERS
+==========================
+
+Development is occurring at https://github.com/publiclab/mapknitter/; please fork and submit pull requests.
+
+If you're a developer, consider joining the Public Lab developer list, also at http://publiclab.org/lists
-You will also need:
- - GDAL >= 1.7.x (gdal.org)
- - some source of local tiles, such as from TileStream (mapbox.com)
-1) Download the Bitnami.org RubyStack: http://bitnami.org/stack/rubystack, and run the installer.
-2) Place this MapKnitter folder in the resulting "projects" folder inside "rubystack-2.2-2" (get MapKnitter at http://github.com/jywarren/mapknitter or https://github.com/jywarren/mapknitter/zipball/master)
-3) Open a shell prompt/terminal, and enter the "rubystack-2.2-2" folder.
-4) Type ".rubyconsole" to start the Bitnami ruby console.
-5) Type "cd projects/mapknitter" to enter the MapKnitter project folder.
-6) Follow the above steps for a normal installation.
diff --git a/Rakefile b/Rakefile
index 46029270..8708a7df 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,10 +1,7 @@
+#!/usr/bin/env rake
# 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'
+Mapknitter::Application.load_tasks
diff --git a/app/assets/images/rails.png b/app/assets/images/rails.png
new file mode 100644
index 00000000..d5edc04e
Binary files /dev/null and b/app/assets/images/rails.png differ
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
new file mode 100644
index 00000000..aaa69c61
--- /dev/null
+++ b/app/assets/javascripts/application.js
@@ -0,0 +1,15 @@
+// This is a manifest file that'll be compiled into application.js, which will include all the files
+// listed below.
+//
+// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
+// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
+//
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
+// GO AFTER THE REQUIRES BELOW.
+//
+// require jquery
+// require jquery_ujs
+//= require_tree .
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
new file mode 100644
index 00000000..3192ec89
--- /dev/null
+++ b/app/assets/stylesheets/application.css
@@ -0,0 +1,13 @@
+/*
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
+ * listed below.
+ *
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
+ *
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
+ * compiled file, but it's generally better to create a new file per style scope.
+ *
+ *= require_self
+ *= require_tree .
+ */
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 9e85f024..4b972a8f 100755
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,19 +1,48 @@
-# Filters added to this controller apply to all controllers in the application.
-# Likewise, all the methods added will be available for all controllers.
-require_dependency 'password'
-
-include AuthenticatedSystem
-
class ApplicationController < ActionController::Base
+ # Prevent CSRF attacks by raising an exception.
+ # For APIs, you may want to use :null_session instead.
+ protect_from_forgery with: :exception
+
helper :all # include all helpers, all the time
- # See ActionController::RequestForgeryProtection for details
- # Uncomment the :secret if you're not using the cookie session store
- protect_from_forgery # :secret => 'e60163cd72d897fd0ae06095d71acfbc'
-
- # See ActionController::Base for details
- # Uncomment this to filter the contents of submitted sensitive data parameters
- # from your application log (in this case, all fields with names like "password").
- filter_parameter_logging :password
-
+ before_filter :current_user
+ helper_method :logged_in?
+
+ def current_user
+ user_id = session[:user_id]
+ if user_id
+ begin
+ @user = User.find(user_id)
+ rescue
+ @user = nil
+ end
+ else
+ @user = nil
+ end
+ end
+
+ private
+
+ def require_login
+ unless logged_in?
+ path_info = request.env['PATH_INFO']
+ flash[:warning] = "You must be logged in to access this section"
+ redirect_to '/login?back_to=' + URI.encode(path_info) # halts request cycle
+ end
+ end
+
+ def logged_in?
+ user_id = session[:user_id]
+
+ begin
+ if user_id and User.find(user_id)
+ return true
+ else
+ return false
+ end
+ rescue
+ return false
+ end
+ end
+
end
diff --git a/app/controllers/map_controller.rb b/app/controllers/map_controller.rb
index ae689bfd..fcfdef7d 100644
--- a/app/controllers/map_controller.rb
+++ b/app/controllers/map_controller.rb
@@ -4,7 +4,7 @@ class MapController < ApplicationController
def index
# only maps with at least 1 warpable:
- @maps = Map.find :all, :conditions => {:archived => false, :password => ''}, :order => 'updated_at DESC', :joins => :warpables, :group => "maps.id", :limit => 24
+ @maps = Map.find :all, :conditions => {:archived => false, :password => ''}, :order => 'updated_at DESC', :group => "maps.id", :limit => 24
@notes = Node.find :all, :order => "id DESC", :limit => 5
@unpaginated = true
@authors = Map.find(:all, :limit => 12, :group => "maps.author", :order => "id DESC", :conditions => ['password = "" AND archived = "false"']).collect(&:author)
@@ -333,11 +333,11 @@ class MapController < ApplicationController
export.jpg = false
export.save
- directory = RAILS_ROOT+"/public/warps/"+map.name+"/"
+ directory = Rails.root+"/public/warps/"+map.name+"/"
stdin, stdout, stderr = Open3.popen3('rm -r '+directory)
puts stdout.readlines
puts stderr.readlines
- stdin, stdout, stderr = Open3.popen3('rm -r '+RAILS_ROOT+'/public/tms/'+map.name)
+ stdin, stdout, stderr = Open3.popen3('rm -r '+Rails.root+'/public/tms/'+map.name)
puts stdout.readlines
puts stderr.readlines
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 6df2035a..062e6fe9 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,8 +1,28 @@
-# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
- def admin
- APP_CONFIG["password"] == params[:password]
- end
+ # add this to app/helpers/application_helper.rb
+ # http://www.emersonlackey.com/article/rails3-error-messages-for-replacemen
+ def errors_for(object, message=nil)
+ html = ""
+ unless object.nil? || object.errors.blank?
+ html << "
\n"
+ if message.blank?
+ if object.new_record?
+ html << "\t\t
There was a problem creating the #{object.class.name.humanize.downcase}
\n"
+ else
+ html << "\t\t
There was a problem updating the #{object.class.name.humanize.downcase}
\n"
+ end
+ else
+ html << "
#{message}
"
+ end
+ html << "\t\t
\n"
+ object.errors.full_messages.each do |error|
+ html << "\t\t\t
#{error}
\n"
+ end
+ html << "\t\t
\n"
+ html << "\t
\n"
+ end
+ html
+ end
end
diff --git a/vendor/plugins/geokit-rails/test/fixtures/stores.yml b/app/mailers/.gitkeep
similarity index 100%
rename from vendor/plugins/geokit-rails/test/fixtures/stores.yml
rename to app/mailers/.gitkeep
diff --git a/app/models/.gitkeep b/app/models/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/app/models/map.rb b/app/models/map.rb
index 76a84758..5399a6d1 100755
--- a/app/models/map.rb
+++ b/app/models/map.rb
@@ -245,7 +245,7 @@ class Map < ActiveRecord::Base
puts '> generating tiles'
# make tiles:
google_api_key = APP_CONFIG["google_maps_api_key"]
- gdal2tiles = 'gdal2tiles.py -k -t "'+self.name+'-nrg" -g "'+google_api_key+'" '+RAILS_ROOT+'/public/warps/'+self.name+'/'+self.name+'-nrg.tif '+RAILS_ROOT+'/public/tms/'+self.name+"-nrg/"
+ gdal2tiles = 'gdal2tiles.py -k -t "'+self.name+'-nrg" -g "'+google_api_key+'" '+Rails.root+'/public/warps/'+self.name+'/'+self.name+'-nrg.tif '+Rails.root+'/public/tms/'+self.name+"-nrg/"
# puts gdal2tiles
# puts system('which gdal2tiles.py')
system(Gdal.ulimit+gdal2tiles)
@@ -344,16 +344,16 @@ class Map < ActiveRecord::Base
geotiff_location
end
- # generates a tileset at RAILS_ROOT/public/tms//
+ # generates a tileset at Rails.root/public/tms//
def generate_tiles
google_api_key = APP_CONFIG["google_maps_api_key"]
- gdal2tiles = 'gdal2tiles.py -k -t "'+self.name+'" -g "'+google_api_key+'" '+RAILS_ROOT+'/public/warps/'+self.name+'/'+self.name+'-geo.tif '+RAILS_ROOT+'/public/tms/'+self.name+"/"
+ gdal2tiles = 'gdal2tiles.py -k -t "'+self.name+'" -g "'+google_api_key+'" '+Rails.root+'/public/warps/'+self.name+'/'+self.name+'-geo.tif '+Rails.root+'/public/tms/'+self.name+"/"
# puts gdal2tiles
# puts system('which gdal2tiles.py')
system(Gdal.ulimit+gdal2tiles)
end
- # zips up tiles at RAILS_ROOT/public/tms/.zip
+ # zips up tiles at Rails.root/public/tms/.zip
def zip_tiles
rmzip = 'cd public/tms/ && rm '+self.name+'.zip && cd ../../'
system(Gdal.ulimit+rmzip)
@@ -364,8 +364,8 @@ class Map < ActiveRecord::Base
end
def generate_jpg(export_type)
- imageMagick = 'convert -background white -flatten '+RAILS_ROOT+'/public/warps/'+self.name+'/'+self.name+'-geo.tif '+RAILS_ROOT+'/public/warps/'+self.name+'/'+self.name+'.jpg' if export_type == "normal"
- imageMagick = 'convert -background white -flatten '+RAILS_ROOT+'/public/warps/'+self.name+'/'+self.name+'-'+export_type+'.tif '+RAILS_ROOT+'/public/warps/'+self.name+'/'+self.name+'-nrg.jpg' if export_type == "nrg"
+ imageMagick = 'convert -background white -flatten '+Rails.root+'/public/warps/'+self.name+'/'+self.name+'-geo.tif '+Rails.root+'/public/warps/'+self.name+'/'+self.name+'.jpg' if export_type == "normal"
+ imageMagick = 'convert -background white -flatten '+Rails.root+'/public/warps/'+self.name+'/'+self.name+'-'+export_type+'.tif '+Rails.root+'/public/warps/'+self.name+'/'+self.name+'-nrg.jpg' if export_type == "nrg"
system(Gdal.ulimit+imageMagick)
end
diff --git a/app/models/warpable.rb b/app/models/warpable.rb
index c2e2b0bb..e8772816 100755
--- a/app/models/warpable.rb
+++ b/app/models/warpable.rb
@@ -1,99 +1,80 @@
-require "open3"
-require "fileutils"
-
class Warpable < ActiveRecord::Base
-
- has_attachment :content_type => :image,
- :storage => APP_CONFIG["file_storage"],
- #:storage => :s3,
- #:storage => :file_system,
- :path_prefix => APP_CONFIG["file_path_prefix"],
- #:path_prefix => 'public/warpables',
- :max_size => 30.megabytes,
- :processor => :image_science,
- :thumbnails => { :medium => '500x375', :small => '240x180', :thumb => '100x100>' }
+
+ # remaming configs from attachment_fu:
+ # :storage => APP_CONFIG["file_storage"],
- # validates_as_attachment
+ # Paperclip
+ has_attached_file :image,
+ #:path => ":rails_root/public/warpables/:attachment/:id/:style/:filename",
+ #:url => "/system/:attachment/:id/:style/:filename",
+ :path => "paperclip/:id/:style/:filename",
+ # should start using
+ #:path => "warpables/:id/:style/:filename",
+ :storage => :s3,
+ :s3_credentials => ":rails_root/config/amazon_s3.yml",
+ :styles => {
+ :medium=> "500x375",
+ :small=> "240x180",
+ :thumb => "100x100>" }
- def validate
- errors.add_to_base("You must choose a file to upload") unless self.filename
-
- unless self.filename == nil
-
- # Images should only be GIF, JPEG, or PNG
- [:content_type].each do |attr_name|
- enum = attachment_options[attr_name]
- unless enum.nil? || enum.include?(send(attr_name))
- errors.add_to_base("You can only upload images (GIF, JPEG, or PNG)")
- end
- end
-
- # Images should be less than 5 MB
- [:size].each do |attr_name|
- enum = attachment_options[attr_name]
- unless enum.nil? || enum.include?(send(attr_name))
- errors.add_to_base("Images should be smaller than 10 MB in size")
- end
- end
- end
- end
+ belongs_to :map
def poly_area
- area = 0
- nodes = self.nodes_array
- nodes.each_with_index do |node,index|
- if index < nodes.length-1
- nextnode = nodes[index+1]
- else
- nextnode = nodes[0]
- end
- if index > 0
- last = nodes[index-1]
- else
- last = nodes[nodes.length-1]
- end
- scale = 20037508.34
- # inefficient but workable, we don't use this that often:
-
- nodey = Cartagen.spherical_mercator_lat_to_y(node.lat,scale)
- nodex = Cartagen.spherical_mercator_lon_to_x(node.lon,scale)
- lasty = Cartagen.spherical_mercator_lat_to_y(last.lat,scale)
- lastx = Cartagen.spherical_mercator_lon_to_x(last.lon,scale)
- nexty = Cartagen.spherical_mercator_lat_to_y(nextnode.lat,scale)
- nextx = Cartagen.spherical_mercator_lon_to_x(nextnode.lon,scale)
- area += lastx*nodey-nodex*lasty+nodex*nexty-nextx*nodey
- end
- (area/2).abs
+ area = 0
+ nodes = self.nodes_array
+ nodes.each_with_index do |node,index|
+ if index < nodes.length-1
+ nextnode = nodes[index+1]
+ else
+ nextnode = nodes[0]
+ end
+ if index > 0
+ last = nodes[index-1]
+ else
+ last = nodes[nodes.length-1]
+ end
+ scale = 20037508.34
+ # inefficient but workable, we don't use this that often:
+
+ nodey = Cartagen.spherical_mercator_lat_to_y(node.lat,scale)
+ nodex = Cartagen.spherical_mercator_lon_to_x(node.lon,scale)
+ lasty = Cartagen.spherical_mercator_lat_to_y(last.lat,scale)
+ lastx = Cartagen.spherical_mercator_lon_to_x(last.lon,scale)
+ nexty = Cartagen.spherical_mercator_lat_to_y(nextnode.lat,scale)
+ nextx = Cartagen.spherical_mercator_lon_to_x(nextnode.lon,scale)
+ area += lastx*nodey-nodex*lasty+nodex*nexty-nextx*nodey
+ end
+ (area/2).abs
end
def get_cm_per_pixel
- unless self.width.nil? || self.nodes == ''
- nodes = self.nodes_array
- # haversine might be more appropriate for large images
- scale = 20037508.34
- y1 = Cartagen.spherical_mercator_lat_to_y(nodes[0].lat,scale)
- x1 = Cartagen.spherical_mercator_lon_to_x(nodes[0].lon,scale)
- y2 = Cartagen.spherical_mercator_lat_to_y(nodes[1].lat,scale)
- x2 = Cartagen.spherical_mercator_lon_to_x(nodes[1].lon,scale)
- dist = Math.sqrt(((y2-y1)*(y2-y1))+((x2-x1)*(x2-x1)))
- #puts 'x1,y1: '+x1.to_s+','+y1.to_s+' x2,y2: '+x2.to_s+','+y2.to_s
- #puts (x2-x1).to_s+','+(y2-y1).to_s
- #puts 'scale: '+((warpable.width)/dist).to_s+' & dist: '+dist.to_s
- scale = (dist*100)/(self.width) unless self.width.nil? || dist.nil?
- end
- scale
+ unless self.width.nil? || self.nodes == ''
+ nodes = self.nodes_array
+ # haversine might be more appropriate for large images
+ scale = 20037508.34
+ y1 = Cartagen.spherical_mercator_lat_to_y(nodes[0].lat,scale)
+ x1 = Cartagen.spherical_mercator_lon_to_x(nodes[0].lon,scale)
+ y2 = Cartagen.spherical_mercator_lat_to_y(nodes[1].lat,scale)
+ x2 = Cartagen.spherical_mercator_lon_to_x(nodes[1].lon,scale)
+ dist = Math.sqrt(((y2-y1)*(y2-y1))+((x2-x1)*(x2-x1)))
+ #puts 'x1,y1: '+x1.to_s+','+y1.to_s+' x2,y2: '+x2.to_s+','+y2.to_s
+ #puts (x2-x1).to_s+','+(y2-y1).to_s
+ #puts 'scale: '+((warpable.width)/dist).to_s+' & dist: '+dist.to_s
+ scale = (dist*100)/(self.width) unless self.width.nil? || dist.nil?
+ end
+ scale
end
def self.histogram_cm_per_pixel
- w = Warpable.find :all, :conditions => ['cm_per_pixel != 0 AND cm_per_pixel < 500'], :order => "cm_per_pixel DESC"
- hist = []
- (0..w.first.cm_per_pixel.to_i).each do |bin|
- hist[bin] = 0
- end
- w.each do |warpable|
- hist[warpable.cm_per_pixel.to_i] += 1
- end
- hist
+ w = Warpable.find :all, :conditions => ['cm_per_pixel != 0 AND cm_per_pixel < 500'], :order => "cm_per_pixel DESC"
+ hist = []
+ (0..w.first.cm_per_pixel.to_i).each do |bin|
+ hist[bin] = 0
+ end
+ w.each do |warpable|
+ hist[warpable.cm_per_pixel.to_i] += 1
+ end
+ hist
end
def nodes_array
@@ -101,6 +82,7 @@ class Warpable < ActiveRecord::Base
end
# allow uploads via URL
+ # needs update for Paperclip!!
require 'open-uri'
attr_reader :url
def url=(uri)
@@ -165,7 +147,7 @@ class Warpable < ActiveRecord::Base
}
}
else
- File.copy(RAILS_ROOT+'/public'+self.public_filename,local_location)
+ File.copy(Rails.root+'/public'+self.public_filename,local_location)
end
points = ""
@@ -174,20 +156,20 @@ class Warpable < ActiveRecord::Base
first = true
#EXIF orientation values:
-#Value 0th Row 0th Column
-#1 top left side
-#2 top right side
-#3 bottom right side
-#4 bottom left side
-#5 left side top
-#6 right side top
-#7 right side bottom
-#8 left side bottom
-
- rotation = (`identify -format %[exif:Orientation] #{local_location}`).to_i
- #stdin, stdout, stderr = Open3.popen3('identify -format %[exif:Orientation] #{local_location}')
- #rotation = stdout.readlines.first.to_s.to_i
- #puts stderr.readlines
+#Value 0th Row 0th Column
+#1 top left side
+#2 top right side
+#3 bottom right side
+#4 bottom left side
+#5 left side top
+#6 right side top
+#7 right side bottom
+#8 left side bottom
+
+ rotation = (`identify -format %[exif:Orientation] #{local_location}`).to_i
+ #stdin, stdout, stderr = Open3.popen3('identify -format %[exif:Orientation] #{local_location}')
+ #rotation = stdout.readlines.first.to_s.to_i
+ #puts stderr.readlines
if rotation == 6
puts 'rotated CCW'
@@ -235,11 +217,11 @@ class Warpable < ActiveRecord::Base
height = (y1-y2).to_i.to_s
width = (-x1+x2).to_i.to_s
- # http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=11319
- # http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=8764
- # read about equalization
- # -equalize
- # -contrast-stretch 0
+ # http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=11319
+ # http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=8764
+ # read about equalization
+ # -equalize
+ # -contrast-stretch 0
imageMagick = "convert "
imageMagick += "-contrast-stretch 0 "
@@ -249,44 +231,44 @@ class Warpable < ActiveRecord::Base
imageMagick += "-distort Perspective '"+points+"' "
imageMagick += "-flatten "
if width > height
- imageMagick += "-crop "+width+"x"+width+"+0+0\! "
+ imageMagick += "-crop "+width+"x"+width+"+0+0\! "
else
- imageMagick += "-crop "+height+"x"+height+"+0+0\! "
+ imageMagick += "-crop "+height+"x"+height+"+0+0\! "
end
imageMagick += "+repage "
imageMagick += completed_local_location
puts imageMagick
- system(Gdal.ulimit+imageMagick)
+ system(Gdal.ulimit+imageMagick)
# create a mask (later we can blur edges here)
imageMagick2 = 'convert +antialias '
if width > height
- imageMagick2 += "-size "+width+"x"+width+" "
+ imageMagick2 += "-size "+width+"x"+width+" "
else
- imageMagick2 += "-size "+height+"x"+height+" "
+ imageMagick2 += "-size "+height+"x"+height+" "
end
- # attempt at blurred edges in masking, but I've given up, as gdal_merge doesn't seem to respect variable-opacity alpha channels
- imageMagick2 += ' xc:none -draw "fill black stroke red stroke-width 30 polyline '
- imageMagick2 += maskpoints + '" '
- imageMagick2 += ' -alpha set -channel A -transparent red -blur 0x8 -channel R -evaluate set 0 +channel '+mask_location
+ # attempt at blurred edges in masking, but I've given up, as gdal_merge doesn't seem to respect variable-opacity alpha channels
+ imageMagick2 += ' xc:none -draw "fill black stroke red stroke-width 30 polyline '
+ imageMagick2 += maskpoints + '" '
+ imageMagick2 += ' -alpha set -channel A -transparent red -blur 0x8 -channel R -evaluate set 0 +channel '+mask_location
#imageMagick2 += ' xc:none -draw "fill black stroke none polyline '
#imageMagick2 += maskpoints + '" '
#imageMagick2 += ' '+mask_location
puts imageMagick2
- system(Gdal.ulimit+imageMagick2)
+ system(Gdal.ulimit+imageMagick2)
imageMagick3 = 'composite '+mask_location+' '+completed_local_location+' -compose DstIn -alpha Set '+masked_local_location
puts imageMagick3
- system(Gdal.ulimit+imageMagick3)
+ system(Gdal.ulimit+imageMagick3)
gdal_translate = "gdal_translate -of GTiff -a_srs EPSG:4326 "+coordinates+' -co "TILED=NO" '+masked_local_location+' '+geotiff_location
puts gdal_translate
- system(Gdal.ulimit+gdal_translate)
+ system(Gdal.ulimit+gdal_translate)
#gdalwarp = 'gdalwarp -srcnodata "255" -dstnodata 0 -cblend 30 -of GTiff -t_srs EPSG:4326 '+geotiff_location+' '+warped_geotiff_location
gdalwarp = 'gdalwarp -of GTiff -t_srs EPSG:4326 '+geotiff_location+' '+warped_geotiff_location
puts gdalwarp
- system(Gdal.ulimit+gdalwarp)
+ system(Gdal.ulimit+gdalwarp)
# deletions could happen here; do it in distinct method so we can run it independently
self.delete_temp_files(path)
diff --git a/app/views/layouts/application.html.erb.rails3 b/app/views/layouts/application.html.erb.rails3
new file mode 100644
index 00000000..0c1e4d68
--- /dev/null
+++ b/app/views/layouts/application.html.erb.rails3
@@ -0,0 +1,14 @@
+
+
+
+ Mapknitter
+ <%= stylesheet_link_tag "application", :media => "all" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tags %>
+
+
+
+<%= yield %>
+
+
+
diff --git a/app/views/map/_list.html.erb b/app/views/map/_list.html.erb
index c3da7c98..f2681d8e 100644
--- a/app/views/map/_list.html.erb
+++ b/app/views/map/_list.html.erb
@@ -2,7 +2,7 @@
<% odd = true %>
<% for map in @maps %>
- <% if !map.private && map.warpables.length > 0 %><% end %>
+ <% if !map.private && map.warpables.length > 0 %><% end %>
<% end %>
- <% form_for :map, @map, :url => { :controller => "map", :action => "create" }, :html => {:id => "new_map", :class => "map"} do |f| %>
- <%= error_messages_for 'map' %>
+ <% form_for :map, :html => {:id => "new_map", :class => "map"} do |f| %>
+
+ <%= errors_for @map, "Oops, we were unable to save your map." %>
+
diff --git a/config.ru b/config.ru
new file mode 100644
index 00000000..ee4a427b
--- /dev/null
+++ b/config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Mapknitter::Application
diff --git a/config/amazon_s3.yml.example b/config/amazon_s3.yml.example
index b876b57a..5e4237ec 100644
--- a/config/amazon_s3.yml.example
+++ b/config/amazon_s3.yml.example
@@ -1,14 +1,11 @@
development:
- bucket_name:
+ bucket: "grassrootsmapping"
access_key_id:
secret_access_key:
-
test:
- bucket_name:
access_key_id:
secret_access_key:
-
production:
- bucket_name:
+ bucket: "grassrootsmapping"
access_key_id:
secret_access_key:
diff --git a/config/application.rb b/config/application.rb
new file mode 100644
index 00000000..f5d410ce
--- /dev/null
+++ b/config/application.rb
@@ -0,0 +1,62 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+if defined?(Bundler)
+ # If you precompile assets before deploying to production, use this line
+ Bundler.require(*Rails.groups(:assets => %w(development test)))
+ # If you want your assets lazily compiled in production, use this line
+ # Bundler.require(:default, :assets, Rails.env)
+end
+
+module Mapknitter
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # 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]
+
+ # Enable escaping HTML in JSON.
+ config.active_support.escape_html_entities_in_json = true
+
+ # Use SQL instead of Active Record's schema dumper when creating the 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
+
+ # Enforce whitelist mode for mass assignment.
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
+ # parameters by using an attr_accessible or attr_protected declaration.
+ config.active_record.whitelist_attributes = true
+
+ # Enable the asset pipeline
+ config.assets.enabled = true
+
+ # Version of your assets, change this if you want to expire all your assets
+ config.assets.version = '1.0'
+ end
+end
diff --git a/config/boot.rb b/config/boot.rb
index 6686664c..4489e586 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -1,114 +1,6 @@
-# Don't change this file!
-# Configure your app in config/environment.rb and config/environments/*.rb
+require 'rubygems'
-RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
+# Set up gems listed in the Gemfile.
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
-module Rails
- class << self
- def boot!
- unless booted?
- preinitialize
- pick_boot.run
- end
- end
-
- def booted?
- defined? Rails::Initializer
- end
-
- def pick_boot
- (vendor_rails? ? VendorBoot : GemBoot).new
- end
-
- def vendor_rails?
- File.exist?("#{RAILS_ROOT}/vendor/rails")
- end
-
- def preinitialize
- load(preinitializer_path) if File.exist?(preinitializer_path)
- end
-
- def preinitializer_path
- "#{RAILS_ROOT}/config/preinitializer.rb"
- end
- end
-
- class Boot
- def run
- load_initializer
- Rails::Initializer.run(:set_load_path)
- end
- end
-
- class VendorBoot < Boot
- def load_initializer
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
- Rails::Initializer.run(:install_gem_spec_stubs)
- Rails::GemDependency.add_frozen_gem_path
- end
- end
-
- class GemBoot < Boot
- def load_initializer
- self.class.load_rubygems
- load_rails_gem
- require 'initializer'
- end
-
- def load_rails_gem
- if version = self.class.gem_version
- gem 'rails', version
- else
- gem 'rails'
- end
- rescue Gem::LoadError => load_error
- if load_error.message =~ /Could not find RubyGem rails/
- 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
- else
- raise
- end
- 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
- min_version = '1.3.2'
- require 'rubygems'
- 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 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
diff --git a/config/environment.rb b/config/environment.rb
index 52f7afd5..761c5657 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -1,125 +1,5 @@
-# Be sure to restart your server when you modify this file
+# Load the rails application
+require File.expand_path('../application', __FILE__)
-# Uncomment below to force Rails into production mode when
-# you don't control web/app server and can't set it the proper way
-# ENV['RAILS_ENV'] ||= 'production'
-
-# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.3.15' unless defined? RAILS_GEM_VERSION
-
-# Bootstrap the Rails environment, frameworks, and default configuration
-require File.join(File.dirname(__FILE__), 'boot')
-
-# monkey patch for 2.0. Will ignore vendor gems. # via http://djellemah.com/blog/2013/02/27/rails-23-with-ruby-20/ #if RUBY_VERSION >= "2.0.0"
- module Gem
- def self.source_index
- sources
- end
-
- def self.cache
- sources
- end
-
- SourceIndex = Specification
-
- class SourceList
- # If you want vendor gems, this is where to start writing code.
- def search( *args ); []; end
- def each( &block ); end
- include Enumerable
- end
- end
-#end
-
-Rails::Initializer.run do |config|
- # Settings in config/environments/* take precedence over those specified here.
- # Application configuration should go into files in config/initializers
- # -- all .rb files in that directory are automatically loaded.
- # See Rails::Configuration for more options.
-
- # Skip frameworks you're not going to use. To use Rails without a database
- # you must remove the Active Record framework.
- # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
-
- # Specify gems that this application depends on.
- # They can then be installed with "rake gems:install" on new installations.
- # 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"
-
- # commented these out in order to use the Gemfile instead
- # config.gem "mysql", :version => '~> 2.9.1'
- # #config.gem "json_pure"
- # config.gem "httparty", :version => '~> 0.11.0'
- # config.gem "geokit-rails", :version => '~> 1.1.4'
- # #config.gem "RubyInline"
- # config.gem "image_science", :version => '~> 1.2.6'
- #Configure at config/initializers/recaptcha.rb, copy from recaptcha.rb.example
- # config.gem "recaptcha", :lib => "recaptcha/rails" # Passenger needs this line in order to load correctly -> why?
- # #config.gem "exifr" # didnt use as incompatible with ruby 1.8.6
- # config.gem 'will_paginate', :version => '~> 2.3.16'
- # config.gem 'oa-openid', :version => '~> 0.3.2'
-
- # config.gem "rubyzip"
- # if you're going to use Amazon s3 for image storage:
- # config.gem "aws-s3"
- # you also need to install 'freeimage':
- ##### sudo port install freeimage
- ##### or: sudo aptitude install libfreeimage3 libfreeimage-dev
- # we also need davetroy-geohash, but it's not in the default gem sources, so try adding github to your gem sources:
- # gem sources -a http://gems.github.com
- # then run:
- # sudo gem install davetroy-geohash
- # Hmm, this might also be useful:
- #config.gem "davetroy-geohash", :lib => 'geohash', :source => "http://gems.github.com"
-
- # 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
-
- # Your secret key for verifying cookie session data integrity.
- # If you change this key, all old sessions will become invalid!
- # Make sure the secret is at least 30 characters and all random,
- # no regular words or you'll be exposed to dictionary attacks.
- config.action_controller.session = {
- :session_key => '_whooz_session',
- :secret => 'e420335fa23afd9cc84f118c9cb9985530d4f259b671fe1ec9c60466d6a07c6bbd268167674293b1cda7476f64f0012c23adca8fa0bcd9ee3ef70dcd0e9745e7'
- }
-
- # 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
-
- #require 'json/add/rails'
-end
-
-ENV['PATH'] = "#{ENV['PATH']}:/Library/Frameworks/GDAL.framework/Programs"
+# Initialize the rails application
+Mapknitter::Application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
index e77ec47f..47e9e4e8 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -1,17 +1,37 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Mapknitter::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
-# In the development environment your application's code is reloaded on
-# every request. This slows down response time but is perfect for development
-# since you don't have to restart the webserver when you make code changes.
-config.cache_classes = false
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
-# Log error messages when you accidentally call methods on nil.
-config.whiny_nils = true
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_view.debug_rjs = true
-config.action_controller.perform_caching = true #
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
-# Don't care if the mailer can't send
-config.action_mailer.raise_delivery_errors = false
\ No newline at end of file
+ # 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
+
+ # Raise exception on mass assignment protection for Active Record models
+ config.active_record.mass_assignment_sanitizer = :strict
+
+ # Log the query plan for queries taking more than this (works
+ # with SQLite, MySQL, and PostgreSQL)
+ config.active_record.auto_explain_threshold_in_seconds = 0.5
+
+ # Do not compress assets
+ config.assets.compress = false
+
+ # Expands the lines which load the assets
+ config.assets.debug = true
+end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index ec5b7bc8..e99e0a7e 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -1,24 +1,67 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Mapknitter::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
-# The production environment is meant for finished, "live" apps.
-# Code is not reloaded between requests
-config.cache_classes = true
+ # Code is not reloaded between requests
+ config.cache_classes = true
-# Enable threaded mode
-# config.threadsafe!
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
-# Use a different logger for distributed setups
-# config.logger = SyslogLogger.new
+ # Disable Rails's static asset server (Apache or nginx will already do this)
+ config.serve_static_assets = false
-# Full error reports are disabled and caching is turned on
-config.action_controller.consider_all_requests_local = false
-config.action_controller.perform_caching = true
+ # Compress JavaScripts and CSS
+ config.assets.compress = true
-# Use a different cache store in production
-# config.cache_store = :mem_cache_store
+ # Don't fallback to assets pipeline if a precompiled asset is missed
+ config.assets.compile = false
-# Enable serving of images, stylesheets, and javascripts from an asset server
-# config.action_controller.asset_host = "http://assets.example.com"
+ # Generate digests for assets URLs
+ config.assets.digest = true
-# Disable delivery errors, bad email addresses will be ignored
-# config.action_mailer.raise_delivery_errors = false
+ # Defaults to nil and saved in location specified by config.assets.prefix
+ # config.assets.manifest = YOUR_PATH
+
+ # Specifies the header that your server uses for sending files
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # See everything in the log (default is :info)
+ # config.log_level = :debug
+
+ # Prepend all log lines with the following tags
+ # config.log_tags = [ :subdomain, :uuid ]
+
+ # Use a different logger for distributed setups
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
+
+ # Use a different cache store in production
+ # config.cache_store = :mem_cache_store
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
+ # config.action_controller.asset_host = "http://assets.example.com"
+
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
+ # config.assets.precompile += %w( search.js )
+
+ # 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
+
+ # Log the query plan for queries taking more than this (works
+ # with SQLite, MySQL, and PostgreSQL)
+ # config.active_record.auto_explain_threshold_in_seconds = 0.5
+end
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 1e709e1d..8b5dc440 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -1,22 +1,37 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Mapknitter::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
-# The test environment is used exclusively to run your application's
-# test suite. You never need to work with it otherwise. Remember that
-# your test database is "scratch space" for the test suite and is wiped
-# and recreated between test runs. Don't rely on the data there!
-config.cache_classes = true
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
-# Log error messages when you accidentally call methods on nil.
-config.whiny_nils = true
+ # Configure static asset server for tests with Cache-Control for performance
+ config.serve_static_assets = true
+ config.static_cache_control = "public, max-age=3600"
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_controller.perform_caching = false
+ # Log error messages when you accidentally call methods on nil
+ config.whiny_nils = true
-# Disable request forgery protection in test environment
-config.action_controller.allow_forgery_protection = false
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = 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
+ # 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
+
+ # Raise exception on mass assignment protection for Active Record models
+ config.active_record.mass_assignment_sanitizer = :strict
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb
new file mode 100644
index 00000000..59385cdf
--- /dev/null
+++ b/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
diff --git a/config/initializers/geokit_config.rb b/config/initializers/geokit_config.rb
deleted file mode 100644
index 9a49d2cd..00000000
--- a/config/initializers/geokit_config.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-if defined? Geokit
-
- # These defaults are used in Geokit::Mappable.distance_to and in acts_as_mappable
- Geokit::default_units = :miles
- Geokit::default_formula = :sphere
-
- # This is the timeout value in seconds to be used for calls to the geocoder web
- # services. For no timeout at all, comment out the setting. The timeout unit
- # is in seconds.
-# Geokit::Geocoders::timeout = 3
-
- # These settings are used if web service calls must be routed through a proxy.
- # These setting can be nil if not needed, otherwise, addr and port must be
- # filled in at a minimum. If the proxy requires authentication, the username
- # and password can be provided as well.
- Geokit::Geocoders::proxy_addr = nil
- Geokit::Geocoders::proxy_port = nil
- Geokit::Geocoders::proxy_user = nil
- Geokit::Geocoders::proxy_pass = nil
-
- # This is your yahoo application key for the Yahoo Geocoder.
- # See http://developer.yahoo.com/faq/index.html#appid
- # and http://developer.yahoo.com/maps/rest/V1/geocode.html
- Geokit::Geocoders::yahoo = 'REPLACE_WITH_YOUR_YAHOO_KEY'
-
- # This is your Google Maps geocoder key.
- # See http://www.google.com/apis/maps/signup.html
- # and http://www.google.com/apis/maps/documentation/#Geocoding_Examples
- # Geokit::Geocoders::google = 'ABQIAAAANO6Yx8ihhesSqnPHx9a3RxQWBoXWBrlkEUL-tdL_AsWXzvTH0xT-5lfSNkW4zpDMdK9jmjmggAHvYw'
- Geokit::Geocoders::google = 'ABQIAAAANO6Yx8ihhesSqnPHx9a3RxQWBoXWBrlkEUL-tdL_AsWXzvTH0xT-5lfSNkW4zpDMdK9jmjmggAHvYw'
-
- # This is your username and password for geocoder.us.
- # To use the free service, the value can be set to nil or false. For
- # usage tied to an account, the value should be set to username:password.
- # See http://geocoder.us
- # and http://geocoder.us/user/signup
-# Geokit::Geocoders::geocoder_us = false
-
- # This is your authorization key for geocoder.ca.
- # To use the free service, the value can be set to nil or false. For
- # usage tied to an account, set the value to the key obtained from
- # Geocoder.ca.
- # See http://geocoder.ca
- # and http://geocoder.ca/?register=1
- Geokit::Geocoders::geocoder_ca = false
-
- # Uncomment to use a username with the Geonames geocoder
- #Geokit::Geocoders::geonames="REPLACE_WITH_YOUR_GEONAMES_USERNAME"
-
- # This is the order in which the geocoders are called in a failover scenario
- # If you only want to use a single geocoder, put a single symbol in the array.
- # Valid symbols are :google, :yahoo, :us, and :ca.
- # Be aware that there are Terms of Use restrictions on how you can use the
- # various geocoders. Make sure you read up on relevant Terms of Use for each
- # geocoder you are going to use.
- Geokit::Geocoders::provider_order = [:google_v3_geocoder]
-end
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
index d531b8bb..5d8d9be2 100644
--- a/config/initializers/inflections.rb
+++ b/config/initializers/inflections.rb
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.
-# Add new inflection rules using the following format
+# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
@@ -8,3 +8,8 @@
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
+#
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections do |inflect|
+# inflect.acronym 'RESTful'
+# end
diff --git a/config/initializers/load_config.rb b/config/initializers/load_config.rb
index 4f1d9688..e6874293 100644
--- a/config/initializers/load_config.rb
+++ b/config/initializers/load_config.rb
@@ -1 +1 @@
-APP_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml")[RAILS_ENV]
+APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env]
diff --git a/config/initializers/openid.rb b/config/initializers/openid.rb
deleted file mode 100644
index 7ee18ced..00000000
--- a/config/initializers/openid.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-OpenIdAuthentication.store = :file
-
-# Pickaxe-through-window solution:
-Rack::OpenID.class_eval do
-
- def realm_url(req)
- url = req.scheme + "://"
- url << req.host
-
- scheme, port = req.scheme, req.port
- if scheme == "https" && port != 443 ||
- scheme == "http" && port != 80
- #url << ":#{port}"
- end
-
- url
- end
-
-end
-
-# gotta break the return_to port mismatch check too...
-# #, @message="return_to port does not match", @reference=nil, @contact=nil>
-
-require "openid/message"
-require "openid/protocolerror"
-require "openid/kvpost"
-require "openid/consumer/discovery"
-require "openid/urinorm"
-
-OpenID::Consumer::IdResHandler.class_eval do
-
- def verify_return_to_base(msg_return_to)
- begin
- app_parsed = URI.parse(OpenID::URINorm::urinorm(@current_url))
- rescue URI::InvalidURIError
- raise OpenID::ProtocolError, "current_url is not a valid URI: #{@current_url}"
- end
-
- #[:scheme, :host, :port, :path].each do |meth|
- [:scheme, :host, :path].each do |meth|
- if msg_return_to.send(meth) != app_parsed.send(meth)
- raise OpenID::ProtocolError, "return_to #{meth.to_s} does not match"
- end
- end
- end
-
-end
-
diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb
new file mode 100644
index 00000000..b7bba1a4
--- /dev/null
+++ b/config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+Mapknitter::Application.config.secret_token = 'asdfjdasgaisaolghrwiohrkahguilboiwelkxwbranjkl'
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
new file mode 100644
index 00000000..24b53497
--- /dev/null
+++ b/config/initializers/session_store.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+Mapknitter::Application.config.session_store :cookie_store, key: '_mapknitter_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 "rails generate session_migration")
+# Mapknitter::Application.config.session_store :active_record_store
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb
new file mode 100644
index 00000000..999df201
--- /dev/null
+++ b/config/initializers/wrap_parameters.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters format: [:json]
+end
+
+# Disable root element in JSON by default.
+ActiveSupport.on_load(:active_record) do
+ self.include_root_in_json = false
+end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index f265c068..179c14ca 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1,5 +1,5 @@
# Sample localization file for English. Add more files in this directory for other locales.
-# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
- hello: "Hello world"
\ No newline at end of file
+ hello: "Hello world"
diff --git a/config/routes.rb b/config/routes.rb
index 97d10d0f..8ff02310 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,83 +1,100 @@
-ActionController::Routing::Routes.draw do |map|
- map.local '/local/:login', :controller => 'sessions', :action => 'local'
- map.logout '/logout', :controller => 'sessions', :action => 'destroy'
- map.login '/login', :controller => 'sessions', :action => 'new'
- map.register '/register', :controller => 'users', :action => 'create'
- map.signup '/signup', :controller => 'users', :action => 'new'
- map.resources :users
- map.tags '/tag/create', :controller => 'tag', :action => 'create'
- map.tags '/tag/:id', :controller => 'tag', :action => 'show'
-
- map.open_id_complete '/session', :controller => "session", :action => "create", :conditions => { :method => :get }
- map.resource :session
-
-
- # The priority is based upon order of creation: first created -> highest priority.
+Mapknitter::Application.routes.draw do
+ # The priority is based upon order of creation:
+ # first created -> highest priority.
# Sample of regular route:
- # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
+ # match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
- # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
- # map.resources :products
+ # resources :products
# Sample resource route with options:
- # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
+ # resources :products do
+ # member do
+ # get 'short'
+ # post 'toggle'
+ # end
+ #
+ # collection do
+ # get 'sold'
+ # end
+ # end
# Sample resource route with sub-resources:
- # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
-
+ # resources :products do
+ # resources :comments, :sales
+ # resource :seller
+ # end
+
# Sample resource route with more complex sub-resources
- # map.resources :products do |products|
- # products.resources :comments
- # products.resources :sales, :collection => { :recent => :get }
+ # resources :products do
+ # resources :comments
+ # resources :sales do
+ # get 'recent', :on => :collection
+ # end
# end
# Sample resource route within a namespace:
- # map.namespace :admin do |admin|
- # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
- # admin.resources :products
+ # namespace :admin do
+ # # Directs /admin/products/* to Admin::ProductsController
+ # # (app/controllers/admin/products_controller.rb)
+ # resources :products
# end
- # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
- # map.root :controller => "welcome"
+ get 'local/:login' => 'sessions#local'
+ get 'logout' => 'sessions#destroy'
+ get 'login' => 'sessions#new'
+ get 'register' => 'users#create'
+ get 'signup' => 'users#new'
+ resources :users
+ get 'tag/create' => 'tag#create'
+ get 'tag/:id' => 'tag#show'
- # See how all your routes lay out with "rake routes"
-
- # Install the default routes as the lowest priority.
- # Note: These default routes make all actions in every controller accessible via GET requests. You should
- # consider removing the them or commenting them out if you're using named routes and resources.
+ get 'session' => 'session#create', :conditions => { :method => :get }
+ resources :session
# Registered user pages:
- map.profile '/profile', :controller => 'users', :action => 'profile', :id => 0
- map.profile '/profile/:id', :controller => 'users', :action => 'profile'
- map.dashboard '/dashboard', :controller => 'users', :action => 'dashboard'
- map.assign '/assign/:id', :controller => 'map', :action => 'assign'
- #map.comments '/comments', :controller => 'users', :action => 'comments'
+ get 'profile' => 'users#profile', :id => 0
+ get 'profile/:id' => 'users#profile'
+ get 'dashboard' => 'users#dashboard'
+ get 'assign/:id' => 'map#assign'
+ #map.comments '/comments' => 'users#comments'
- map.root :controller => "map", :action => "index"
- map.connect 'sorter/', :controller => "utility", :action => "sorter"
+ get 'sorter/' => 'utility#sorter'
- map.connect 'tms/:id/alt/:z/:x/:y.png', :controller => "utility", :action => "tms_alt"
- map.connect 'tms/:id/', :controller => "utility", :action => "tms_info"
- map.connect 'tms/:id/alt/', :controller => "utility", :action => "tms_info"
- map.connect 'stylesheet/:id.gss', :controller => "map", :action => "stylesheet"
- map.connect 'maps', :controller => "map", :action => "index"
- map.connect 'maps/:id', :controller => "map", :action => "show"
- map.connect 'import/:name', :controller => "warper", :action => "import"
+ get 'tms/:id/alt/:z/:x/:y.png' => 'utility#tms_alt'
+ get 'tms/:id/' => 'utility#tms_info'
+ get 'tms/:id/alt/' => 'utility#tms_info'
+ get 'stylesheet/:id.gss' => 'map#stylesheet'
+ get 'maps' => 'map#index'
+ get 'map/create/:id' => 'map#index'
+ get 'maps/:id' => 'map#show'
+ get 'import/:name' => 'warper#import'
- map.connect 'authors', :controller => 'users', :action => 'authors'
- map.connect 'author/list', :controller => 'author', :action => 'list'
- map.connect 'author/emails', :controller => 'author', :action => 'emails'
- map.connect 'author/:id', :controller => 'author', :action => 'show'
- map.connect 'api/0.6/geohash/:id.json', :controller => 'api', :action => 'planet'
+ get 'authors' => 'users#authors'
+ get 'author/list' => 'author#list'
+ get 'author/emails' => 'author#emails'
+ get 'author/:id' => 'author#show'
+ get 'api/0.6/geohash/:id.json' => 'api#planet'
+
+ # You can have the root of your site routed with 'root'
+ # just remember to delete public/index.html.
+ root :to => 'map#index'
+
+ # See how all your routes lay out with 'rake routes'
+
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
+ # Note: This route will make all actions in every controller accessible via GET requests.
+ # match ':controller(/:action(/:id))(.:format)'
+
+ get ':controller/:action/:id'
+ #get ':controller.:format' # this doesn't work -- what's it for?
+ get ':controller/:action.:format'
+ get ':controller/:action/:id.:format'
- map.connect ':controller/:action/:id'
- map.connect ':controller.:format'
- map.connect ':controller/:action.:format'
- map.connect ':controller/:action/:id.:format'
end
diff --git a/db/migrate/20141103164503_change_warpable_columns.rb b/db/migrate/20141103164503_change_warpable_columns.rb
new file mode 100644
index 00000000..491f4538
--- /dev/null
+++ b/db/migrate/20141103164503_change_warpable_columns.rb
@@ -0,0 +1,13 @@
+class ChangeWarpableColumns < ActiveRecord::Migration
+ def up
+ rename_column(:warpables, :photo_file_name, :filename)
+ rename_column(:warpables, :photo_content_type, :content_type)
+ rename_column(:warpables, :photo_file_size, :size)
+ end
+
+ def down
+ rename_column(:warpables, :filename, :photo_file_name)
+ rename_column(:warpables, :content_type, :photo_content_type)
+ rename_column(:warpables, :size, :photo_file_size)
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 3757dbce..1444a1ee 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1,15 +1,17 @@
-# This file is auto-generated from the current state of the database. Instead of editing this file,
-# please use the migrations feature of Active Record to incrementally modify your database, and
-# then regenerate this schema definition.
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
#
-# Note that this schema.rb definition is the authoritative source for your database schema. If you need
-# to create the application database on another system, you should be using db:schema:load, not running
-# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130128184718) do
+ActiveRecord::Schema.define(:version => 20130124160539) do
create_table "exports", :force => true do |t|
t.integer "map_id", :default => 0
@@ -66,7 +68,6 @@ ActiveRecord::Schema.define(:version => 20130128184718) do
t.string "description", :default => ""
t.integer "map_id", :default => 0
t.integer "way_order", :default => 0
- t.text "body"
end
create_table "tags", :force => true do |t|
@@ -112,6 +113,19 @@ ActiveRecord::Schema.define(:version => 20130128184718) do
t.float "cm_per_pixel", :default => 0.0, :null => false
end
+ create_table "warpeds", :force => true do |t|
+ t.integer "parent_id"
+ t.string "content_type"
+ t.string "filename"
+ t.string "thumbnail"
+ t.integer "size"
+ t.integer "width"
+ t.integer "height"
+ t.string "transform_type"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "ways", :force => true do |t|
t.string "color", :default => "red"
t.string "author", :default => "anonymous"
@@ -123,9 +137,7 @@ ActiveRecord::Schema.define(:version => 20130128184718) do
t.datetime "updated_at"
t.string "name", :default => ""
t.string "description", :default => ""
- t.boolean "complete", :default => true
t.integer "map_id", :default => 0
- t.text "body"
end
end
diff --git a/db/seeds.rb b/db/seeds.rb
new file mode 100644
index 00000000..4edb1e85
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
+# Mayor.create(name: 'Emanuel', city: cities.first)
diff --git a/doc/README_FOR_APP b/doc/README_FOR_APP
deleted file mode 100644
index e33b8581..00000000
--- a/doc/README_FOR_APP
+++ /dev/null
@@ -1,5 +0,0 @@
-To build the guides:
-
-* Install source-highlighter (http://www.gnu.org/software/src-highlite/source-highlight.html)
-* Install the mizuho gem (http://github.com/FooBarWidget/mizuho/tree/master)
-* Run `rake guides` from the railties directory
\ No newline at end of file
diff --git a/lib/assets/.gitkeep b/lib/assets/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/lib/tasks/.gitkeep b/lib/tasks/.gitkeep
new file mode 100644
index 00000000..e69de29b
diff --git a/lib/tasks/attachment_tasks.rake b/lib/tasks/attachment_tasks.rake
new file mode 100644
index 00000000..894751e1
--- /dev/null
+++ b/lib/tasks/attachment_tasks.rake
@@ -0,0 +1,125 @@
+# see http://ramblingsonrails.com/how-to-migrate-a-rails-app-from-attachment_fu-to-paperclip
+require 'right_aws'
+
+namespace :utils do
+ namespace :attachments do
+ task :initialize_s3 => :environment do
+ s3_config = YAML.load_file(File.join(File.dirname(__FILE__), '/../../config/amazon_s3.yml'))
+ s3_config = s3_config[RAILS_ENV].to_options
+
+ @s3 = RightAws::S3.new(s3_config[:access_key_id], s3_config[:secret_access_key])
+ end
+
+ desc "Make a copy of an S3 bucket"
+ task :copy_s3_bucket => :initialize_s3 do
+ from_bucket = @s3.bucket(ENV['FROM'])
+ to_bucket = @s3.bucket(ENV['TO'], true)
+
+ puts "Getting #{from_bucket.name} keys"
+ keys = from_bucket.keys
+ puts "keys retrieved: #{keys.size}"
+ keys.each do |key|
+ (1..10).each do |try|
+ begin
+ puts "Copying #{from_bucket.name}/#{key.name} to #{to_bucket.name}/#{key.name}"
+ from_bucket.s3.interface.copy(from_bucket.name, key.name, to_bucket.name, key.name)
+ break
+ rescue Exception => e
+ puts "problem, trying again..."
+ sleep 1
+ end
+ end
+ end
+ end
+
+ desc "Empty an S3 bucket by deleting all the contained files"
+ task :empty_s3_bucket => :initialize_s3 do
+ from_bucket = @s3.bucket(ENV['BUCKET'])
+
+ puts "Emtptying #{from_bucket.name}"
+ bucket.keys({'max-keys' => 100}).each do |key|
+ (1..10).each do |try|
+ begin
+ print '.'
+ STDOUT.flush
+ key.delete
+ break
+ rescue Exception => e
+ puts "\nproblem, trying again..."
+ sleep 1
+ end
+ end
+ end
+ end
+
+ desc "Delete an S3 bucket and all its contents"
+ task :delete_s3_bucket => :empty_s3_bucket do
+ from_bucket = @s3.bucket(ENV['BUCKET'])
+ from_bucket.delete
+ end
+
+ desc "Migrate Attachement_fu to Paperclip"
+ task :migrate_attachment_fu_to_paperclip => :initialize_s3 do
+ #Set the Attachment_fu class you'll be migrating
+ Klass = Warpable
+
+ bucket = @s3.bucket(ENV['BUCKET'])
+
+ #Move Attachment_fu files (keys) to new Paperclip names
+ #Paperclip allows you to customise the naming schema of your
+ #S3 keys (filenames) so you will need to handle that here manually
+ #This scripts caters for the naming style :id/:style.:extension
+ Klass.find(:all, :conditions => {:parent_id => nil}).each do |obj|
+ parent_id = obj.id
+
+ original_key_name = "#{Klass.name.downcase.pluralize}/#{parent_id}/#{obj.filename}"
+ new_key_name = "paperclip/#{parent_id}/original#{File.extname(obj.filename).downcase}"
+
+ # modified to copy not move
+ #move_key bucket, original_key_name, new_key_name
+ copy_key bucket, original_key_name, new_key_name
+
+ #Get thumbnails
+ if obj.thumbnailable?
+ Klass.find(obj.thumbnail_ids).each do |child|
+ original_key_name = "#{Klass.name.downcase.pluralize}/#{parent_id}/#{child.filename}"
+ new_key_name = "paperclip/#{parent_id}/#{child.thumbnail}#{File.extname(child.filename).downcase}"
+
+ #move_key bucket, original_key_name, new_key_name
+ copy_key bucket, original_key_name, new_key_name
+ end
+ end
+ end
+ end
+
+ def copy_key(bucket, original_key_name, new_key_name)
+ puts "Copying #{bucket.name}/#{original_key_name} to #{bucket.name}/#{new_key_name}"
+ #Occationally I am getting a 500 error from amazon so I'm putting these in a loop so that we can retry a couple of times if we need to
+ (1..10).each do |try|
+ begin
+ original_key = RightAws::S3::Key.create(bucket, original_key_name)
+ bucket.copy_key original_key_name, new_key_name if original_key.exists?
+ break
+ rescue Exception => e
+ puts "problem, trying again..."
+ sleep 1
+ end
+ end
+ end
+
+ def move_key(bucket, original_key_name, new_key_name)
+ puts "Moving #{bucket.name}/#{original_key_name} to #{bucket.name}/#{new_key_name}"
+ #Occationally I am getting a 500 error from amazon so I'm putting these in a loop so that we can retry a couple of times if we need to
+ (1..10).each do |try|
+ begin
+ original_key = RightAws::S3::Key.create(bucket, original_key_name)
+ bucket.move_key original_key_name, new_key_name if original_key.exists?
+ break
+ rescue Exception => e
+ puts "problem, trying again..."
+ sleep 1
+ end
+ end
+ end
+ end
+end
diff --git a/public/404.html b/public/404.html
index eff660b9..9a48320a 100644
--- a/public/404.html
+++ b/public/404.html
@@ -1,23 +1,19 @@
-
-
-
-
+
+
-
The page you were looking for doesn't exist (404)
-
+
@@ -27,4 +23,4 @@
You may have mistyped the address or the page may have moved.
-
\ No newline at end of file
+
diff --git a/public/422.html b/public/422.html
index b54e4a3c..83660ab1 100644
--- a/public/422.html
+++ b/public/422.html
@@ -1,23 +1,19 @@
-
-
-
-
+
+
-
The change you wanted was rejected (422)
-
+
@@ -27,4 +23,4 @@
Maybe you tried to change something you didn't have access to.
-
\ No newline at end of file
+
diff --git a/public/500.html b/public/500.html
index 0cd07c10..f3648a0d 100644
--- a/public/500.html
+++ b/public/500.html
@@ -1,33 +1,25 @@
-
-
-
-
+
+
-
We're sorry, but something went wrong (500)
-
+
We're sorry, but something went wrong.
-
We've been notified about this issue and we'll take a look at it shortly.
-
(If you're the administrator of this website, then please read
- the log file "<%=h RAILS_ENV %>.log"
- to find out what went wrong.)
<%= submit_tag :Save %>
- # <% end -%>
- #
- # @attachment = Attachment.create! params[:attachment]
- #
- # TODO: Allow it to work with Merb tempfiles too.
- def uploaded_data=(file_data)
- return nil if file_data.nil? || file_data.size == 0
- self.content_type = file_data.content_type
- self.filename = file_data.original_filename if respond_to?(:filename)
- if file_data.is_a?(StringIO)
- file_data.rewind
- self.temp_data = file_data.read
- else
- self.temp_path = file_data
- end
- end
-
- # Gets the latest temp path from the collection of temp paths. While working with an attachment,
- # multiple Tempfile objects may be created for various processing purposes (resizing, for example).
- # An array of all the tempfile objects is stored so that the Tempfile instance is held on to until
- # it's not needed anymore. The collection is cleared after saving the attachment.
- def temp_path
- p = temp_paths.first
- p.respond_to?(:path) ? p.path : p.to_s
- end
-
- # Gets an array of the currently used temp paths. Defaults to a copy of #full_filename.
- def temp_paths
- @temp_paths ||= (new_record? || !respond_to?(:full_filename) || !File.exist?(full_filename) ?
- [] : [copy_to_temp_file(full_filename)])
- end
-
- # Adds a new temp_path to the array. This should take a string or a Tempfile. This class makes no
- # attempt to remove the files, so Tempfiles should be used. Tempfiles remove themselves when they go out of scope.
- # You can also use string paths for temporary files, such as those used for uploaded files in a web server.
- def temp_path=(value)
- temp_paths.unshift value
- temp_path
- end
-
- # Gets the data from the latest temp file. This will read the file into memory.
- def temp_data
- save_attachment? ? File.read(temp_path) : nil
- end
-
- # Writes the given data to a Tempfile and adds it to the collection of temp files.
- def temp_data=(data)
- self.temp_path = write_to_temp_file data unless data.nil?
- end
-
- # Copies the given file to a randomly named Tempfile.
- def copy_to_temp_file(file)
- self.class.copy_to_temp_file file, random_tempfile_filename
- end
-
- # Writes the given file to a randomly named Tempfile.
- def write_to_temp_file(data)
- self.class.write_to_temp_file data, random_tempfile_filename
- end
-
- # Stub for creating a temp file from the attachment data. This should be defined in the backend module.
- def create_temp_file() end
-
- # Allows you to work with a processed representation (RMagick, ImageScience, etc) of the attachment in a block.
- #
- # @attachment.with_image do |img|
- # self.data = img.thumbnail(100, 100).to_blob
- # end
- #
- def with_image(&block)
- self.class.with_image(temp_path, &block)
- end
-
- protected
- # Generates a unique filename for a Tempfile.
- def random_tempfile_filename
- "#{rand Time.now.to_i}#{filename || 'attachment'}"
- end
-
- def sanitize_filename(filename)
- returning filename.strip do |name|
- # NOTE: File.basename doesn't work right with Windows paths on Unix
- # get only the filename, not the whole path
- name.gsub! /^.*(\\|\/)/, ''
-
- # Finally, replace all non alphanumeric, underscore or periods with underscore
- name.gsub! /[^\w\.\-]/, '_'
- end
- end
-
- # before_validation callback.
- def set_size_from_temp_path
- self.size = File.size(temp_path) if save_attachment?
- end
-
- # validates the size and content_type attributes according to the current model's options
- def attachment_attributes_valid?
- [:size, :content_type].each do |attr_name|
- enum = attachment_options[attr_name]
- errors.add attr_name, ActiveRecord::Errors.default_error_messages[:inclusion] unless enum.nil? || enum.include?(send(attr_name))
- end
- end
-
- # Initializes a new thumbnail with the given suffix.
- def find_or_initialize_thumbnail(file_name_suffix)
- respond_to?(:parent_id) ?
- thumbnail_class.find_or_initialize_by_thumbnail_and_parent_id(file_name_suffix.to_s, id) :
- thumbnail_class.find_or_initialize_by_thumbnail(file_name_suffix.to_s)
- end
-
- # Stub for a #process_attachment method in a processor
- def process_attachment
- @saved_attachment = save_attachment?
- end
-
- # Cleans up after processing. Thumbnails are created, the attachment is stored to the backend, and the temp_paths are cleared.
- def after_process_attachment
- if @saved_attachment
- if respond_to?(:process_attachment_with_processing) && thumbnailable? && !attachment_options[:thumbnails].blank? && parent_id.nil?
- temp_file = temp_path || create_temp_file
- attachment_options[:thumbnails].each { |suffix, size| create_or_update_thumbnail(temp_file, suffix, *size) }
- end
- save_to_storage
- @temp_paths.clear
- @saved_attachment = nil
- callback :after_attachment_saved
- end
- end
-
- # Resizes the given processed img object with either the attachment resize options or the thumbnail resize options.
- def resize_image_or_thumbnail!(img)
- if (!respond_to?(:parent_id) || parent_id.nil?) && attachment_options[:resize_to] # parent image
- resize_image(img, attachment_options[:resize_to])
- elsif thumbnail_resize_options # thumbnail
- resize_image(img, thumbnail_resize_options)
- end
- end
-
- # Yanked from ActiveRecord::Callbacks, modified so I can pass args to the callbacks besides self.
- # Only accept blocks, however
- if ActiveSupport.const_defined?(:Callbacks)
- # Rails 2.1 and beyond!
- def callback_with_args(method, arg = self)
- notify(method)
-
- result = run_callbacks(method, { :object => arg }) { |result, object| result == false }
-
- if result != false && respond_to_without_attributes?(method)
- result = send(method)
- end
-
- result
- end
-
- def run_callbacks(kind, options = {}, &block)
- options.reverse_merge!( :object => self )
- self.class.send("#{kind}_callback_chain").run(options[:object], options, &block)
- end
- else
- # Rails 2.0
- def callback_with_args(method, arg = self)
- notify(method)
-
- result = nil
- callbacks_for(method).each do |callback|
- result = callback.call(self, arg)
- return false if result == false
- end
- result
- end
- end
-
- # Removes the thumbnails for the attachment, if it has any
- def destroy_thumbnails
- self.thumbnails.each { |thumbnail| thumbnail.destroy } if thumbnailable?
- end
- end
- end
-end
diff --git a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/db_file_backend.rb b/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/db_file_backend.rb
deleted file mode 100644
index 23881e75..00000000
--- a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/db_file_backend.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-module Technoweenie # :nodoc:
- module AttachmentFu # :nodoc:
- module Backends
- # Methods for DB backed attachments
- module DbFileBackend
- def self.included(base) #:nodoc:
- Object.const_set(:DbFile, Class.new(ActiveRecord::Base)) unless Object.const_defined?(:DbFile)
- base.belongs_to :db_file, :class_name => '::DbFile', :foreign_key => 'db_file_id'
- end
-
- # Creates a temp file with the current db data.
- def create_temp_file
- write_to_temp_file current_data
- end
-
- # Gets the current data from the database
- def current_data
- db_file.data
- end
-
- protected
- # Destroys the file. Called in the after_destroy callback
- def destroy_file
- db_file.destroy if db_file
- end
-
- # Saves the data to the DbFile model
- def save_to_storage
- if save_attachment?
- (db_file || build_db_file).data = temp_data
- db_file.save!
- self.class.update_all ['db_file_id = ?', self.db_file_id = db_file.id], ['id = ?', id]
- end
- true
- end
- end
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb b/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb
deleted file mode 100644
index f16e0676..00000000
--- a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb
+++ /dev/null
@@ -1,97 +0,0 @@
-require 'fileutils'
-module Technoweenie # :nodoc:
- module AttachmentFu # :nodoc:
- module Backends
- # Methods for file system backed attachments
- module FileSystemBackend
- def self.included(base) #:nodoc:
- base.before_update :rename_file
- end
-
- # Gets the full path to the filename in this format:
- #
- # # This assumes a model name like MyModel
- # # public/#{table_name} is the default filesystem path
- # RAILS_ROOT/public/my_models/5/blah.jpg
- #
- # Overwrite this method in your model to customize the filename.
- # The optional thumbnail argument will output the thumbnail's filename.
- def full_filename(thumbnail = nil)
- file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s
- File.join(RAILS_ROOT, file_system_path, *partitioned_path(thumbnail_name_for(thumbnail)))
- end
-
- # Used as the base path that #public_filename strips off full_filename to create the public path
- def base_path
- @base_path ||= File.join(RAILS_ROOT, 'public')
- end
-
- # The attachment ID used in the full path of a file
- def attachment_path_id
- ((respond_to?(:parent_id) && parent_id) || id).to_i
- end
-
- # overrwrite this to do your own app-specific partitioning.
- # you can thank Jamis Buck for this: http://www.37signals.com/svn/archives2/id_partitioning.php
- def partitioned_path(*args)
- ("%08d" % attachment_path_id).scan(/..../) + args
- end
-
- # Gets the public path to the file
- # The optional thumbnail argument will output the thumbnail's filename.
- def public_filename(thumbnail = nil)
- full_filename(thumbnail).gsub %r(^#{Regexp.escape(base_path)}), ''
- end
-
- def filename=(value)
- @old_filename = full_filename unless filename.nil? || @old_filename
- write_attribute :filename, sanitize_filename(value)
- end
-
- # Creates a temp file from the currently saved file.
- def create_temp_file
- copy_to_temp_file full_filename
- end
-
- protected
- # Destroys the file. Called in the after_destroy callback
- def destroy_file
- FileUtils.rm full_filename
- # remove directory also if it is now empty
- Dir.rmdir(File.dirname(full_filename)) if (Dir.entries(File.dirname(full_filename))-['.','..']).empty?
- rescue
- logger.info "Exception destroying #{full_filename.inspect}: [#{$!.class.name}] #{$1.to_s}"
- logger.warn $!.backtrace.collect { |b| " > #{b}" }.join("\n")
- end
-
- # Renames the given file before saving
- def rename_file
- return unless @old_filename && @old_filename != full_filename
- if save_attachment? && File.exists?(@old_filename)
- FileUtils.rm @old_filename
- elsif File.exists?(@old_filename)
- FileUtils.mv @old_filename, full_filename
- end
- @old_filename = nil
- true
- end
-
- # Saves the file to the file system
- def save_to_storage
- if save_attachment?
- # TODO: This overwrites the file if it exists, maybe have an allow_overwrite option?
- FileUtils.mkdir_p(File.dirname(full_filename))
- File.cp(temp_path, full_filename)
- File.chmod(attachment_options[:chmod] || 0644, full_filename)
- end
- @old_filename = nil
- true
- end
-
- def current_data
- File.file?(full_filename) ? File.read(full_filename) : nil
- end
- end
- end
- end
-end
diff --git a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb b/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb
deleted file mode 100644
index 2c2be130..00000000
--- a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb
+++ /dev/null
@@ -1,303 +0,0 @@
-module Technoweenie # :nodoc:
- module AttachmentFu # :nodoc:
- module Backends
- # = AWS::S3 Storage Backend
- #
- # Enables use of {Amazon's Simple Storage Service}[http://aws.amazon.com/s3] as a storage mechanism
- #
- # == Requirements
- #
- # Requires the {AWS::S3 Library}[http://amazon.rubyforge.org] for S3 by Marcel Molina Jr. installed either
- # as a gem or a as a Rails plugin.
- #
- # == Configuration
- #
- # Configuration is done via RAILS_ROOT/config/amazon_s3.yml and is loaded according to the RAILS_ENV.
- # The minimum connection options that you must specify are a bucket name, your access key id and your secret access key.
- # If you don't already have your access keys, all you need to sign up for the S3 service is an account at Amazon.
- # You can sign up for S3 and get access keys by visiting http://aws.amazon.com/s3.
- #
- # Example configuration (RAILS_ROOT/config/amazon_s3.yml)
- #
- # development:
- # bucket_name: appname_development
- # access_key_id:
- # secret_access_key:
- #
- # test:
- # bucket_name: appname_test
- # access_key_id:
- # secret_access_key:
- #
- # production:
- # bucket_name: appname
- # access_key_id:
- # secret_access_key:
- #
- # You can change the location of the config path by passing a full path to the :s3_config_path option.
- #
- # has_attachment :storage => :s3, :s3_config_path => (RAILS_ROOT + '/config/s3.yml')
- #
- # === Required configuration parameters
- #
- # * :access_key_id - The access key id for your S3 account. Provided by Amazon.
- # * :secret_access_key - The secret access key for your S3 account. Provided by Amazon.
- # * :bucket_name - A unique bucket name (think of the bucket_name as being like a database name).
- #
- # If any of these required arguments is missing, a MissingAccessKey exception will be raised from AWS::S3.
- #
- # == About bucket names
- #
- # Bucket names have to be globaly unique across the S3 system. And you can only have up to 100 of them,
- # so it's a good idea to think of a bucket as being like a database, hence the correspondance in this
- # implementation to the development, test, and production environments.
- #
- # The number of objects you can store in a bucket is, for all intents and purposes, unlimited.
- #
- # === Optional configuration parameters
- #
- # * :server - The server to make requests to. Defaults to s3.amazonaws.com.
- # * :port - The port to the requests should be made on. Defaults to 80 or 443 if :use_ssl is set.
- # * :use_ssl - If set to true, :port will be implicitly set to 443, unless specified otherwise. Defaults to false.
- #
- # == Usage
- #
- # To specify S3 as the storage mechanism for a model, set the acts_as_attachment :storage option to :s3.
- #
- # class Photo < ActiveRecord::Base
- # has_attachment :storage => :s3
- # end
- #
- # === Customizing the path
- #
- # By default, files are prefixed using a pseudo hierarchy in the form of :table_name/:id, which results
- # in S3 urls that look like: http(s)://:server/:bucket_name/:table_name/:id/:filename with :table_name
- # representing the customizable portion of the path. You can customize this prefix using the :path_prefix
- # option:
- #
- # class Photo < ActiveRecord::Base
- # has_attachment :storage => :s3, :path_prefix => 'my/custom/path'
- # end
- #
- # Which would result in URLs like http(s)://:server/:bucket_name/my/custom/path/:id/:filename.
- #
- # === Permissions
- #
- # By default, files are stored on S3 with public access permissions. You can customize this using
- # the :s3_access option to has_attachment. Available values are
- # :private, :public_read_write, and :authenticated_read.
- #
- # === Other options
- #
- # Of course, all the usual configuration options apply, such as content_type and thumbnails:
- #
- # class Photo < ActiveRecord::Base
- # has_attachment :storage => :s3, :content_type => ['application/pdf', :image], :resize_to => 'x50'
- # has_attachment :storage => :s3, :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }
- # end
- #
- # === Accessing S3 URLs
- #
- # You can get an object's URL using the s3_url accessor. For example, assuming that for your postcard app
- # you had a bucket name like 'postcard_world_development', and an attachment model called Photo:
- #
- # @postcard.s3_url # => http(s)://s3.amazonaws.com/postcard_world_development/photos/1/mexico.jpg
- #
- # The resulting url is in the form: http(s)://:server/:bucket_name/:table_name/:id/:file.
- # The optional thumbnail argument will output the thumbnail's filename (if any).
- #
- # Additionally, you can get an object's base path relative to the bucket root using
- # base_path:
- #
- # @photo.file_base_path # => photos/1
- #
- # And the full path (including the filename) using full_filename:
- #
- # @photo.full_filename # => photos/
- #
- # Niether base_path or full_filename include the bucket name as part of the path.
- # You can retrieve the bucket name using the bucket_name method.
- module S3Backend
- class RequiredLibraryNotFoundError < StandardError; end
- class ConfigFileNotFoundError < StandardError; end
-
- def self.included(base) #:nodoc:
- mattr_reader :bucket_name, :s3_config
-
- begin
- require 'aws/s3'
- include AWS::S3
- rescue LoadError
- raise RequiredLibraryNotFoundError.new('AWS::S3 could not be loaded')
- end
-
- begin
- @@s3_config_path = base.attachment_options[:s3_config_path] || (RAILS_ROOT + '/config/amazon_s3.yml')
- @@s3_config = @@s3_config = YAML.load(ERB.new(File.read(@@s3_config_path)).result)[RAILS_ENV].symbolize_keys
- #rescue
- # raise ConfigFileNotFoundError.new('File %s not found' % @@s3_config_path)
- end
-
- @@bucket_name = s3_config[:bucket_name]
-
- Base.establish_connection!(s3_config.slice(:access_key_id, :secret_access_key, :server, :port, :use_ssl, :persistent, :proxy))
-
- # Bucket.create(@@bucket_name)
-
- base.before_update :rename_file
- end
-
- def self.protocol
- @protocol ||= s3_config[:use_ssl] ? 'https://' : 'http://'
- end
-
- def self.hostname
- @hostname ||= s3_config[:server] || AWS::S3::DEFAULT_HOST
- end
-
- def self.port_string
- @port_string ||= (s3_config[:port].nil? || s3_config[:port] == (s3_config[:use_ssl] ? 443 : 80)) ? '' : ":#{s3_config[:port]}"
- end
-
- module ClassMethods
- def s3_protocol
- Technoweenie::AttachmentFu::Backends::S3Backend.protocol
- end
-
- def s3_hostname
- Technoweenie::AttachmentFu::Backends::S3Backend.hostname
- end
-
- def s3_port_string
- Technoweenie::AttachmentFu::Backends::S3Backend.port_string
- end
- end
-
- # Overwrites the base filename writer in order to store the old filename
- def filename=(value)
- @old_filename = filename unless filename.nil? || @old_filename
- write_attribute :filename, sanitize_filename(value)
- end
-
- # The attachment ID used in the full path of a file
- def attachment_path_id
- ((respond_to?(:parent_id) && parent_id) || id).to_s
- end
-
- # The pseudo hierarchy containing the file relative to the bucket name
- # Example: :table_name/:id
- def base_path
- File.join(attachment_options[:path_prefix], attachment_path_id)
- end
-
- # The full path to the file relative to the bucket name
- # Example: :table_name/:id/:filename
- def full_filename(thumbnail = nil)
- File.join(base_path, thumbnail_name_for(thumbnail))
- end
-
- # All public objects are accessible via a GET request to the S3 servers. You can generate a
- # url for an object using the s3_url method.
- #
- # @photo.s3_url
- #
- # The resulting url is in the form: http(s)://:server/:bucket_name/:table_name/:id/:file where
- # the :server variable defaults to AWS::S3 URL::DEFAULT_HOST (s3.amazonaws.com) and can be
- # set using the configuration parameters in RAILS_ROOT/config/amazon_s3.yml.
- #
- # The optional thumbnail argument will output the thumbnail's filename (if any).
- def s3_url(thumbnail = nil)
- File.join(s3_protocol + s3_hostname + s3_port_string, bucket_name, full_filename(thumbnail))
- end
- alias :public_filename :s3_url
-
- # All private objects are accessible via an authenticated GET request to the S3 servers. You can generate an
- # authenticated url for an object like this:
- #
- # @photo.authenticated_s3_url
- #
- # By default authenticated urls expire 5 minutes after they were generated.
- #
- # Expiration options can be specified either with an absolute time using the :expires option,
- # or with a number of seconds relative to now with the :expires_in option:
- #
- # # Absolute expiration date (October 13th, 2025)
- # @photo.authenticated_s3_url(:expires => Time.mktime(2025,10,13).to_i)
- #
- # # Expiration in five hours from now
- # @photo.authenticated_s3_url(:expires_in => 5.hours)
- #
- # You can specify whether the url should go over SSL with the :use_ssl option.
- # By default, the ssl settings for the current connection will be used:
- #
- # @photo.authenticated_s3_url(:use_ssl => true)
- #
- # Finally, the optional thumbnail argument will output the thumbnail's filename (if any):
- #
- # @photo.authenticated_s3_url('thumbnail', :expires_in => 5.hours, :use_ssl => true)
- def authenticated_s3_url(*args)
- thumbnail = args.first.is_a?(String) ? args.first : nil
- options = args.last.is_a?(Hash) ? args.last : {}
- S3Object.url_for(full_filename(thumbnail), bucket_name, options)
- end
-
- def create_temp_file
- write_to_temp_file current_data
- end
-
- def current_data
- S3Object.value full_filename, bucket_name
- end
-
- def s3_protocol
- Technoweenie::AttachmentFu::Backends::S3Backend.protocol
- end
-
- def s3_hostname
- Technoweenie::AttachmentFu::Backends::S3Backend.hostname
- end
-
- def s3_port_string
- Technoweenie::AttachmentFu::Backends::S3Backend.port_string
- end
-
- protected
- # Called in the after_destroy callback
- def destroy_file
- S3Object.delete full_filename, bucket_name
- end
-
- def rename_file
- return unless @old_filename && @old_filename != filename
-
- old_full_filename = File.join(base_path, @old_filename)
-
- S3Object.rename(
- old_full_filename,
- full_filename,
- bucket_name,
- :access => attachment_options[:s3_access]
- )
-
- @old_filename = nil
- true
- end
-
- def save_to_storage
- if save_attachment?
- S3Object.store(
- full_filename,
- (temp_path ? File.open(temp_path) : temp_data),
- bucket_name,
- :content_type => content_type,
- :access => attachment_options[:s3_access]
- )
- end
-
- @old_filename = nil
- true
- end
- end
- end
- end
-end
diff --git a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/core_image_processor.rb b/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/core_image_processor.rb
deleted file mode 100644
index 8120b69b..00000000
--- a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/core_image_processor.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require 'red_artisan/core_image/processor'
-
-module Technoweenie # :nodoc:
- module AttachmentFu # :nodoc:
- module Processors
- module CoreImageProcessor
- def self.included(base)
- base.send :extend, ClassMethods
- base.alias_method_chain :process_attachment, :processing
- end
-
- module ClassMethods
- def with_image(file, &block)
- block.call OSX::CIImage.from(file)
- end
- end
-
- protected
- def process_attachment_with_processing
- return unless process_attachment_without_processing
- with_image do |img|
- self.width = img.extent.size.width if respond_to?(:width)
- self.height = img.extent.size.height if respond_to?(:height)
- resize_image_or_thumbnail! img
- callback_with_args :after_resize, img
- end if image?
- end
-
- # Performs the actual resizing operation for a thumbnail
- def resize_image(img, size)
- processor = ::RedArtisan::CoreImage::Processor.new(img)
- size = size.first if size.is_a?(Array) && size.length == 1
- if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))
- if size.is_a?(Fixnum)
- processor.fit(size)
- else
- processor.resize(size[0], size[1])
- end
- else
- new_size = [img.extent.size.width, img.extent.size.height] / size.to_s
- processor.resize(new_size[0], new_size[1])
- end
-
- processor.render do |result|
- self.width = result.extent.size.width if respond_to?(:width)
- self.height = result.extent.size.height if respond_to?(:height)
- result.save self.temp_path, OSX::NSJPEGFileType
- self.size = File.size(self.temp_path)
- end
- end
- end
- end
- end
-end
-
-
diff --git a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/gd2_processor.rb b/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/gd2_processor.rb
deleted file mode 100644
index d120b25a..00000000
--- a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/gd2_processor.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-require 'rubygems'
-require 'gd2'
-module Technoweenie # :nodoc:
- module AttachmentFu # :nodoc:
- module Processors
- module Gd2Processor
- def self.included(base)
- base.send :extend, ClassMethods
- base.alias_method_chain :process_attachment, :processing
- end
-
- module ClassMethods
- # Yields a block containing a GD2 Image for the given binary data.
- def with_image(file, &block)
- im = GD2::Image.import(file)
- block.call(im)
- end
- end
-
- protected
- def process_attachment_with_processing
- return unless process_attachment_without_processing && image?
- with_image do |img|
- resize_image_or_thumbnail! img
- self.width = img.width
- self.height = img.height
- callback_with_args :after_resize, img
- end
- end
-
- # Performs the actual resizing operation for a thumbnail
- def resize_image(img, size)
- size = size.first if size.is_a?(Array) && size.length == 1
- if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))
- if size.is_a?(Fixnum)
- # Borrowed from image science's #thumbnail method and adapted
- # for this.
- scale = size.to_f / (img.width > img.height ? img.width.to_f : img.height.to_f)
- img.resize!((img.width * scale).round(1), (img.height * scale).round(1), false)
- else
- img.resize!(size.first, size.last, false)
- end
- else
- w, h = [img.width, img.height] / size.to_s
- img.resize!(w, h, false)
- end
- self.temp_path = random_tempfile_filename
- self.size = img.export(self.temp_path)
- end
-
- end
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb b/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb
deleted file mode 100644
index 6f27833d..00000000
--- a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require 'image_science'
-module Technoweenie # :nodoc:
- module AttachmentFu # :nodoc:
- module Processors
- module ImageScienceProcessor
- def self.included(base)
- base.send :extend, ClassMethods
- base.alias_method_chain :process_attachment, :processing
- end
-
- module ClassMethods
- # Yields a block containing an Image Science image for the given binary data.
- def with_image(file, &block)
- ::ImageScience.with_image file, &block
- end
- end
-
- protected
- def process_attachment_with_processing
- return unless process_attachment_without_processing && image?
- with_image do |img|
- self.width = img.width if respond_to?(:width)
- self.height = img.height if respond_to?(:height)
- resize_image_or_thumbnail! img
- end
- end
-
- # Performs the actual resizing operation for a thumbnail
- def resize_image(img, size)
- # create a dummy temp file to write to
- # ImageScience doesn't handle all gifs properly, so it converts them to
- # pngs for thumbnails. It has something to do with trying to save gifs
- # with a larger palette than 256 colors, which is all the gif format
- # supports.
- filename.sub! /gif$/, 'png'
- content_type.sub!(/gif$/, 'png')
- self.temp_path = write_to_temp_file(filename)
- grab_dimensions = lambda do |img|
- self.width = img.width if respond_to?(:width)
- self.height = img.height if respond_to?(:height)
- img.save self.temp_path
- self.size = File.size(self.temp_path)
- callback_with_args :after_resize, img
- end
-
- size = size.first if size.is_a?(Array) && size.length == 1
- if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))
- if size.is_a?(Fixnum)
- img.thumbnail(size, &grab_dimensions)
- else
- img.resize(size[0], size[1], &grab_dimensions)
- end
- else
- new_size = [img.width, img.height] / size.to_s
- img.resize(new_size[0], new_size[1], &grab_dimensions)
- end
- end
- end
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/mini_magick_processor.rb b/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/mini_magick_processor.rb
deleted file mode 100644
index 668a7208..00000000
--- a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/mini_magick_processor.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-require 'mini_magick'
-module Technoweenie # :nodoc:
- module AttachmentFu # :nodoc:
- module Processors
- module MiniMagickProcessor
- def self.included(base)
- base.send :extend, ClassMethods
- base.alias_method_chain :process_attachment, :processing
- end
-
- module ClassMethods
- # Yields a block containing an MiniMagick Image for the given binary data.
- def with_image(file, &block)
- begin
- binary_data = file.is_a?(MiniMagick::Image) ? file : MiniMagick::Image.from_file(file) unless !Object.const_defined?(:MiniMagick)
- rescue
- # Log the failure to load the image.
- logger.debug("Exception working with image: #{$!}")
- binary_data = nil
- end
- block.call binary_data if block && binary_data
- ensure
- !binary_data.nil?
- end
- end
-
- protected
- def process_attachment_with_processing
- return unless process_attachment_without_processing
- with_image do |img|
- resize_image_or_thumbnail! img
- self.width = img[:width] if respond_to?(:width)
- self.height = img[:height] if respond_to?(:height)
- callback_with_args :after_resize, img
- end if image?
- end
-
- # Performs the actual resizing operation for a thumbnail
- def resize_image(img, size)
- size = size.first if size.is_a?(Array) && size.length == 1
- img.combine_options do |commands|
- commands.strip unless attachment_options[:keep_profile]
- if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))
- if size.is_a?(Fixnum)
- size = [size, size]
- commands.resize(size.join('x'))
- else
- commands.resize(size.join('x') + '!')
- end
- else
- commands.resize(size.to_s)
- end
- end
- self.temp_path = img
- end
- end
- end
- end
-end
diff --git a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb b/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb
deleted file mode 100644
index aa83b294..00000000
--- a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-require 'RMagick'
-module Technoweenie # :nodoc:
- module AttachmentFu # :nodoc:
- module Processors
- module RmagickProcessor
- def self.included(base)
- base.send :extend, ClassMethods
- base.alias_method_chain :process_attachment, :processing
- end
-
- module ClassMethods
- # Yields a block containing an RMagick Image for the given binary data.
- def with_image(file, &block)
- begin
- binary_data = file.is_a?(Magick::Image) ? file : Magick::Image.read(file).first unless !Object.const_defined?(:Magick)
- rescue
- # Log the failure to load the image. This should match ::Magick::ImageMagickError
- # but that would cause acts_as_attachment to require rmagick.
- logger.debug("Exception working with image: #{$!}")
- binary_data = nil
- end
- block.call binary_data if block && binary_data
- ensure
- !binary_data.nil?
- end
- end
-
- protected
- def process_attachment_with_processing
- return unless process_attachment_without_processing
- with_image do |img|
- resize_image_or_thumbnail! img
- self.width = img.columns if respond_to?(:width)
- self.height = img.rows if respond_to?(:height)
- callback_with_args :after_resize, img
- end if image?
- end
-
- # Performs the actual resizing operation for a thumbnail
- def resize_image(img, size)
- size = size.first if size.is_a?(Array) && size.length == 1 && !size.first.is_a?(Fixnum)
- if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))
- size = [size, size] if size.is_a?(Fixnum)
- img.thumbnail!(*size)
- else
- img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) }
- end
- img.strip! unless attachment_options[:keep_profile]
- self.temp_path = write_to_temp_file(img.to_blob)
- end
- end
- end
- end
-end
diff --git a/vendor/plugins/attachment_fu/test/backends/db_file_test.rb b/vendor/plugins/attachment_fu/test/backends/db_file_test.rb
deleted file mode 100644
index e95bb494..00000000
--- a/vendor/plugins/attachment_fu/test/backends/db_file_test.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
-
-class DbFileTest < Test::Unit::TestCase
- include BaseAttachmentTests
- attachment_model Attachment
-
- def test_should_call_after_attachment_saved(klass = Attachment)
- attachment_model.saves = 0
- assert_created do
- upload_file :filename => '/files/rails.png'
- end
- assert_equal 1, attachment_model.saves
- end
-
- test_against_subclass :test_should_call_after_attachment_saved, Attachment
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/backends/file_system_test.rb b/vendor/plugins/attachment_fu/test/backends/file_system_test.rb
deleted file mode 100644
index d3250c1a..00000000
--- a/vendor/plugins/attachment_fu/test/backends/file_system_test.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
-
-class FileSystemTest < Test::Unit::TestCase
- include BaseAttachmentTests
- attachment_model FileAttachment
-
- def test_filesystem_size_for_file_attachment(klass = FileAttachment)
- attachment_model klass
- assert_created 1 do
- attachment = upload_file :filename => '/files/rails.png'
- assert_equal attachment.size, File.open(attachment.full_filename).stat.size
- end
- end
-
- test_against_subclass :test_filesystem_size_for_file_attachment, FileAttachment
-
- def test_should_not_overwrite_file_attachment(klass = FileAttachment)
- attachment_model klass
- assert_created 2 do
- real = upload_file :filename => '/files/rails.png'
- assert_valid real
- assert !real.new_record?, real.errors.full_messages.join("\n")
- assert !real.size.zero?
-
- fake = upload_file :filename => '/files/fake/rails.png'
- assert_valid fake
- assert !fake.size.zero?
-
- assert_not_equal File.open(real.full_filename).stat.size, File.open(fake.full_filename).stat.size
- end
- end
-
- test_against_subclass :test_should_not_overwrite_file_attachment, FileAttachment
-
- def test_should_store_file_attachment_in_filesystem(klass = FileAttachment)
- attachment_model klass
- attachment = nil
- assert_created do
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- assert File.exists?(attachment.full_filename), "#{attachment.full_filename} does not exist"
- end
- attachment
- end
-
- test_against_subclass :test_should_store_file_attachment_in_filesystem, FileAttachment
-
- def test_should_delete_old_file_when_updating(klass = FileAttachment)
- attachment_model klass
- attachment = upload_file :filename => '/files/rails.png'
- old_filename = attachment.full_filename
- assert_not_created do
- use_temp_file 'files/rails.png' do |file|
- attachment.filename = 'rails2.png'
- attachment.temp_path = File.join(fixture_path, file)
- attachment.save!
- assert File.exists?(attachment.full_filename), "#{attachment.full_filename} does not exist"
- assert !File.exists?(old_filename), "#{old_filename} still exists"
- end
- end
- end
-
- test_against_subclass :test_should_delete_old_file_when_updating, FileAttachment
-
- def test_should_delete_old_file_when_renaming(klass = FileAttachment)
- attachment_model klass
- attachment = upload_file :filename => '/files/rails.png'
- old_filename = attachment.full_filename
- assert_not_created do
- attachment.filename = 'rails2.png'
- attachment.save
- assert File.exists?(attachment.full_filename), "#{attachment.full_filename} does not exist"
- assert !File.exists?(old_filename), "#{old_filename} still exists"
- assert !attachment.reload.size.zero?
- assert_equal 'rails2.png', attachment.filename
- end
- end
-
- test_against_subclass :test_should_delete_old_file_when_renaming, FileAttachment
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/backends/remote/s3_test.rb b/vendor/plugins/attachment_fu/test/backends/remote/s3_test.rb
deleted file mode 100644
index bc277207..00000000
--- a/vendor/plugins/attachment_fu/test/backends/remote/s3_test.rb
+++ /dev/null
@@ -1,107 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
-require 'net/http'
-
-class S3Test < Test::Unit::TestCase
- def self.test_S3?
- true unless ENV["TEST_S3"] == "false"
- end
-
- if test_S3? && File.exist?(File.join(File.dirname(__FILE__), '../../amazon_s3.yml'))
- include BaseAttachmentTests
- attachment_model S3Attachment
-
- def test_should_create_correct_bucket_name(klass = S3Attachment)
- attachment_model klass
- attachment = upload_file :filename => '/files/rails.png'
- assert_equal attachment.s3_config[:bucket_name], attachment.bucket_name
- end
-
- test_against_subclass :test_should_create_correct_bucket_name, S3Attachment
-
- def test_should_create_default_path_prefix(klass = S3Attachment)
- attachment_model klass
- attachment = upload_file :filename => '/files/rails.png'
- assert_equal File.join(attachment_model.table_name, attachment.attachment_path_id), attachment.base_path
- end
-
- test_against_subclass :test_should_create_default_path_prefix, S3Attachment
-
- def test_should_create_custom_path_prefix(klass = S3WithPathPrefixAttachment)
- attachment_model klass
- attachment = upload_file :filename => '/files/rails.png'
- assert_equal File.join('some/custom/path/prefix', attachment.attachment_path_id), attachment.base_path
- end
-
- test_against_subclass :test_should_create_custom_path_prefix, S3WithPathPrefixAttachment
-
- def test_should_create_valid_url(klass = S3Attachment)
- attachment_model klass
- attachment = upload_file :filename => '/files/rails.png'
- assert_equal "#{s3_protocol}#{s3_hostname}#{s3_port_string}/#{attachment.bucket_name}/#{attachment.full_filename}", attachment.s3_url
- end
-
- test_against_subclass :test_should_create_valid_url, S3Attachment
-
- def test_should_create_authenticated_url(klass = S3Attachment)
- attachment_model klass
- attachment = upload_file :filename => '/files/rails.png'
- assert_match /^http.+AWSAccessKeyId.+Expires.+Signature.+/, attachment.authenticated_s3_url(:use_ssl => true)
- end
-
- test_against_subclass :test_should_create_authenticated_url, S3Attachment
-
- def test_should_save_attachment(klass = S3Attachment)
- attachment_model klass
- assert_created do
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- assert attachment.image?
- assert !attachment.size.zero?
- assert_kind_of Net::HTTPOK, http_response_for(attachment.s3_url)
- end
- end
-
- test_against_subclass :test_should_save_attachment, S3Attachment
-
- def test_should_delete_attachment_from_s3_when_attachment_record_destroyed(klass = S3Attachment)
- attachment_model klass
- attachment = upload_file :filename => '/files/rails.png'
-
- urls = [attachment.s3_url] + attachment.thumbnails.collect(&:s3_url)
-
- urls.each {|url| assert_kind_of Net::HTTPOK, http_response_for(url) }
- attachment.destroy
- urls.each do |url|
- begin
- http_response_for(url)
- rescue Net::HTTPForbidden, Net::HTTPNotFound
- nil
- end
- end
- end
-
- test_against_subclass :test_should_delete_attachment_from_s3_when_attachment_record_destroyed, S3Attachment
-
- protected
- def http_response_for(url)
- url = URI.parse(url)
- Net::HTTP.start(url.host, url.port) {|http| http.request_head(url.path) }
- end
-
- def s3_protocol
- Technoweenie::AttachmentFu::Backends::S3Backend.protocol
- end
-
- def s3_hostname
- Technoweenie::AttachmentFu::Backends::S3Backend.hostname
- end
-
- def s3_port_string
- Technoweenie::AttachmentFu::Backends::S3Backend.port_string
- end
- else
- def test_flunk_s3
- puts "s3 config file not loaded, tests not running"
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/base_attachment_tests.rb b/vendor/plugins/attachment_fu/test/base_attachment_tests.rb
deleted file mode 100644
index c9dbbd7a..00000000
--- a/vendor/plugins/attachment_fu/test/base_attachment_tests.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-module BaseAttachmentTests
- def test_should_create_file_from_uploaded_file
- assert_created do
- attachment = upload_file :filename => '/files/foo.txt'
- assert_valid attachment
- assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
- assert attachment.image?
- assert !attachment.size.zero?
- #assert_equal 3, attachment.size
- assert_nil attachment.width
- assert_nil attachment.height
- end
- end
-
- def test_reassign_attribute_data
- assert_created 1 do
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- assert attachment.size > 0, "no data was set"
-
- attachment.temp_data = 'wtf'
- assert attachment.save_attachment?
- attachment.save!
-
- assert_equal 'wtf', attachment_model.find(attachment.id).send(:current_data)
- end
- end
-
- def test_no_reassign_attribute_data_on_nil
- assert_created 1 do
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- assert attachment.size > 0, "no data was set"
-
- attachment.temp_data = nil
- assert !attachment.save_attachment?
- end
- end
-
- def test_should_overwrite_old_contents_when_updating
- attachment = upload_file :filename => '/files/rails.png'
- assert_not_created do # no new db_file records
- use_temp_file 'files/rails.png' do |file|
- attachment.filename = 'rails2.png'
- attachment.temp_path = File.join(fixture_path, file)
- attachment.save!
- end
- end
- end
-
- def test_should_save_without_updating_file
- attachment = upload_file :filename => '/files/foo.txt'
- assert_valid attachment
- assert !attachment.save_attachment?
- assert_nothing_raised { attachment.save! }
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/basic_test.rb b/vendor/plugins/attachment_fu/test/basic_test.rb
deleted file mode 100644
index f8f881cb..00000000
--- a/vendor/plugins/attachment_fu/test/basic_test.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
-
-class BasicTest < Test::Unit::TestCase
- def test_should_set_default_min_size
- assert_equal 1, Attachment.attachment_options[:min_size]
- end
-
- def test_should_set_default_max_size
- assert_equal 1.megabyte, Attachment.attachment_options[:max_size]
- end
-
- def test_should_set_default_size
- assert_equal (1..1.megabyte), Attachment.attachment_options[:size]
- end
-
- def test_should_set_default_thumbnails_option
- assert_equal Hash.new, Attachment.attachment_options[:thumbnails]
- end
-
- def test_should_set_default_thumbnail_class
- assert_equal Attachment, Attachment.attachment_options[:thumbnail_class]
- end
-
- def test_should_normalize_content_types_to_array
- assert_equal %w(pdf), PdfAttachment.attachment_options[:content_type]
- assert_equal %w(pdf doc txt), DocAttachment.attachment_options[:content_type]
- assert_equal ['image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg'], ImageAttachment.attachment_options[:content_type]
- assert_equal ['pdf', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg'], ImageOrPdfAttachment.attachment_options[:content_type]
- end
-
- def test_should_sanitize_content_type
- @attachment = Attachment.new :content_type => ' foo '
- assert_equal 'foo', @attachment.content_type
- end
-
- def test_should_sanitize_filenames
- @attachment = Attachment.new :filename => 'blah/foo.bar'
- assert_equal 'foo.bar', @attachment.filename
-
- @attachment.filename = 'blah\\foo.bar'
- assert_equal 'foo.bar', @attachment.filename
-
- @attachment.filename = 'f o!O-.bar'
- assert_equal 'f_o_O-.bar', @attachment.filename
- end
-
- def test_should_convert_thumbnail_name
- @attachment = FileAttachment.new :filename => 'foo.bar'
- assert_equal 'foo.bar', @attachment.thumbnail_name_for(nil)
- assert_equal 'foo.bar', @attachment.thumbnail_name_for('')
- assert_equal 'foo_blah.bar', @attachment.thumbnail_name_for(:blah)
- assert_equal 'foo_blah.blah.bar', @attachment.thumbnail_name_for('blah.blah')
-
- @attachment.filename = 'foo.bar.baz'
- assert_equal 'foo.bar_blah.baz', @attachment.thumbnail_name_for(:blah)
- end
-
- def test_should_require_valid_thumbnails_option
- klass = Class.new(ActiveRecord::Base)
- assert_raise ArgumentError do
- klass.has_attachment :thumbnails => []
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/database.yml b/vendor/plugins/attachment_fu/test/database.yml
deleted file mode 100644
index 1c6ece7e..00000000
--- a/vendor/plugins/attachment_fu/test/database.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-sqlite:
- :adapter: sqlite
- :dbfile: attachment_fu_plugin.sqlite.db
-sqlite3:
- :adapter: sqlite3
- :dbfile: attachment_fu_plugin.sqlite3.db
-postgresql:
- :adapter: postgresql
- :username: postgres
- :password: postgres
- :database: attachment_fu_plugin_test
- :min_messages: ERROR
-mysql:
- :adapter: mysql
- :host: localhost
- :username: rails
- :password:
- :database: attachment_fu_plugin_test
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/extra_attachment_test.rb b/vendor/plugins/attachment_fu/test/extra_attachment_test.rb
deleted file mode 100644
index 15b18520..00000000
--- a/vendor/plugins/attachment_fu/test/extra_attachment_test.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
-
-class OrphanAttachmentTest < Test::Unit::TestCase
- include BaseAttachmentTests
- attachment_model OrphanAttachment
-
- def test_should_create_image_from_uploaded_file
- assert_created do
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
- assert attachment.image?
- assert !attachment.size.zero?
- end
- end
-
- def test_should_create_file_from_uploaded_file
- assert_created do
- attachment = upload_file :filename => '/files/foo.txt'
- assert_valid attachment
- assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
- assert attachment.image?
- assert !attachment.size.zero?
- end
- end
-
- def test_should_create_image_from_uploaded_file_with_custom_content_type
- assert_created do
- attachment = upload_file :content_type => 'foo/bar', :filename => '/files/rails.png'
- assert_valid attachment
- assert !attachment.image?
- assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
- assert !attachment.size.zero?
- #assert_equal 1784, attachment.size
- end
- end
-
- def test_should_create_thumbnail
- attachment = upload_file :filename => '/files/rails.png'
-
- assert_raise Technoweenie::AttachmentFu::ThumbnailError do
- attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 50, 50)
- end
- end
-
- def test_should_create_thumbnail_with_geometry_string
- attachment = upload_file :filename => '/files/rails.png'
-
- assert_raise Technoweenie::AttachmentFu::ThumbnailError do
- attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 'x50')
- end
- end
-end
-
-class MinimalAttachmentTest < OrphanAttachmentTest
- attachment_model MinimalAttachment
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/fixtures/attachment.rb b/vendor/plugins/attachment_fu/test/fixtures/attachment.rb
deleted file mode 100644
index 7476d7d9..00000000
--- a/vendor/plugins/attachment_fu/test/fixtures/attachment.rb
+++ /dev/null
@@ -1,148 +0,0 @@
-class Attachment < ActiveRecord::Base
- @@saves = 0
- cattr_accessor :saves
- has_attachment :processor => :rmagick
- validates_as_attachment
- after_attachment_saved do |record|
- self.saves += 1
- end
-end
-
-class SmallAttachment < Attachment
- has_attachment :max_size => 1.kilobyte
-end
-
-class BigAttachment < Attachment
- has_attachment :size => 1.megabyte..2.megabytes
-end
-
-class PdfAttachment < Attachment
- has_attachment :content_type => 'pdf'
-end
-
-class DocAttachment < Attachment
- has_attachment :content_type => %w(pdf doc txt)
-end
-
-class ImageAttachment < Attachment
- has_attachment :content_type => :image, :resize_to => [50,50]
-end
-
-class ImageOrPdfAttachment < Attachment
- has_attachment :content_type => ['pdf', :image], :resize_to => 'x50'
-end
-
-class ImageWithThumbsAttachment < Attachment
- has_attachment :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }, :resize_to => [55,55]
- after_resize do |record, img|
- record.aspect_ratio = img.columns.to_f / img.rows.to_f
- end
-end
-
-class FileAttachment < ActiveRecord::Base
- has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files', :processor => :rmagick
- validates_as_attachment
-end
-
-class ImageFileAttachment < FileAttachment
- has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
- :content_type => :image, :resize_to => [50,50]
-end
-
-class ImageWithThumbsFileAttachment < FileAttachment
- has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
- :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }, :resize_to => [55,55]
- after_resize do |record, img|
- record.aspect_ratio = img.columns.to_f / img.rows.to_f
- end
-end
-
-class ImageWithThumbsClassFileAttachment < FileAttachment
- # use file_system_path to test backwards compatibility
- has_attachment :file_system_path => 'vendor/plugins/attachment_fu/test/files',
- :thumbnails => { :thumb => [50, 50] }, :resize_to => [55,55],
- :thumbnail_class => 'ImageThumbnail'
-end
-
-class ImageThumbnail < FileAttachment
- has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files/thumbnails'
-end
-
-# no parent
-class OrphanAttachment < ActiveRecord::Base
- has_attachment :processor => :rmagick
- validates_as_attachment
-end
-
-# no filename, no size, no content_type
-class MinimalAttachment < ActiveRecord::Base
- has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files', :processor => :rmagick
- validates_as_attachment
-
- def filename
- "#{id}.file"
- end
-end
-
-begin
- class ImageScienceAttachment < ActiveRecord::Base
- has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
- :processor => :image_science, :thumbnails => { :thumb => [50, 51], :geometry => '31>' }, :resize_to => 55
- end
-rescue MissingSourceFile
- puts $!.message
- puts "no ImageScience"
-end
-
-begin
- class CoreImageAttachment < ActiveRecord::Base
- has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
- :processor => :core_image, :thumbnails => { :thumb => [50, 51], :geometry => '31>' }, :resize_to => 55
- end
-rescue MissingSourceFile
- puts $!.message
- puts "no CoreImage"
-end
-
-begin
- class MiniMagickAttachment < ActiveRecord::Base
- has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
- :processor => :mini_magick, :thumbnails => { :thumb => [50, 51], :geometry => '31>' }, :resize_to => 55
- end
-rescue MissingSourceFile
- puts $!.message
- puts "no Mini Magick"
-end
-
-begin
- class GD2Attachment < ActiveRecord::Base
- has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
- :processor => :gd2, :thumbnails => { :thumb => [50, 51], :geometry => '31>' }, :resize_to => 55
- end
-rescue MissingSourceFile
- puts $!.message
- puts "no GD2"
-end
-
-
-begin
- class MiniMagickAttachment < ActiveRecord::Base
- has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
- :processor => :mini_magick, :thumbnails => { :thumb => [50, 51], :geometry => '31>' }, :resize_to => 55
- end
-rescue MissingSourceFile
-end
-
-begin
- class S3Attachment < ActiveRecord::Base
- has_attachment :storage => :s3, :processor => :rmagick, :s3_config_path => File.join(File.dirname(__FILE__), '../amazon_s3.yml')
- validates_as_attachment
- end
-
- class S3WithPathPrefixAttachment < S3Attachment
- has_attachment :storage => :s3, :path_prefix => 'some/custom/path/prefix', :processor => :rmagick
- validates_as_attachment
- end
-rescue
- puts "S3 error: #{$!}"
-end
diff --git a/vendor/plugins/attachment_fu/test/fixtures/files/fake/rails.png b/vendor/plugins/attachment_fu/test/fixtures/files/fake/rails.png
deleted file mode 100644
index 0543c64e..00000000
Binary files a/vendor/plugins/attachment_fu/test/fixtures/files/fake/rails.png and /dev/null differ
diff --git a/vendor/plugins/attachment_fu/test/fixtures/files/foo.txt b/vendor/plugins/attachment_fu/test/fixtures/files/foo.txt
deleted file mode 100644
index 19102815..00000000
--- a/vendor/plugins/attachment_fu/test/fixtures/files/foo.txt
+++ /dev/null
@@ -1 +0,0 @@
-foo
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/fixtures/files/rails.png b/vendor/plugins/attachment_fu/test/fixtures/files/rails.png
deleted file mode 100644
index b8441f18..00000000
Binary files a/vendor/plugins/attachment_fu/test/fixtures/files/rails.png and /dev/null differ
diff --git a/vendor/plugins/attachment_fu/test/geometry_test.rb b/vendor/plugins/attachment_fu/test/geometry_test.rb
deleted file mode 100644
index ade4f489..00000000
--- a/vendor/plugins/attachment_fu/test/geometry_test.rb
+++ /dev/null
@@ -1,101 +0,0 @@
-require 'test/unit'
-require File.expand_path(File.join(File.dirname(__FILE__), '../lib/geometry')) unless Object.const_defined?(:Geometry)
-
-class GeometryTest < Test::Unit::TestCase
- def test_should_resize
- assert_geometry 50, 64,
- "50x50" => [39, 50],
- "60x60" => [47, 60],
- "100x100" => [78, 100]
- end
-
- def test_should_resize_no_width
- assert_geometry 50, 64,
- "x50" => [39, 50],
- "x60" => [47, 60],
- "x100" => [78, 100]
- end
-
- def test_should_resize_no_height
- assert_geometry 50, 64,
- "50" => [50, 64],
- "60" => [60, 77],
- "100" => [100, 128]
- end
-
- def test_should_resize_with_percent
- assert_geometry 50, 64,
- "50x50%" => [25, 32],
- "60x60%" => [30, 38],
- "120x112%" => [60, 72]
- end
-
- def test_should_resize_with_percent_and_no_width
- assert_geometry 50, 64,
- "x50%" => [50, 32],
- "x60%" => [50, 38],
- "x112%" => [50, 72]
- end
-
- def test_should_resize_with_percent_and_no_height
- assert_geometry 50, 64,
- "50%" => [25, 32],
- "60%" => [30, 38],
- "120%" => [60, 77]
- end
-
- def test_should_resize_with_less
- assert_geometry 50, 64,
- "50x50<" => [50, 64],
- "60x60<" => [50, 64],
- "100x100<" => [78, 100],
- "100x112<" => [88, 112],
- "40x70<" => [50, 64]
- end
-
- def test_should_resize_with_less_and_no_width
- assert_geometry 50, 64,
- "x50<" => [50, 64],
- "x60<" => [50, 64],
- "x100<" => [78, 100]
- end
-
- def test_should_resize_with_less_and_no_height
- assert_geometry 50, 64,
- "50<" => [50, 64],
- "60<" => [60, 77],
- "100<" => [100, 128]
- end
-
- def test_should_resize_with_greater
- assert_geometry 50, 64,
- "50x50>" => [39, 50],
- "60x60>" => [47, 60],
- "100x100>" => [50, 64],
- "100x112>" => [50, 64],
- "40x70>" => [40, 51]
- end
-
- def test_should_resize_with_greater_and_no_width
- assert_geometry 50, 64,
- "x40>" => [31, 40],
- "x60>" => [47, 60],
- "x100>" => [50, 64]
- end
-
- def test_should_resize_with_greater_and_no_height
- assert_geometry 50, 64,
- "40>" => [40, 51],
- "60>" => [50, 64],
- "100>" => [50, 64]
- end
-
- protected
- def assert_geometry(width, height, values)
- values.each do |geo, result|
- # run twice to verify the Geometry string isn't modified after a run
- geo = Geometry.from_s(geo)
- 2.times { assert_equal result, [width, height] / geo }
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/processors/core_image_test.rb b/vendor/plugins/attachment_fu/test/processors/core_image_test.rb
deleted file mode 100644
index 09a9bbd5..00000000
--- a/vendor/plugins/attachment_fu/test/processors/core_image_test.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
-
-class CoreImageTest < Test::Unit::TestCase
- attachment_model CoreImageAttachment
-
- if Object.const_defined?(:OSX)
- def test_should_resize_image
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- assert attachment.image?
- # test core image thumbnail
- assert_equal 42, attachment.width
- assert_equal 55, attachment.height
-
- thumb = attachment.thumbnails.detect { |t| t.filename =~ /_thumb/ }
- geo = attachment.thumbnails.detect { |t| t.filename =~ /_geometry/ }
-
- # test exact resize dimensions
- assert_equal 50, thumb.width
- assert_equal 51, thumb.height
-
- # test geometry string
- assert_equal 31, geo.width
- assert_equal 41, geo.height
- end
- else
- def test_flunk
- puts "CoreImage not loaded, tests not running"
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/processors/gd2_test.rb b/vendor/plugins/attachment_fu/test/processors/gd2_test.rb
deleted file mode 100644
index 298853b5..00000000
--- a/vendor/plugins/attachment_fu/test/processors/gd2_test.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
-
-class GD2Test < Test::Unit::TestCase
- attachment_model GD2Attachment
-
- if Object.const_defined?(:GD2)
- def test_should_resize_image
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- assert attachment.image?
- # test gd2 thumbnail
- assert_equal 43, attachment.width
- assert_equal 55, attachment.height
-
- thumb = attachment.thumbnails.detect { |t| t.filename =~ /_thumb/ }
- geo = attachment.thumbnails.detect { |t| t.filename =~ /_geometry/ }
-
- # test exact resize dimensions
- assert_equal 50, thumb.width
- assert_equal 51, thumb.height
-
- # test geometry string
- assert_equal 31, geo.width
- assert_equal 40, geo.height
- end
- else
- def test_flunk
- puts "GD2 not loaded, tests not running"
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/processors/image_science_test.rb b/vendor/plugins/attachment_fu/test/processors/image_science_test.rb
deleted file mode 100644
index 636918d8..00000000
--- a/vendor/plugins/attachment_fu/test/processors/image_science_test.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
-
-class ImageScienceTest < Test::Unit::TestCase
- attachment_model ImageScienceAttachment
-
- if Object.const_defined?(:ImageScience)
- def test_should_resize_image
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- assert attachment.image?
- # test image science thumbnail
- assert_equal 42, attachment.width
- assert_equal 55, attachment.height
-
- thumb = attachment.thumbnails.detect { |t| t.filename =~ /_thumb/ }
- geo = attachment.thumbnails.detect { |t| t.filename =~ /_geometry/ }
-
- # test exact resize dimensions
- assert_equal 50, thumb.width
- assert_equal 51, thumb.height
-
- # test geometry string
- assert_equal 31, geo.width
- assert_equal 41, geo.height
- end
- else
- def test_flunk
- puts "ImageScience not loaded, tests not running"
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/processors/mini_magick_test.rb b/vendor/plugins/attachment_fu/test/processors/mini_magick_test.rb
deleted file mode 100644
index 244a4a23..00000000
--- a/vendor/plugins/attachment_fu/test/processors/mini_magick_test.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
-
-class MiniMagickTest < Test::Unit::TestCase
- attachment_model MiniMagickAttachment
-
- if Object.const_defined?(:MiniMagick)
- def test_should_resize_image
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- assert attachment.image?
- # test MiniMagick thumbnail
- assert_equal 43, attachment.width
- assert_equal 55, attachment.height
-
- thumb = attachment.thumbnails.detect { |t| t.filename =~ /_thumb/ }
- geo = attachment.thumbnails.detect { |t| t.filename =~ /_geometry/ }
-
- # test exact resize dimensions
- assert_equal 50, thumb.width
- assert_equal 51, thumb.height
-
- # test geometry string
- assert_equal 31, geo.width
- assert_equal 40, geo.height
- end
- else
- def test_flunk
- puts "MiniMagick not loaded, tests not running"
- end
- end
-end
diff --git a/vendor/plugins/attachment_fu/test/processors/rmagick_test.rb b/vendor/plugins/attachment_fu/test/processors/rmagick_test.rb
deleted file mode 100644
index 98b67dd4..00000000
--- a/vendor/plugins/attachment_fu/test/processors/rmagick_test.rb
+++ /dev/null
@@ -1,255 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
-
-class RmagickTest < Test::Unit::TestCase
- attachment_model Attachment
-
- if Object.const_defined?(:Magick)
- def test_should_create_image_from_uploaded_file
- assert_created do
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
- assert attachment.image?
- assert !attachment.size.zero?
- #assert_equal 1784, attachment.size
- assert_equal 50, attachment.width
- assert_equal 64, attachment.height
- assert_equal '50x64', attachment.image_size
- end
- end
-
- def test_should_create_image_from_uploaded_file_with_custom_content_type
- assert_created do
- attachment = upload_file :content_type => 'foo/bar', :filename => '/files/rails.png'
- assert_valid attachment
- assert !attachment.image?
- assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
- assert !attachment.size.zero?
- #assert_equal 1784, attachment.size
- assert_nil attachment.width
- assert_nil attachment.height
- assert_equal [], attachment.thumbnails
- end
- end
-
- def test_should_create_thumbnail
- attachment = upload_file :filename => '/files/rails.png'
-
- assert_created do
- basename, ext = attachment.filename.split '.'
- thumbnail = attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 50, 50)
- assert_valid thumbnail
- assert !thumbnail.size.zero?
- #assert_in_delta 4673, thumbnail.size, 2
- assert_equal 50, thumbnail.width
- assert_equal 50, thumbnail.height
- assert_equal [thumbnail.id], attachment.thumbnails.collect(&:id)
- assert_equal attachment.id, thumbnail.parent_id if thumbnail.respond_to?(:parent_id)
- assert_equal "#{basename}_thumb.#{ext}", thumbnail.filename
- end
- end
-
- def test_should_create_thumbnail_with_geometry_string
- attachment = upload_file :filename => '/files/rails.png'
-
- assert_created do
- basename, ext = attachment.filename.split '.'
- thumbnail = attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 'x50')
- assert_valid thumbnail
- assert !thumbnail.size.zero?
- #assert_equal 3915, thumbnail.size
- assert_equal 39, thumbnail.width
- assert_equal 50, thumbnail.height
- assert_equal [thumbnail], attachment.thumbnails
- assert_equal attachment.id, thumbnail.parent_id if thumbnail.respond_to?(:parent_id)
- assert_equal "#{basename}_thumb.#{ext}", thumbnail.filename
- end
- end
-
- def test_should_resize_image(klass = ImageAttachment)
- attachment_model klass
- assert_equal [50, 50], attachment_model.attachment_options[:resize_to]
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
- assert attachment.image?
- assert !attachment.size.zero?
- #assert_in_delta 4673, attachment.size, 2
- assert_equal 50, attachment.width
- assert_equal 50, attachment.height
- end
-
- test_against_subclass :test_should_resize_image, ImageAttachment
-
- def test_should_resize_image_with_geometry(klass = ImageOrPdfAttachment)
- attachment_model klass
- assert_equal 'x50', attachment_model.attachment_options[:resize_to]
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
- assert attachment.image?
- assert !attachment.size.zero?
- #assert_equal 3915, attachment.size
- assert_equal 39, attachment.width
- assert_equal 50, attachment.height
- end
-
- test_against_subclass :test_should_resize_image_with_geometry, ImageOrPdfAttachment
-
- def test_should_give_correct_thumbnail_filenames(klass = ImageWithThumbsFileAttachment)
- attachment_model klass
- assert_created 3 do
- attachment = upload_file :filename => '/files/rails.png'
- thumb = attachment.thumbnails.detect { |t| t.filename =~ /_thumb/ }
- geo = attachment.thumbnails.detect { |t| t.filename =~ /_geometry/ }
-
- [attachment, thumb, geo].each { |record| assert_valid record }
-
- assert_match /rails\.png$/, attachment.full_filename
- assert_match /rails_geometry\.png$/, attachment.full_filename(:geometry)
- assert_match /rails_thumb\.png$/, attachment.full_filename(:thumb)
- end
- end
-
- test_against_subclass :test_should_give_correct_thumbnail_filenames, ImageWithThumbsFileAttachment
-
- def test_should_automatically_create_thumbnails(klass = ImageWithThumbsAttachment)
- attachment_model klass
- assert_created 3 do
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- assert !attachment.size.zero?
- #assert_equal 1784, attachment.size
- assert_equal 55, attachment.width
- assert_equal 55, attachment.height
- assert_equal 2, attachment.thumbnails.length
- assert_equal 1.0, attachment.aspect_ratio
-
- thumb = attachment.thumbnails.detect { |t| t.filename =~ /_thumb/ }
- assert !thumb.new_record?, thumb.errors.full_messages.join("\n")
- assert !thumb.size.zero?
- #assert_in_delta 4673, thumb.size, 2
- assert_equal 50, thumb.width
- assert_equal 50, thumb.height
- assert_equal 1.0, thumb.aspect_ratio
-
- geo = attachment.thumbnails.detect { |t| t.filename =~ /_geometry/ }
- assert !geo.new_record?, geo.errors.full_messages.join("\n")
- assert !geo.size.zero?
- #assert_equal 3915, geo.size
- assert_equal 50, geo.width
- assert_equal 50, geo.height
- assert_equal 1.0, geo.aspect_ratio
- end
- end
-
- test_against_subclass :test_should_automatically_create_thumbnails, ImageWithThumbsAttachment
-
- # same as above method, but test it on a file model
- test_against_class :test_should_automatically_create_thumbnails, ImageWithThumbsFileAttachment
- test_against_subclass :test_should_automatically_create_thumbnails_on_class, ImageWithThumbsFileAttachment
-
- def test_should_use_thumbnail_subclass(klass = ImageWithThumbsClassFileAttachment)
- attachment_model klass
- attachment = nil
- assert_difference ImageThumbnail, :count do
- attachment = upload_file :filename => '/files/rails.png'
- assert_valid attachment
- end
- assert_kind_of ImageThumbnail, attachment.thumbnails.first
- if attachment.thumbnails.first.respond_to?(:parent)
- assert_equal attachment.id, attachment.thumbnails.first.parent.id
- assert_kind_of FileAttachment, attachment.thumbnails.first.parent
- end
- assert_equal 'rails_thumb.png', attachment.thumbnails.first.filename
- assert_equal attachment.thumbnails.first.full_filename, attachment.full_filename(attachment.thumbnails.first.thumbnail),
- "#full_filename does not use thumbnail class' path."
- assert_equal attachment.destroy, attachment
- end
-
- test_against_subclass :test_should_use_thumbnail_subclass, ImageWithThumbsClassFileAttachment
-
- def test_should_remove_old_thumbnail_files_when_updating(klass = ImageWithThumbsFileAttachment)
- attachment_model klass
- attachment = nil
- assert_created 3 do
- attachment = upload_file :filename => '/files/rails.png'
- end
-
- old_filenames = [attachment.full_filename] + attachment.thumbnails.collect(&:full_filename)
-
- assert_not_created do
- use_temp_file "files/rails.png" do |file|
- attachment.filename = 'rails2.png'
- attachment.temp_path = File.join(fixture_path, file)
- attachment.save
- new_filenames = [attachment.reload.full_filename] + attachment.thumbnails.collect { |t| t.reload.full_filename }
- new_filenames.each { |f| assert File.exists?(f), "#{f} does not exist" }
- old_filenames.each { |f| assert !File.exists?(f), "#{f} still exists" }
- end
- end
- end
-
- test_against_subclass :test_should_remove_old_thumbnail_files_when_updating, ImageWithThumbsFileAttachment
-
- def test_should_delete_file_when_in_file_system_when_attachment_record_destroyed(klass = ImageWithThumbsFileAttachment)
- attachment_model klass
- attachment = upload_file :filename => '/files/rails.png'
- filenames = [attachment.full_filename] + attachment.thumbnails.collect(&:full_filename)
- filenames.each { |f| assert File.exists?(f), "#{f} never existed to delete on destroy" }
- attachment.destroy
- filenames.each { |f| assert !File.exists?(f), "#{f} still exists" }
- end
-
- test_against_subclass :test_should_delete_file_when_in_file_system_when_attachment_record_destroyed, ImageWithThumbsFileAttachment
-
- def test_should_have_full_filename_method(klass = FileAttachment)
- attachment_model klass
- attachment = upload_file :filename => '/files/rails.png'
- assert_respond_to attachment, :full_filename
- end
-
- test_against_subclass :test_should_have_full_filename_method, FileAttachment
-
- def test_should_overwrite_old_thumbnail_records_when_updating(klass = ImageWithThumbsAttachment)
- attachment_model klass
- attachment = nil
- assert_created 3 do
- attachment = upload_file :filename => '/files/rails.png'
- end
- assert_not_created do # no new db_file records
- use_temp_file "files/rails.png" do |file|
- attachment.filename = 'rails2.png'
- # The above test (#test_should_have_full_filename_method) to pass before be can set the temp_path below --
- # #temp_path calls #full_filename, which is not getting mixed into the attachment. Maybe we don't need to
- # set temp_path at all?
- #
- # attachment.temp_path = File.join(fixture_path, file)
- attachment.save!
- end
- end
- end
-
- test_against_subclass :test_should_overwrite_old_thumbnail_records_when_updating, ImageWithThumbsAttachment
-
- def test_should_overwrite_old_thumbnail_records_when_renaming(klass = ImageWithThumbsAttachment)
- attachment_model klass
- attachment = nil
- assert_created 3 do
- attachment = upload_file :class => klass, :filename => '/files/rails.png'
- end
- assert_not_created do # no new db_file records
- attachment.filename = 'rails2.png'
- attachment.save
- assert !attachment.reload.size.zero?
- assert_equal 'rails2.png', attachment.filename
- end
- end
-
- test_against_subclass :test_should_overwrite_old_thumbnail_records_when_renaming, ImageWithThumbsAttachment
- else
- def test_flunk
- puts "RMagick not installed, no tests running"
- end
- end
-end
diff --git a/vendor/plugins/attachment_fu/test/schema.rb b/vendor/plugins/attachment_fu/test/schema.rb
deleted file mode 100644
index e46ce24d..00000000
--- a/vendor/plugins/attachment_fu/test/schema.rb
+++ /dev/null
@@ -1,108 +0,0 @@
-ActiveRecord::Schema.define(:version => 0) do
- create_table :attachments, :force => true do |t|
- t.column :db_file_id, :integer
- t.column :parent_id, :integer
- t.column :thumbnail, :string
- t.column :filename, :string, :limit => 255
- t.column :content_type, :string, :limit => 255
- t.column :size, :integer
- t.column :width, :integer
- t.column :height, :integer
- t.column :aspect_ratio, :float
- end
-
- create_table :file_attachments, :force => true do |t|
- t.column :parent_id, :integer
- t.column :thumbnail, :string
- t.column :filename, :string, :limit => 255
- t.column :content_type, :string, :limit => 255
- t.column :size, :integer
- t.column :width, :integer
- t.column :height, :integer
- t.column :type, :string
- t.column :aspect_ratio, :float
- end
-
- create_table :gd2_attachments, :force => true do |t|
- t.column :parent_id, :integer
- t.column :thumbnail, :string
- t.column :filename, :string, :limit => 255
- t.column :content_type, :string, :limit => 255
- t.column :size, :integer
- t.column :width, :integer
- t.column :height, :integer
- t.column :type, :string
- end
-
- create_table :image_science_attachments, :force => true do |t|
- t.column :parent_id, :integer
- t.column :thumbnail, :string
- t.column :filename, :string, :limit => 255
- t.column :content_type, :string, :limit => 255
- t.column :size, :integer
- t.column :width, :integer
- t.column :height, :integer
- t.column :type, :string
- end
-
- create_table :core_image_attachments, :force => true do |t|
- t.column :parent_id, :integer
- t.column :thumbnail, :string
- t.column :filename, :string, :limit => 255
- t.column :content_type, :string, :limit => 255
- t.column :size, :integer
- t.column :width, :integer
- t.column :height, :integer
- t.column :type, :string
- end
-
- create_table :mini_magick_attachments, :force => true do |t|
- t.column :parent_id, :integer
- t.column :thumbnail, :string
- t.column :filename, :string, :limit => 255
- t.column :content_type, :string, :limit => 255
- t.column :size, :integer
- t.column :width, :integer
- t.column :height, :integer
- t.column :type, :string
- end
-
- create_table :mini_magick_attachments, :force => true do |t|
- t.column :parent_id, :integer
- t.column :thumbnail, :string
- t.column :filename, :string, :limit => 255
- t.column :content_type, :string, :limit => 255
- t.column :size, :integer
- t.column :width, :integer
- t.column :height, :integer
- t.column :type, :string
- end
-
- create_table :orphan_attachments, :force => true do |t|
- t.column :db_file_id, :integer
- t.column :filename, :string, :limit => 255
- t.column :content_type, :string, :limit => 255
- t.column :size, :integer
- end
-
- create_table :minimal_attachments, :force => true do |t|
- t.column :size, :integer
- t.column :content_type, :string, :limit => 255
- end
-
- create_table :db_files, :force => true do |t|
- t.column :data, :binary
- end
-
- create_table :s3_attachments, :force => true do |t|
- t.column :parent_id, :integer
- t.column :thumbnail, :string
- t.column :filename, :string, :limit => 255
- t.column :content_type, :string, :limit => 255
- t.column :size, :integer
- t.column :width, :integer
- t.column :height, :integer
- t.column :type, :string
- t.column :aspect_ratio, :float
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/test_helper.rb b/vendor/plugins/attachment_fu/test/test_helper.rb
deleted file mode 100644
index ccd53e5d..00000000
--- a/vendor/plugins/attachment_fu/test/test_helper.rb
+++ /dev/null
@@ -1,142 +0,0 @@
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-
-ENV['RAILS_ENV'] = 'test'
-ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..'
-
-require 'test/unit'
-require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb'))
-require 'active_record/fixtures'
-require 'action_controller/test_process'
-
-config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
-ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
-
-db_adapter = ENV['DB']
-
-# no db passed, try one of these fine config-free DBs before bombing.
-db_adapter ||=
- begin
- require 'rubygems'
- require 'sqlite'
- 'sqlite'
- rescue MissingSourceFile
- begin
- require 'sqlite3'
- 'sqlite3'
- rescue MissingSourceFile
- end
- end
-
-if db_adapter.nil?
- raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3."
-end
-
-ActiveRecord::Base.establish_connection(config[db_adapter])
-
-load(File.dirname(__FILE__) + "/schema.rb")
-
-Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures"
-$LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
-
-class Test::Unit::TestCase #:nodoc:
- include ActionController::TestProcess
- def create_fixtures(*table_names)
- if block_given?
- Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
- else
- Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
- end
- end
-
- def setup
- Attachment.saves = 0
- DbFile.transaction { [Attachment, FileAttachment, OrphanAttachment, MinimalAttachment, DbFile].each { |klass| klass.delete_all } }
- attachment_model self.class.attachment_model
- end
-
- def teardown
- FileUtils.rm_rf File.join(File.dirname(__FILE__), 'files')
- end
-
- self.use_transactional_fixtures = true
- self.use_instantiated_fixtures = false
-
- def self.attachment_model(klass = nil)
- @attachment_model = klass if klass
- @attachment_model
- end
-
- def self.test_against_class(test_method, klass, subclass = false)
- define_method("#{test_method}_on_#{:sub if subclass}class") do
- klass = Class.new(klass) if subclass
- attachment_model klass
- send test_method, klass
- end
- end
-
- def self.test_against_subclass(test_method, klass)
- test_against_class test_method, klass, true
- end
-
- protected
- def upload_file(options = {})
- use_temp_file options[:filename] do |file|
- att = attachment_model.create :uploaded_data => fixture_file_upload(file, options[:content_type] || 'image/png')
- att.reload unless att.new_record?
- return att
- end
- end
-
- def use_temp_file(fixture_filename)
- temp_path = File.join('/tmp', File.basename(fixture_filename))
- FileUtils.mkdir_p File.join(fixture_path, 'tmp')
- FileUtils.cp File.join(fixture_path, fixture_filename), File.join(fixture_path, temp_path)
- yield temp_path
- ensure
- FileUtils.rm_rf File.join(fixture_path, 'tmp')
- end
-
- def assert_created(num = 1)
- assert_difference attachment_model.base_class, :count, num do
- if attachment_model.included_modules.include? DbFile
- assert_difference DbFile, :count, num do
- yield
- end
- else
- yield
- end
- end
- end
-
- def assert_not_created
- assert_created(0) { yield }
- end
-
- def should_reject_by_size_with(klass)
- attachment_model klass
- assert_not_created do
- attachment = upload_file :filename => '/files/rails.png'
- assert attachment.new_record?
- assert attachment.errors.on(:size)
- assert_nil attachment.db_file if attachment.respond_to?(:db_file)
- end
- end
-
- def assert_difference(object, method = nil, difference = 1)
- initial_value = object.send(method)
- yield
- assert_equal initial_value + difference, object.send(method)
- end
-
- def assert_no_difference(object, method, &block)
- assert_difference object, method, 0, &block
- end
-
- def attachment_model(klass = nil)
- @attachment_model = klass if klass
- @attachment_model
- end
-end
-
-require File.join(File.dirname(__FILE__), 'fixtures/attachment')
-require File.join(File.dirname(__FILE__), 'base_attachment_tests')
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/test/validation_test.rb b/vendor/plugins/attachment_fu/test/validation_test.rb
deleted file mode 100644
index a14cf990..00000000
--- a/vendor/plugins/attachment_fu/test/validation_test.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
-
-class ValidationTest < Test::Unit::TestCase
- def test_should_invalidate_big_files
- @attachment = SmallAttachment.new
- assert !@attachment.valid?
- assert @attachment.errors.on(:size)
-
- @attachment.size = 2000
- assert !@attachment.valid?
- assert @attachment.errors.on(:size), @attachment.errors.full_messages.to_sentence
-
- @attachment.size = 1000
- assert !@attachment.valid?
- assert_nil @attachment.errors.on(:size)
- end
-
- def test_should_invalidate_small_files
- @attachment = BigAttachment.new
- assert !@attachment.valid?
- assert @attachment.errors.on(:size)
-
- @attachment.size = 2000
- assert !@attachment.valid?
- assert @attachment.errors.on(:size), @attachment.errors.full_messages.to_sentence
-
- @attachment.size = 1.megabyte
- assert !@attachment.valid?
- assert_nil @attachment.errors.on(:size)
- end
-
- def test_should_validate_content_type
- @attachment = PdfAttachment.new
- assert !@attachment.valid?
- assert @attachment.errors.on(:content_type)
-
- @attachment.content_type = 'foo'
- assert !@attachment.valid?
- assert @attachment.errors.on(:content_type)
-
- @attachment.content_type = 'pdf'
- assert !@attachment.valid?
- assert_nil @attachment.errors.on(:content_type)
- end
-
- def test_should_require_filename
- @attachment = Attachment.new
- assert !@attachment.valid?
- assert @attachment.errors.on(:filename)
-
- @attachment.filename = 'foo'
- assert !@attachment.valid?
- assert_nil @attachment.errors.on(:filename)
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/color.rb b/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/color.rb
deleted file mode 100644
index f593b909..00000000
--- a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/color.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-module RedArtisan
- module CoreImage
- module Filters
- module Color
-
- def greyscale(color = nil, intensity = 1.00)
- create_core_image_context(@original.extent.size.width, @original.extent.size.height)
-
- color = OSX::CIColor.colorWithString("1.0 1.0 1.0 1.0") unless color
-
- @original.color_monochrome :inputColor => color, :inputIntensity => intensity do |greyscale|
- @target = greyscale
- end
- end
-
- def sepia(intensity = 1.00)
- create_core_image_context(@original.extent.size.width, @original.extent.size.height)
-
- @original.sepia_tone :inputIntensity => intensity do |sepia|
- @target = sepia
- end
- end
-
- end
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/effects.rb b/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/effects.rb
deleted file mode 100644
index 2e0f2443..00000000
--- a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/effects.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-module RedArtisan
- module CoreImage
- module Filters
- module Effects
-
- def spotlight(position, points_at, brightness, concentration, color)
- create_core_image_context(@original.extent.size.width, @original.extent.size.height)
-
- @original.spot_light :inputLightPosition => vector3(*position), :inputLightPointsAt => vector3(*points_at),
- :inputBrightness => brightness, :inputConcentration => concentration, :inputColor => color do |spot|
- @target = spot
- end
- end
-
- def edges(intensity = 1.00)
- create_core_image_context(@original.extent.size.width, @original.extent.size.height)
-
- @original.edges :inputIntensity => intensity do |edged|
- @target = edged
- end
- end
-
- private
-
- def vector3(x, y, w)
- OSX::CIVector.vectorWithX_Y_Z(x, y, w)
- end
- end
- end
- end
-end
diff --git a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/perspective.rb b/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/perspective.rb
deleted file mode 100644
index 6160dd82..00000000
--- a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/perspective.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-module RedArtisan
- module CoreImage
- module Filters
- module Perspective
-
- def perspective(top_left, top_right, bottom_left, bottom_right)
- create_core_image_context(@original.extent.size.width, @original.extent.size.height)
-
- @original.perspective_transform :inputTopLeft => top_left, :inputTopRight => top_right, :inputBottomLeft => bottom_left, :inputBottomRight => bottom_right do |transformed|
- @target = transformed
- end
- end
-
- def perspective_tiled(top_left, top_right, bottom_left, bottom_right)
- create_core_image_context(@original.extent.size.width, @original.extent.size.height)
-
- @original.perspective_tile :inputTopLeft => top_left, :inputTopRight => top_right, :inputBottomLeft => bottom_left, :inputBottomRight => bottom_right do |tiled|
- @target = tiled
- end
- end
-
- end
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/quality.rb b/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/quality.rb
deleted file mode 100644
index 018690f0..00000000
--- a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/quality.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-module RedArtisan
- module CoreImage
- module Filters
- module Quality
-
- def reduce_noise(level = 0.02, sharpness = 0.4)
- create_core_image_context(@original.extent.size.width, @original.extent.size.height)
-
- @original.noise_reduction :inputNoiseLevel => level, :inputSharpness => sharpness do |noise_reduced|
- @target = noise_reduced
- end
- end
-
- def adjust_exposure(input_ev = 0.5)
- create_core_image_context(@original.extent.size.width, @original.extent.size.height)
-
- @original.exposure_adjust :inputEV => input_ev do |adjusted|
- @target = adjusted
- end
- end
-
- end
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/scale.rb b/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/scale.rb
deleted file mode 100644
index f729b59a..00000000
--- a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/scale.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-module RedArtisan
- module CoreImage
- module Filters
- module Scale
-
- def resize(width, height)
- create_core_image_context(width, height)
-
- scale_x, scale_y = scale(width, height)
-
- @original.affine_clamp :inputTransform => OSX::NSAffineTransform.transform do |clamped|
- clamped.lanczos_scale_transform :inputScale => scale_x > scale_y ? scale_x : scale_y, :inputAspectRatio => scale_x / scale_y do |scaled|
- scaled.crop :inputRectangle => vector(0, 0, width, height) do |cropped|
- @target = cropped
- end
- end
- end
- end
-
- def thumbnail(width, height)
- create_core_image_context(width, height)
-
- transform = OSX::NSAffineTransform.transform
- transform.scaleXBy_yBy *scale(width, height)
-
- @original.affine_transform :inputTransform => transform do |scaled|
- @target = scaled
- end
- end
-
- def fit(size)
- original_size = @original.extent.size
- scale = size.to_f / (original_size.width > original_size.height ? original_size.width : original_size.height)
- resize (original_size.width * scale).to_i, (original_size.height * scale).to_i
- end
-
- private
-
- def scale(width, height)
- original_size = @original.extent.size
- return width.to_f / original_size.width.to_f, height.to_f / original_size.height.to_f
- end
-
- end
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/watermark.rb b/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/watermark.rb
deleted file mode 100644
index 3c3a1ad1..00000000
--- a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/watermark.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-module RedArtisan
- module CoreImage
- module Filters
- module Watermark
-
- def watermark(watermark_image, tile = false, strength = 0.1)
- create_core_image_context(@original.extent.size.width, @original.extent.size.height)
-
- if watermark_image.respond_to? :to_str
- watermark_image = OSX::CIImage.from(watermark_image.to_str)
- end
-
- if tile
- tile_transform = OSX::NSAffineTransform.transform
- tile_transform.scaleXBy_yBy 1.0, 1.0
-
- watermark_image.affine_tile :inputTransform => tile_transform do |tiled|
- tiled.crop :inputRectangle => vector(0, 0, @original.extent.size.width, @original.extent.size.height) do |tiled_watermark|
- watermark_image = tiled_watermark
- end
- end
- end
-
- @original.dissolve_transition :inputTargetImage => watermark_image, :inputTime => strength do |watermarked|
- @target = watermarked
- end
- end
-
- end
- end
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/processor.rb b/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/processor.rb
deleted file mode 100644
index 965e70cc..00000000
--- a/vendor/plugins/attachment_fu/vendor/red_artisan/core_image/processor.rb
+++ /dev/null
@@ -1,123 +0,0 @@
-require 'rubygems'
-require 'osx/cocoa'
-require 'active_support'
-
-require 'red_artisan/core_image/filters/scale'
-require 'red_artisan/core_image/filters/color'
-require 'red_artisan/core_image/filters/watermark'
-require 'red_artisan/core_image/filters/quality'
-require 'red_artisan/core_image/filters/perspective'
-require 'red_artisan/core_image/filters/effects'
-
-# Generic image processor for scaling images based on CoreImage via RubyCocoa.
-#
-# Example usage:
-#
-# p = Processor.new OSX::CIImage.from(path_to_image)
-# p.resize(640, 480)
-# p.render do |result|
-# result.save('resized.jpg', OSX::NSJPEGFileType)
-# end
-#
-# This will resize the image to the given dimensions exactly, if you'd like to ensure that aspect ratio is preserved:
-#
-# p = Processor.new OSX::CIImage.from(path_to_image)
-# p.fit(640)
-# p.render do |result|
-# result.save('resized.jpg', OSX::NSJPEGFileType)
-# end
-#
-# fit(size) will attempt its best to resize the image so that the longest width/height (depending on image orientation) will match
-# the given size. The second axis will be calculated automatically based on the aspect ratio.
-#
-# Scaling is performed by first clamping the image so that its external bounds become infinite, this helps when scaling so that any
-# rounding discrepencies in dimensions don't affect the resultant image. We then perform a Lanczos transform on the image which scales
-# it to the target size. We then crop the image to the traget dimensions.
-#
-# If you are generating smaller images such as thumbnails where high quality rendering isn't as important, an additional method is
-# available:
-#
-# p = Processor.new OSX::CIImage.from(path_to_image)
-# p.thumbnail(100, 100)
-# p.render do |result|
-# result.save('resized.jpg', OSX::NSJPEGFileType)
-# end
-#
-# This will perform a straight affine transform and scale the X and Y boundaries to the requested size. Generally, this will be faster
-# than a lanczos scale transform, but with a scaling quality trade.
-#
-# More than welcome to intregrate any patches, improvements - feel free to mail me with ideas.
-#
-# Thanks to
-# * Satoshi Nakagawa for working out that OCObjWrapper needs inclusion when aliasing method_missing on existing OSX::* classes.
-# * Vasantha Crabb for general help and inspiration with Cocoa
-# * Ben Schwarz for example image data and collaboration during performance testing
-#
-# Copyright (c) Marcus Crafter released under the MIT license
-#
-module RedArtisan
- module CoreImage
- class Processor
-
- def initialize(original)
- if original.respond_to? :to_str
- @original = OSX::CIImage.from(original.to_str)
- else
- @original = original
- end
- end
-
- def render(&block)
- raise "unprocessed image: #{@original}" unless @target
- block.call @target
- end
-
- include Filters::Scale, Filters::Color, Filters::Watermark, Filters::Quality, Filters::Perspective, Filters::Effects
-
- private
-
- def create_core_image_context(width, height)
- output = OSX::NSBitmapImageRep.alloc.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel(nil, width, height, 8, 4, true, false, OSX::NSDeviceRGBColorSpace, 0, 0)
- context = OSX::NSGraphicsContext.graphicsContextWithBitmapImageRep(output)
- OSX::NSGraphicsContext.setCurrentContext(context)
- @ci_context = context.CIContext
- end
-
- def vector(x, y, w, h)
- OSX::CIVector.vectorWithX_Y_Z_W(x, y, w, h)
- end
- end
- end
-end
-
-module OSX
- class CIImage
- include OCObjWrapper
-
- def method_missing_with_filter_processing(sym, *args, &block)
- f = OSX::CIFilter.filterWithName("CI#{sym.to_s.camelize}")
- return method_missing_without_filter_processing(sym, *args, &block) unless f
-
- f.setDefaults if f.respond_to? :setDefaults
- f.setValue_forKey(self, 'inputImage')
- options = args.last.is_a?(Hash) ? args.last : {}
- options.each { |k, v| f.setValue_forKey(v, k.to_s) }
-
- block.call f.valueForKey('outputImage')
- end
-
- alias_method_chain :method_missing, :filter_processing
-
- def save(target, format = OSX::NSJPEGFileType, properties = nil)
- bitmapRep = OSX::NSBitmapImageRep.alloc.initWithCIImage(self)
- blob = bitmapRep.representationUsingType_properties(format, properties)
- blob.writeToFile_atomically(target, false)
- end
-
- def self.from(filepath)
- raise Errno::ENOENT, "No such file or directory - #{filepath}" unless File.exists?(filepath)
- OSX::CIImage.imageWithContentsOfURL(OSX::NSURL.fileURLWithPath(filepath))
- end
- end
-end
-
diff --git a/vendor/plugins/geokit-rails/.gitignore b/vendor/plugins/geokit-rails/.gitignore
deleted file mode 100644
index 04371127..00000000
--- a/vendor/plugins/geokit-rails/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-test/debug.log
-.svn
diff --git a/vendor/plugins/geokit-rails/CHANGELOG.rdoc b/vendor/plugins/geokit-rails/CHANGELOG.rdoc
deleted file mode 100644
index d17c5125..00000000
--- a/vendor/plugins/geokit-rails/CHANGELOG.rdoc
+++ /dev/null
@@ -1,20 +0,0 @@
-== 2008-02-20
-* More powerful assosciations in the Rails Plugin:You can now specify a model as mappable "through" an associated model.
-In other words, that associated model is the actual mappable model with "lat" and "lng" attributes, but this "through" model
-can still utilize all Geokit's "find by distance" finders. Also Rails 2.3 compatibility (thanks github/glennpow)
-
-== 2008-12-18
-* Split Rails plugin from geocoder gem
-* updated for Rails 2.2.2
-
-== 2008-08-20
-* Further fix of distance calculation, this time in SQL. Now uses least() function, which is available in MySQL version 3.22.5+ and postgres versions 8.1+
-
-== 2008-01-16
-* fixed the "zero-distance" bug (calculating between two points that are the same)
-
-== 2007-11-12
-* fixed a small but with queries crossing meridian, and also fixed find(:closest)
-
-== 2008-10-11
-* Fixed Rails2/Edge compatability
\ No newline at end of file
diff --git a/vendor/plugins/geokit-rails/MIT-LICENSE b/vendor/plugins/geokit-rails/MIT-LICENSE
deleted file mode 100644
index 97d81c80..00000000
--- a/vendor/plugins/geokit-rails/MIT-LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (c) 2007 Bill Eisenhauer & Andre Lewis
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/vendor/plugins/geokit-rails/README.markdown b/vendor/plugins/geokit-rails/README.markdown
deleted file mode 100644
index 4c3d020e..00000000
--- a/vendor/plugins/geokit-rails/README.markdown
+++ /dev/null
@@ -1,528 +0,0 @@
-## INSTALLATION
-
-Geokit consists of a Gem ([geokit-gem](http://github.com/andre/geokit-gem/tree/master)) and a Rails plugin ([geokit-rails](http://github.com/andre/geokit-rails/tree/master)).
-
-#### 1. Install the Rails plugin:
-
- cd [YOUR_RAILS_APP_ROOT]
- script/plugin install git://github.com/andre/geokit-rails.git
-
-#### 2. Add this line to your environment.rb
-(inside the Rails::Initializer.run do |config| block)
-
- config.gem "geokit"
-
-This informs Rails of the gem dependency.
-
-#### 3. Tell Rails to install the gem:
-
- rake gems:install
-
-And you're good to go! If you're running an older verion of Rails, just install the gem manually: `sudo gem install rails`
-
-## FEATURE SUMMARY
-
-Geokit provides key functionality for location-oriented Rails applications:
-
-- Distance calculations, for both flat and spherical environments. For example,
- given the location of two points on the earth, you can calculate the miles/KM
- between them.
-- ActiveRecord distance-based finders. For example, you can find all the points
- in your database within a 50-mile radius.
-- IP-based location lookup utilizing hostip.info. Provide an IP address, and get
- city name and latitude/longitude in return
-- A before_filter helper to geocoder the user's location based on IP address,
- and retain the location in a cookie.
-- Geocoding from multiple providers. It currently supports Google, Yahoo,
- Geocoder.us, and Geocoder.ca geocoders, and it provides a uniform response
- structure from all of them. It also provides a fail-over mechanism, in case
- your input fails to geocode in one service. Geocoding is provided buy the Geokit
- gem, which you must have installed
-
-The goal of this plugin is to provide the common functionality for location-oriented
-applications (geocoding, location lookup, distance calculation) in an easy-to-use
-package.
-
-## A NOTE ON TERMINOLOGY
-
-Throughout the code and API, latitude and longitude are referred to as lat
-and lng. We've found over the long term the abbreviation saves lots of typing time.
-
-## DISTANCE CALCULATIONS AND QUERIES
-
-If you want only distance calculation services, you need only mix in the Mappable
-module like so:
-
- class Location
- include Geokit::Mappable
- end
-
-After doing so, you can do things like:
-
- Location.distance_between(from, to)
-
-with optional parameters :units and :formula. Values for :units can be :miles,
-:kms (kilometers), or :nms (nautical miles) with :miles as the default. Values for :formula can be :sphere or :flat with
-:sphere as the default. :sphere gives you Haversine calculations, while :flat
-gives the Pythagoreum Theory. These defaults persist through out the plug-in.
-
-You can also do:
-
- location.distance_to(other)
-
-The real power and utility of the plug-in is in its query support. This is
-achieved through mixing into an ActiveRecord model object:
-
- class Location < ActiveRecord::Base
- acts_as_mappable
- end
-
-The plug-in uses the above-mentioned defaults, but can be modified to use
-different units and a different formulae. This is done through the `:default_units`
-and `:default_formula` keys which accept the same values as mentioned above.
-
-The plug-in creates a calculated column and potentially a calculated condition.
-By default, these are known as "distance" but this can be changed through the
-`:distance_field_name` key.
-
-So, an alternative invocation would look as below:
-
- class Location < ActiveRecord::Base
- acts_as_mappable :default_units => :kms,
- :default_formula => :flat,
- :distance_field_name => :distance
- end
-
-You can also define alternative column names for latitude and longitude using
-the `:lat_column_name` and `:lng_column_name` keys. The defaults are 'lat' and
-'lng' respectively.
-
-Thereafter, a set of finder methods are made available. Below are the
-different combinations:
-
-Origin as a two-element array of latititude/longitude:
-
- find(:all, :origin => [37.792,-122.393])
-
-Origin as a geocodeable string:
-
- find(:all, :origin => '100 Spear st, San Francisco, CA')
-
-Origin as an object which responds to lat and lng methods,
-or latitude and longitude methods, or whatever methods you have
-specified for `lng_column_name` and `lat_column_name`:
-
- find(:all, :origin=>my_store) # my_store.lat and my_store.lng methods exist
-
-Often you will need to find within a certain distance. The prefered syntax is:
-
- find(:all, :origin => @somewhere, :within => 5)
-
-. . . however these syntaxes will also work:
-
- find_within(5, :origin => @somewhere)
- find(:all, :origin => @somewhere, :conditions => "distance < 5")
-
-Note however that the third form should be avoided. With either of the first two,
-Geokit automatically adds a bounding box to speed up the radial query in the database.
-With the third form, it does not.
-
-If you need to combine distance conditions with other conditions, you should do
-so like this:
-
- find(:all, :origin => @somewhere, :within => 5, :conditions=>['state=?',state])
-
-If :origin is not provided in the finder call, the find method
-works as normal. Further, the key is removed
-from the :options hash prior to invoking the superclass behavior.
-
-Other convenience methods work intuitively and are as follows:
-
- find_within(distance, :origin => @somewhere)
- find_beyond(distance, :origin => @somewhere)
- find_closest(:origin => @somewhere)
- find_farthest(:origin => @somewhere)
-
-where the options respect the defaults, but can be overridden if
-desired.
-
-Lastly, if all that is desired is the raw SQL for distance
-calculations, you can use the following:
-
- distance_sql(origin, units=default_units, formula=default_formula)
-
-Thereafter, you are free to use it in find_by_sql as you wish.
-
-There are methods available to enable you to get the count based upon
-the find condition that you have provided. These all work similarly to
-the finders. So for instance:
-
- count(:origin, :conditions => "distance < 5")
- count_within(distance, :origin => @somewhere)
- count_beyond(distance, :origin => @somewhere)
-
-## FINDING WITHIN A BOUNDING BOX
-
-If you are displaying points on a map, you probably need to query for whatever falls within the rectangular bounds of the map:
-
- Store.find :all, :bounds=>[sw_point,ne_point]
-
-The input to :bounds can be array with the two points or a Bounds object. However you provide them, the order should always be the southwest corner, northeast corner of the rectangle. Typically, you will be getting the sw_point and ne_point from a map that is displayed on a web page.
-
-If you need to calculate the bounding box from a point and radius, you can do that:
-
- bounds=Bounds.from_point_and_radius(home,5)
- Store.find :all, :bounds=>bounds
-
-## USING INCLUDES
-
-You can use includes along with your distance finders:
-
- stores=Store.find :all, :origin=>home, :include=>[:reviews,:cities] :within=>5, :order=>'distance'
-
-*However*, ActiveRecord drops the calculated distance column when you use include. So, if you need to
-use the distance column, you'll have to re-calculate it post-query in Ruby:
-
- stores.sort_by_distance_from(home)
-
-In this case, you may want to just use the bounding box
-condition alone in your SQL (there's no use calculating the distance twice):
-
- bounds=Bounds.from_point_and_radius(home,5)
- stores=Store.find :all, :include=>[:reviews,:cities] :bounds=>bounds
- stores.sort_by_distance_from(home)
-
-## USING :through
-
-You can also specify a model as mappable "through" another associated model. In other words, that associated model is the
-actual mappable model with "lat" and "lng" attributes, but this "through" model can still utilize all of the above find methods
-to search for records.
-
- class Location < ActiveRecord::Base
- belongs_to :locatable, :polymorphic => true
- acts_as_mappable
- end
-
- class Company < ActiveRecord::Base
- has_one :location, :as => :locatable # also works for belongs_to associations
- acts_as_mappable :through => :location
- end
-
-Then you can still call:
-
- Company.find_within(distance, :origin => @somewhere)
-
-Remember that the notes above about USING INCLUDES apply to the results from this find, since an include is automatically used.
-
-## IP GEOCODING
-
-You can obtain the location for an IP at any time using the geocoder
-as in the following example:
-
- location = IpGeocoder.geocode('12.215.42.19')
-
-where Location is a GeoLoc instance containing the latitude,
-longitude, city, state, and country code. Also, the success
-value is true.
-
-If the IP cannot be geocoded, a GeoLoc instance is returned with a
-success value of false.
-
-It should be noted that the IP address needs to be visible to the
-Rails application. In other words, you need to ensure that the
-requesting IP address is forwarded by any front-end servers that
-are out in front of the Rails app. Otherwise, the IP will always
-be that of the front-end server.
-
-## IP GEOCODING HELPER
-
-A class method called geocode_ip_address has been mixed into the
-ActionController::Base. This enables before_filter style lookup of
-the IP address. Since it is a filter, it can accept any of the
-available filter options.
-
-Usage is as below:
-
- class LocationAwareController < ActionController::Base
- geocode_ip_address
- end
-
-A first-time lookup will result in the GeoLoc class being stored
-in the session as `:geo_location` as well as in a cookie called
-`:geo_session`. Subsequent lookups will use the session value if it
-exists or the cookie value if it doesn't exist. The last resort is
-to make a call to the web service. Clients are free to manage the
-cookie as they wish.
-
-The intent of this feature is to be able to provide a good guess as
-to a new visitor's location.
-
-## INTEGRATED FIND AND GEOCODING
-
-Geocoding has been integrated with the finders enabling you to pass
-a physical address or an IP address. This would look the following:
-
- Location.find_farthest(:origin => '217.15.10.9')
- Location.find_farthest(:origin => 'Irving, TX')
-
-where the IP or physical address would be geocoded to a location and
-then the resulting latitude and longitude coordinates would be used
-in the find. This is not expected to be common usage, but it can be
-done nevertheless.
-
-## ADDRESS GEOCODING
-
-Geocoding is provided by the Geokit gem, which is required for this plugin.
-See the top of this file for instructions on installing the Geokit gem.
-
-Geokit can geocode addresses using multiple geocodeing web services.
-Currently, Geokit supports Google, Yahoo, and Geocoder.us geocoding
-services.
-
-These geocoder services are made available through the following classes:
-GoogleGeocoder, YahooGeocoder, UsGeocoder, CaGeocoder, and GeonamesGeocoder.
-Further, an additional geocoder class called MultiGeocoder incorporates an ordered failover
-sequence to increase the probability of successful geocoding.
-
-All classes are called using the following signature:
-
- include Geokit::Geocoders
- location = XxxGeocoder.geocode(address)
-
-where you replace Xxx Geocoder with the appropriate class. A GeoLoc
-instance is the result of the call. This class has a "success"
-attribute which will be true if a successful geocoding occurred.
-If successful, the lat and lng properties will be populated.
-
-Geocoders are named with the naming convention NameGeocoder. This
-naming convention enables Geocoder to auto-detect its sub-classes
-in order to create methods called `name_geocoder(address)` so that
-all geocoders are called through the base class. This is done
-purely for convenience; the individual geocoder classes are expected
-to be used independently.
-
-The MultiGeocoder class requires the configuration of a provider
-order which dictates what order to use the various geocoders. Ordering
-is done through `Geokit::Geocoders::provider_order`, found in
-`config/initializers/geokit_config.rb`.
-
-If you don't already have a `geokit_config.rb` file, the plugin creates one
-when it is first installed.
-
-Make sure your failover configuration matches the usage characteristics
-of your application -- for example, if you routinely get bogus input to
-geocode, your code will be much slower if you have to failover among
-multiple geocoders before determining that the input was in fact bogus.
-
-The Geocoder.geocode method returns a GeoLoc object. Basic usage:
-
- loc=Geocoder.geocode('100 Spear St, San Francisco, CA')
- if loc.success
- puts loc.lat
- puts loc.lng
- puts loc.full_address
- end
-
-## REVERSE GEOCODING
-
-Currently, only the Google Geocoder supports reverse geocoding. Pass the lat/lng as a string, array or LatLng instance:
-
- res=Geokit::Geocoders::GoogleGeocoder.reverse_geocode "37.791821,-122.394679"
- => # '100 Spear st, San Francisco, CA')
-
-where the physical address would be geocoded to a location and then the
-resulting latitude and longitude coordinates would be used in the
-find.
-
-Note that if the address fails to geocode, the find method will raise an
-ActiveRecord::GeocodeError you must be prepared to catch. Alternatively,
-You can geocoder the address beforehand, and pass the resulting lat/lng
-into the finder if successful.
-
-## Auto Geocoding
-
-If your geocoding needs are simple, you can tell your model to automatically
-geocode itself on create:
-
- class Store < ActiveRecord::Base
- acts_as_mappable :auto_geocode=>true
- end
-
-It takes two optional params:
-
- class Store < ActiveRecord::Base
- acts_as_mappable :auto_geocode=>{:field=>:address, :error_message=>'Could not geocode address'}
- end
-
-. . . which is equivilent to:
-
- class Store << ActiveRecord::Base
- acts_as_mappable
- before_validation_on_create :geocode_address
-
- private
- def geocode_address
- geo=Geokit::Geocoders::MultiGeocoder.geocode (address)
- errors.add(:address, "Could not Geocode address") if !geo.success
- self.lat, self.lng = geo.lat,geo.lng if geo.success
- end
- end
-
-If you need any more complicated geocoding behavior for your model, you should roll your own
-`before_validate` callback.
-
-
-## Distances, headings, endpoints, and midpoints
-
- distance=home.distance_from(work, :units=>:miles)
- heading=home.heading_to(work) # result is in degrees, 0 is north
- endpoint=home.endpoint(90,2) # two miles due east
- midpoing=home.midpoint_to(work)
-
-## Cool stuff you can do with bounds
-
- bounds=Bounds.new(sw_point,ne_point)
- bounds.contains?(home)
- puts bounds.center
-
-
-HOW TO . . .
-=================================================================================
-
-A few quick examples to get you started ....
-
-## How to install the Geokit Rails plugin
-(See the very top of this file)
-
-## How to find all stores within a 10-mile radius of a given lat/lng
-1. ensure your stores table has lat and lng columns with numeric or float
- datatypes to store your latitude/longitude
-
-3. use `acts_as_mappable` on your store model:
-
- class Store < ActiveRecord::Base
- acts_as_mappable
- ...
- end
-
-3. finders now have extra capabilities:
-
- Store.find(:all, :origin =>[32.951613,-96.958444], :within=>10)
-
-## How to geocode an address
-
-1. configure your geocoder key(s) in `config/initializers/geokit_config.rb`
-
-2. also in `geokit_config.rb`, make sure that `Geokit::Geocoders::provider_order` reflects the
- geocoder(s). If you only want to use one geocoder, there should
- be only one symbol in the array. For example:
-
- Geokit::Geocoders::provider_order=[:google]
-
-3. Test it out in script/console
-
- include Geokit::Geocoders
- res = MultiGeocoder.geocode('100 Spear St, San Francisco, CA')
- puts res.lat
- puts res.lng
- puts res.full_address
- ... etc. The return type is GeoLoc, see the API for
- all the methods you can call on it.
-
-## How to find all stores within 10 miles of a given address
-
-1. as above, ensure your table has the lat/lng columns, and you've
- applied `acts_as_mappable` to the Store model.
-
-2. configure and test out your geocoder, as above
-
-3. pass the address in under the :origin key
-
- Store.find(:all, :origin=>'100 Spear st, San Francisco, CA',
- :within=>10)
-
-4. you can also use a zipcode, or anything else that's geocodable:
-
- Store.find(:all, :origin=>'94117',
- :conditions=>'distance<10')
-
-## How to sort a query by distance from an origin
-
-You now have access to a 'distance' column, and you can use it
-as you would any other column. For example:
- Store.find(:all, :origin=>'94117', :order=>'distance')
-
-## How to elements of an array according to distance from a common point
-
-Usually, you can do your sorting in the database as part of your find call.
-If you need to sort things post-query, you can do so:
-
- stores=Store.find :all
- stores.sort_by_distance_from(home)
- puts stores.first.distance
-
-Obviously, each of the items in the array must have a latitude/longitude so
-they can be sorted by distance.
-
-## Database Compatability
-
-* Geokit works with MySQL (tested with version 5.0.41) or PostgreSQL (tested with version 8.2.6)
-* Geokit does *not* work with SQLite, as it lacks the necessary geometry functions.
-* Geokit is known to *not* work with Postgres versions under 8.1 -- it uses the least() funciton.
-
-
-## HIGH-LEVEL NOTES ON WHAT'S WHERE
-
-`acts_as_mappable.rb`, as you'd expect, contains the ActsAsMappable
-module which gets mixed into your models to provide the
-location-based finder goodness.
-
-`ip_geocode_lookup.rb` contains the before_filter helper method which
-enables auto lookup of the requesting IP address.
-
-### The Geokit gem provides the building blocks of distance-based operations:
-
-The Mappable module, which provides basic
-distance calculation methods, i.e., calculating the distance
-between two points.
-
-The LatLng class is a simple container for latitude and longitude, but
-it's made more powerful by mixing in the above-mentioned Mappable
-module -- therefore, you can calculate easily the distance between two
-LatLng ojbects with `distance = first.distance_to(other)`
-
-GeoLoc represents an address or location which
-has been geocoded. You can get the city, zipcode, street address, etc.
-from a GeoLoc object. GeoLoc extends LatLng, so you also get lat/lng
-AND the Mappable modeule goodness for free.
-
-## GOOGLE GROUP
-
-Follow the Google Group for updates and discussion on Geokit: http://groups.google.com/group/geokit
-
-## IMPORTANT POST-INSTALLATION NOTES:
-
-*1. The configuration file*: Geokit for Rails uses a configuration file in config/initializers.
-You *must* add your own keys for the various geocoding services if you want to use geocoding.
-If you need to refer to the original template again, see the `assets/api_keys_template` file.
-
-*2. The gem dependency*: Geokit for Rails depends on the Geokit gem. Tell Rails about this
-dependency in `config/environment.rb`, within the initializer block:
-config.gem "geokit"
-
-*If you're having trouble with dependencies ....*
-
-Try installing the gem manually (sudo gem install geokit), then adding a `require 'geokit'` to the top of
-`vendor/plugins/geokit-rails/init.rb` and/or `config/geokit_config.rb`.
diff --git a/vendor/plugins/geokit-rails/Rakefile b/vendor/plugins/geokit-rails/Rakefile
deleted file mode 100644
index 82e289ea..00000000
--- a/vendor/plugins/geokit-rails/Rakefile
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the GeoKit plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
-desc 'Generate documentation for the GeoKit plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'GeoKit'
- rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
\ No newline at end of file
diff --git a/vendor/plugins/geokit-rails/about.yml b/vendor/plugins/geokit-rails/about.yml
deleted file mode 100644
index 3698e7ce..00000000
--- a/vendor/plugins/geokit-rails/about.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-author:
- name_1: Bill Eisenhauer
- homepage_1: http://blog.billeisenhauer.com
- name_2: Andre Lewis
- homepage_2: http://www.earthcode.com
-summary: Geo distance calculations, distance calculation query support, geocoding for physical and ip addresses.
-version: 1.1.0
-rails_version: 1.0+
-license: MIT
\ No newline at end of file
diff --git a/vendor/plugins/geokit-rails/assets/api_keys_template b/vendor/plugins/geokit-rails/assets/api_keys_template
deleted file mode 100644
index d660079f..00000000
--- a/vendor/plugins/geokit-rails/assets/api_keys_template
+++ /dev/null
@@ -1,56 +0,0 @@
-if defined? Geokit
-
- # These defaults are used in Geokit::Mappable.distance_to and in acts_as_mappable
- Geokit::default_units = :miles
- Geokit::default_formula = :sphere
-
- # This is the timeout value in seconds to be used for calls to the geocoder web
- # services. For no timeout at all, comment out the setting. The timeout unit
- # is in seconds.
- Geokit::Geocoders::timeout = 3
-
- # These settings are used if web service calls must be routed through a proxy.
- # These setting can be nil if not needed, otherwise, addr and port must be
- # filled in at a minimum. If the proxy requires authentication, the username
- # and password can be provided as well.
- Geokit::Geocoders::proxy_addr = nil
- Geokit::Geocoders::proxy_port = nil
- Geokit::Geocoders::proxy_user = nil
- Geokit::Geocoders::proxy_pass = nil
-
- # This is your yahoo application key for the Yahoo Geocoder.
- # See http://developer.yahoo.com/faq/index.html#appid
- # and http://developer.yahoo.com/maps/rest/V1/geocode.html
- Geokit::Geocoders::yahoo = 'REPLACE_WITH_YOUR_YAHOO_KEY'
-
- # This is your Google Maps geocoder key.
- # See http://www.google.com/apis/maps/signup.html
- # and http://www.google.com/apis/maps/documentation/#Geocoding_Examples
- Geokit::Geocoders::google = 'REPLACE_WITH_YOUR_GOOGLE_KEY'
-
- # This is your username and password for geocoder.us.
- # To use the free service, the value can be set to nil or false. For
- # usage tied to an account, the value should be set to username:password.
- # See http://geocoder.us
- # and http://geocoder.us/user/signup
- Geokit::Geocoders::geocoder_us = false
-
- # This is your authorization key for geocoder.ca.
- # To use the free service, the value can be set to nil or false. For
- # usage tied to an account, set the value to the key obtained from
- # Geocoder.ca.
- # See http://geocoder.ca
- # and http://geocoder.ca/?register=1
- Geokit::Geocoders::geocoder_ca = false
-
- # Uncomment to use a username with the Geonames geocoder
- #Geokit::Geocoders::geonames="REPLACE_WITH_YOUR_GEONAMES_USERNAME"
-
- # This is the order in which the geocoders are called in a failover scenario
- # If you only want to use a single geocoder, put a single symbol in the array.
- # Valid symbols are :google, :yahoo, :us, and :ca.
- # Be aware that there are Terms of Use restrictions on how you can use the
- # various geocoders. Make sure you read up on relevant Terms of Use for each
- # geocoder you are going to use.
- Geokit::Geocoders::provider_order = [:google,:us]
-end
diff --git a/vendor/plugins/geokit-rails/init.rb b/vendor/plugins/geokit-rails/init.rb
deleted file mode 100644
index 11cd95f4..00000000
--- a/vendor/plugins/geokit-rails/init.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# Load modules and classes needed to automatically mix in ActiveRecord and
-# ActionController helpers. All other functionality must be explicitly
-# required.
-#
-# Note that we don't explicitly require the geokit gem. You should specify gem dependencies in your config/environment.rb
-# with this line: config.gem "andre-geokit", :lib=>'geokit', :source => 'http://gems.github.com'
-#
-if defined? Geokit
- require 'geokit-rails/defaults'
- require 'geokit-rails/acts_as_mappable'
- require 'geokit-rails/ip_geocode_lookup'
-
- # Automatically mix in distance finder support into ActiveRecord classes.
- ActiveRecord::Base.send :include, GeoKit::ActsAsMappable
-
- # Automatically mix in ip geocoding helpers into ActionController classes.
- ActionController::Base.send :include, GeoKit::IpGeocodeLookup
-end
\ No newline at end of file
diff --git a/vendor/plugins/geokit-rails/install.rb b/vendor/plugins/geokit-rails/install.rb
deleted file mode 100644
index 1e44d547..00000000
--- a/vendor/plugins/geokit-rails/install.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-# Display to the console the contents of the README file.
-puts IO.read(File.join(File.dirname(__FILE__), 'README.markdown'))
-
-# place the api_keys_template in the application's /config/initializers/geokit_config.rb
-path=File.expand_path(File.join(File.dirname(__FILE__), '../../../config/initializers/geokit_config.rb'))
-template_path=File.join(File.dirname(__FILE__), '/assets/api_keys_template')
-if File.exists?(path)
- puts "It looks like you already have a configuration file at #{path}. We've left it as-is. Recommended: check #{template_path} to see if anything has changed, and update config file accordingly."
-else
- File.open(path, "w") do |f|
- f.puts IO.read(template_path)
- puts "We created a configuration file for you in config/initializers/geokit_config.rb. Add your Google API keys, etc there."
- end
-end
diff --git a/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb b/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb
deleted file mode 100644
index 04cb4210..00000000
--- a/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb
+++ /dev/null
@@ -1,465 +0,0 @@
-module Geokit
- # Contains the class method acts_as_mappable targeted to be mixed into ActiveRecord.
- # When mixed in, augments find services such that they provide distance calculation
- # query services. The find method accepts additional options:
- #
- # * :origin - can be
- # 1. a two-element array of latititude/longitude -- :origin=>[37.792,-122.393]
- # 2. a geocodeable string -- :origin=>'100 Spear st, San Francisco, CA'
- # 3. an object which responds to lat and lng methods, or latitude and longitude methods,
- # or whatever methods you have specified for lng_column_name and lat_column_name
- #
- # Other finder methods are provided for specific queries. These are:
- #
- # * find_within (alias: find_inside)
- # * find_beyond (alias: find_outside)
- # * find_closest (alias: find_nearest)
- # * find_farthest
- #
- # Counter methods are available and work similarly to finders.
- #
- # If raw SQL is desired, the distance_sql method can be used to obtain SQL appropriate
- # to use in a find_by_sql call.
- module ActsAsMappable
- # Mix below class methods into ActiveRecord.
- def self.included(base) # :nodoc:
- base.extend ClassMethods
- end
-
- # Class method to mix into active record.
- module ClassMethods # :nodoc:
- # Class method to bring distance query support into ActiveRecord models. By default
- # uses :miles for distance units and performs calculations based upon the Haversine
- # (sphere) formula. These can be changed by setting Geokit::default_units and
- # Geokit::default_formula. Also, by default, uses lat, lng, and distance for respective
- # column names. All of these can be overridden using the :default_units, :default_formula,
- # :lat_column_name, :lng_column_name, and :distance_column_name hash keys.
- #
- # Can also use to auto-geocode a specific column on create. Syntax;
- #
- # acts_as_mappable :auto_geocode=>true
- #
- # By default, it tries to geocode the "address" field. Or, for more customized behavior:
- #
- # acts_as_mappable :auto_geocode=>{:field=>:address,:error_message=>'bad address'}
- #
- # In both cases, it creates a before_validation_on_create callback to geocode the given column.
- # For anything more customized, we recommend you forgo the auto_geocode option
- # and create your own AR callback to handle geocoding.
- def acts_as_mappable(options = {})
- # Mix in the module, but ensure to do so just once.
- return if !defined?(Geokit::Mappable) || self.included_modules.include?(Geokit::ActsAsMappable::InstanceMethods)
- send :include, Geokit::ActsAsMappable::InstanceMethods
- # include the Mappable module.
- send :include, Geokit::Mappable
-
- # Handle class variables.
- cattr_accessor :through
- if self.through = options[:through]
- if reflection = self.reflect_on_association(self.through)
- (class << self; self; end).instance_eval do
- [ :distance_column_name, :default_units, :default_formula, :lat_column_name, :lng_column_name, :qualified_lat_column_name, :qualified_lng_column_name ].each do |method_name|
- define_method method_name do
- reflection.klass.send(method_name)
- end
- end
- end
- end
- else
- cattr_accessor :distance_column_name, :default_units, :default_formula, :lat_column_name, :lng_column_name, :qualified_lat_column_name, :qualified_lng_column_name
- self.distance_column_name = options[:distance_column_name] || 'distance'
- self.default_units = options[:default_units] || Geokit::default_units
- self.default_formula = options[:default_formula] || Geokit::default_formula
- self.lat_column_name = options[:lat_column_name] || 'lat'
- self.lng_column_name = options[:lng_column_name] || 'lng'
- self.qualified_lat_column_name = "#{table_name}.#{lat_column_name}"
- self.qualified_lng_column_name = "#{table_name}.#{lng_column_name}"
- if options.include?(:auto_geocode) && options[:auto_geocode]
- # if the form auto_geocode=>true is used, let the defaults take over by suppling an empty hash
- options[:auto_geocode] = {} if options[:auto_geocode] == true
- cattr_accessor :auto_geocode_field, :auto_geocode_error_message
- self.auto_geocode_field = options[:auto_geocode][:field] || 'address'
- self.auto_geocode_error_message = options[:auto_geocode][:error_message] || 'could not locate address'
-
- # set the actual callback here
- before_validation_on_create :auto_geocode_address
- end
- end
- end
- end
-
- # this is the callback for auto_geocoding
- def auto_geocode_address
- address=self.send(auto_geocode_field).to_s
- geo=Geokit::Geocoders::MultiGeocoder.geocode(address)
-
- if geo.success
- self.send("#{lat_column_name}=", geo.lat)
- self.send("#{lng_column_name}=", geo.lng)
- else
- errors.add(auto_geocode_field, auto_geocode_error_message)
- end
-
- geo.success
- end
-
- # Instance methods to mix into ActiveRecord.
- module InstanceMethods #:nodoc:
- # Mix class methods into module.
- def self.included(base) # :nodoc:
- base.extend SingletonMethods
- end
-
- # Class singleton methods to mix into ActiveRecord.
- module SingletonMethods # :nodoc:
- # Extends the existing find method in potentially two ways:
- # - If a mappable instance exists in the options, adds a distance column.
- # - If a mappable instance exists in the options and the distance column exists in the
- # conditions, substitutes the distance sql for the distance column -- this saves
- # having to write the gory SQL.
- def find(*args)
- prepare_for_find_or_count(:find, args)
- super(*args)
- end
-
- # Extends the existing count method by:
- # - If a mappable instance exists in the options and the distance column exists in the
- # conditions, substitutes the distance sql for the distance column -- this saves
- # having to write the gory SQL.
- def count(*args)
- prepare_for_find_or_count(:count, args)
- super(*args)
- end
-
- # Finds within a distance radius.
- def find_within(distance, options={})
- options[:within] = distance
- find(:all, options)
- end
- alias find_inside find_within
-
- # Finds beyond a distance radius.
- def find_beyond(distance, options={})
- options[:beyond] = distance
- find(:all, options)
- end
- alias find_outside find_beyond
-
- # Finds according to a range. Accepts inclusive or exclusive ranges.
- def find_by_range(range, options={})
- options[:range] = range
- find(:all, options)
- end
-
- # Finds the closest to the origin.
- def find_closest(options={})
- find(:nearest, options)
- end
- alias find_nearest find_closest
-
- # Finds the farthest from the origin.
- def find_farthest(options={})
- find(:farthest, options)
- end
-
- # Finds within rectangular bounds (sw,ne).
- def find_within_bounds(bounds, options={})
- options[:bounds] = bounds
- find(:all, options)
- end
-
- # counts within a distance radius.
- def count_within(distance, options={})
- options[:within] = distance
- count(options)
- end
- alias count_inside count_within
-
- # Counts beyond a distance radius.
- def count_beyond(distance, options={})
- options[:beyond] = distance
- count(options)
- end
- alias count_outside count_beyond
-
- # Counts according to a range. Accepts inclusive or exclusive ranges.
- def count_by_range(range, options={})
- options[:range] = range
- count(options)
- end
-
- # Finds within rectangular bounds (sw,ne).
- def count_within_bounds(bounds, options={})
- options[:bounds] = bounds
- count(options)
- end
-
- # Returns the distance calculation to be used as a display column or a condition. This
- # is provide for anyone wanting access to the raw SQL.
- def distance_sql(origin, units=default_units, formula=default_formula)
- case formula
- when :sphere
- sql = sphere_distance_sql(origin, units)
- when :flat
- sql = flat_distance_sql(origin, units)
- end
- sql
- end
-
- private
-
- # Prepares either a find or a count action by parsing through the options and
- # conditionally adding to the select clause for finders.
- def prepare_for_find_or_count(action, args)
- options = args.extract_options!
- #options = defined?(args.extract_options!) ? args.extract_options! : extract_options_from_args!(args)
- # Handle :through
- apply_include_for_through(options)
- # Obtain items affecting distance condition.
- origin = extract_origin_from_options(options)
- units = extract_units_from_options(options)
- formula = extract_formula_from_options(options)
- bounds = extract_bounds_from_options(options)
- # if no explicit bounds were given, try formulating them from the point and distance given
- bounds = formulate_bounds_from_distance(options, origin, units) unless bounds
- # Apply select adjustments based upon action.
- add_distance_to_select(options, origin, units, formula) if origin && action == :find
- # Apply the conditions for a bounding rectangle if applicable
- apply_bounds_conditions(options,bounds) if bounds
- # Apply distance scoping and perform substitutions.
- apply_distance_scope(options)
- substitute_distance_in_conditions(options, origin, units, formula) if origin && options.has_key?(:conditions)
- # Order by scoping for find action.
- apply_find_scope(args, options) if action == :find
- # Unfortunatley, we need to do extra work if you use an :include. See the method for more info.
- handle_order_with_include(options,origin,units,formula) if options.include?(:include) && options.include?(:order) && origin
- # Restore options minus the extra options that we used for the
- # Geokit API.
- args.push(options)
- end
-
- def apply_include_for_through(options)
- if self.through
- case options[:include]
- when Array
- options[:include] << self.through
- when Hash, String, Symbol
- options[:include] = [ self.through, options[:include] ]
- else
- options[:include] = self.through
- end
- end
- end
-
- # If we're here, it means that 1) an origin argument, 2) an :include, 3) an :order clause were supplied.
- # Now we have to sub some SQL into the :order clause. The reason is that when you do an :include,
- # ActiveRecord drops the psuedo-column (specificically, distance) which we supplied for :select.
- # So, the 'distance' column isn't available for the :order clause to reference when we use :include.
- def handle_order_with_include(options, origin, units, formula)
- # replace the distance_column_name with the distance sql in order clause
- options[:order].sub!(distance_column_name, distance_sql(origin, units, formula))
- end
-
- # Looks for mapping-specific tokens and makes appropriate translations so that the
- # original finder has its expected arguments. Resets the the scope argument to
- # :first and ensures the limit is set to one.
- def apply_find_scope(args, options)
- case args.first
- when :nearest, :closest
- args[0] = :first
- options[:limit] = 1
- options[:order] = "#{distance_column_name} ASC"
- when :farthest
- args[0] = :first
- options[:limit] = 1
- options[:order] = "#{distance_column_name} DESC"
- end
- end
-
- # If it's a :within query, add a bounding box to improve performance.
- # This only gets called if a :bounds argument is not otherwise supplied.
- def formulate_bounds_from_distance(options, origin, units)
- distance = options[:within] if options.has_key?(:within)
- distance = options[:range].last-(options[:range].exclude_end?? 1 : 0) if options.has_key?(:range)
- if distance
- res=Geokit::Bounds.from_point_and_radius(origin,distance,:units=>units)
- else
- nil
- end
- end
-
- # Replace :within, :beyond and :range distance tokens with the appropriate distance
- # where clauses. Removes these tokens from the options hash.
- def apply_distance_scope(options)
- distance_condition = "#{distance_column_name} <= #{options[:within]}" if options.has_key?(:within)
- distance_condition = "#{distance_column_name} > #{options[:beyond]}" if options.has_key?(:beyond)
- distance_condition = "#{distance_column_name} >= #{options[:range].first} AND #{distance_column_name} <#{'=' unless options[:range].exclude_end?} #{options[:range].last}" if options.has_key?(:range)
- [:within, :beyond, :range].each { |option| options.delete(option) } if distance_condition
-
- options[:conditions]=augment_conditions(options[:conditions],distance_condition) if distance_condition
- end
-
- # This method lets you transparently add a new condition to a query without
- # worrying about whether it currently has conditions, or what kind of conditions they are
- # (string or array).
- #
- # Takes the current conditions (which can be an array or a string, or can be nil/false),
- # and a SQL string. It inserts the sql into the existing conditions, and returns new conditions
- # (which can be a string or an array
- def augment_conditions(current_conditions,sql)
- if current_conditions && current_conditions.is_a?(String)
- res="#{current_conditions} AND #{sql}"
- elsif current_conditions && current_conditions.is_a?(Array)
- current_conditions[0]="#{current_conditions[0]} AND #{sql}"
- res=current_conditions
- else
- res=sql
- end
- res
- end
-
- # Alters the conditions to include rectangular bounds conditions.
- def apply_bounds_conditions(options,bounds)
- sw,ne=bounds.sw,bounds.ne
- lng_sql= bounds.crosses_meridian? ? "(#{qualified_lng_column_name}<#{ne.lng} OR #{qualified_lng_column_name}>#{sw.lng})" : "#{qualified_lng_column_name}>#{sw.lng} AND #{qualified_lng_column_name}<#{ne.lng}"
- bounds_sql="#{qualified_lat_column_name}>#{sw.lat} AND #{qualified_lat_column_name}<#{ne.lat} AND #{lng_sql}"
- options[:conditions]=augment_conditions(options[:conditions],bounds_sql)
- end
-
- # Extracts the origin instance out of the options if it exists and returns
- # it. If there is no origin, looks for latitude and longitude values to
- # create an origin. The side-effect of the method is to remove these
- # option keys from the hash.
- def extract_origin_from_options(options)
- origin = options.delete(:origin)
- res = normalize_point_to_lat_lng(origin) if origin
- res
- end
-
- # Extract the units out of the options if it exists and returns it. If
- # there is no :units key, it uses the default. The side effect of the
- # method is to remove the :units key from the options hash.
- def extract_units_from_options(options)
- units = options[:units] || default_units
- options.delete(:units)
- units
- end
-
- # Extract the formula out of the options if it exists and returns it. If
- # there is no :formula key, it uses the default. The side effect of the
- # method is to remove the :formula key from the options hash.
- def extract_formula_from_options(options)
- formula = options[:formula] || default_formula
- options.delete(:formula)
- formula
- end
-
- def extract_bounds_from_options(options)
- bounds = options.delete(:bounds)
- bounds = Geokit::Bounds.normalize(bounds) if bounds
- end
-
- # Geocode IP address.
- def geocode_ip_address(origin)
- geo_location = Geokit::Geocoders::IpGeocoder.geocode(origin)
- return geo_location if geo_location.success
- raise Geokit::Geocoders::GeocodeError
- end
-
-
- # Given a point in a variety of (an address to geocode,
- # an array of [lat,lng], or an object with appropriate lat/lng methods, an IP addres)
- # this method will normalize it into a Geokit::LatLng instance. The only thing this
- # method adds on top of LatLng#normalize is handling of IP addresses
- def normalize_point_to_lat_lng(point)
- res = geocode_ip_address(point) if point.is_a?(String) && /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})?$/.match(point)
- res = Geokit::LatLng.normalize(point) unless res
- res
- end
-
- # Augments the select with the distance SQL.
- def add_distance_to_select(options, origin, units=default_units, formula=default_formula)
- if origin
- distance_selector = distance_sql(origin, units, formula) + " AS #{distance_column_name}"
- selector = options.has_key?(:select) && options[:select] ? options[:select] : "*"
- options[:select] = "#{selector}, #{distance_selector}"
- end
- end
-
- # Looks for the distance column and replaces it with the distance sql. If an origin was not
- # passed in and the distance column exists, we leave it to be flagged as bad SQL by the database.
- # Conditions are either a string or an array. In the case of an array, the first entry contains
- # the condition.
- def substitute_distance_in_conditions(options, origin, units=default_units, formula=default_formula)
- original_conditions = options[:conditions]
- condition = original_conditions.is_a?(String) ? original_conditions : original_conditions.first
- pattern = Regexp.new("\\b#{distance_column_name}\\b")
- condition = condition.gsub(pattern, distance_sql(origin, units, formula))
- original_conditions = condition if original_conditions.is_a?(String)
- original_conditions[0] = condition if original_conditions.is_a?(Array)
- options[:conditions] = original_conditions
- end
-
- # Returns the distance SQL using the spherical world formula (Haversine). The SQL is tuned
- # to the database in use.
- def sphere_distance_sql(origin, units)
- lat = deg2rad(origin.lat)
- lng = deg2rad(origin.lng)
- multiplier = units_sphere_multiplier(units)
- case connection.adapter_name.downcase
- when "mysql"
- sql=<<-SQL_END
- (ACOS(least(1,COS(#{lat})*COS(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*COS(RADIANS(#{qualified_lng_column_name}))+
- COS(#{lat})*SIN(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*SIN(RADIANS(#{qualified_lng_column_name}))+
- SIN(#{lat})*SIN(RADIANS(#{qualified_lat_column_name}))))*#{multiplier})
- SQL_END
- when "postgresql"
- sql=<<-SQL_END
- (ACOS(least(1,COS(#{lat})*COS(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*COS(RADIANS(#{qualified_lng_column_name}))+
- COS(#{lat})*SIN(#{lng})*COS(RADIANS(#{qualified_lat_column_name}))*SIN(RADIANS(#{qualified_lng_column_name}))+
- SIN(#{lat})*SIN(RADIANS(#{qualified_lat_column_name}))))*#{multiplier})
- SQL_END
- else
- sql = "unhandled #{connection.adapter_name.downcase} adapter"
- end
- end
-
- # Returns the distance SQL using the flat-world formula (Phythagorean Theory). The SQL is tuned
- # to the database in use.
- def flat_distance_sql(origin, units)
- lat_degree_units = units_per_latitude_degree(units)
- lng_degree_units = units_per_longitude_degree(origin.lat, units)
- case connection.adapter_name.downcase
- when "mysql"
- sql=<<-SQL_END
- SQRT(POW(#{lat_degree_units}*(#{origin.lat}-#{qualified_lat_column_name}),2)+
- POW(#{lng_degree_units}*(#{origin.lng}-#{qualified_lng_column_name}),2))
- SQL_END
- when "postgresql"
- sql=<<-SQL_END
- SQRT(POW(#{lat_degree_units}*(#{origin.lat}-#{qualified_lat_column_name}),2)+
- POW(#{lng_degree_units}*(#{origin.lng}-#{qualified_lng_column_name}),2))
- SQL_END
- else
- sql = "unhandled #{connection.adapter_name.downcase} adapter"
- end
- end
- end
- end
- end
-end
-
-# Extend Array with a sort_by_distance method.
-# This method creates a "distance" attribute on each object,
-# calculates the distance from the passed origin,
-# and finally sorts the array by the resulting distance.
-class Array
- def sort_by_distance_from(origin, opts={})
- distance_attribute_name = opts.delete(:distance_attribute_name) || 'distance'
- self.each do |e|
- e.class.send(:attr_accessor, distance_attribute_name) if !e.respond_to? "#{distance_attribute_name}="
- e.send("#{distance_attribute_name}=", e.distance_to(origin,opts))
- end
- self.sort!{|a,b|a.send(distance_attribute_name) <=> b.send(distance_attribute_name)}
- end
-end
diff --git a/vendor/plugins/geokit-rails/lib/geokit-rails/defaults.rb b/vendor/plugins/geokit-rails/lib/geokit-rails/defaults.rb
deleted file mode 100644
index f5d791ea..00000000
--- a/vendor/plugins/geokit-rails/lib/geokit-rails/defaults.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-module Geokit
- # These defaults are used in Geokit::Mappable.distance_to and in acts_as_mappable
- @@default_units = :miles
- @@default_formula = :sphere
-
- [:default_units, :default_formula].each do |sym|
- class_eval <<-EOS, __FILE__, __LINE__
- def self.#{sym}
- if defined?(#{sym.to_s.upcase})
- #{sym.to_s.upcase}
- else
- @@#{sym}
- end
- end
-
- def self.#{sym}=(obj)
- @@#{sym} = obj
- end
- EOS
- end
- Geokit::Geocoders.logger = ActiveRecord::Base.logger
-end
diff --git a/vendor/plugins/geokit-rails/lib/geokit-rails/ip_geocode_lookup.rb b/vendor/plugins/geokit-rails/lib/geokit-rails/ip_geocode_lookup.rb
deleted file mode 100644
index a9dc281d..00000000
--- a/vendor/plugins/geokit-rails/lib/geokit-rails/ip_geocode_lookup.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-require 'yaml'
-
-module Geokit
- # Contains a class method geocode_ip_address which can be used to enable automatic geocoding
- # for request IP addresses. The geocoded information is stored in a cookie and in the
- # session to minimize web service calls. The point of the helper is to enable location-based
- # websites to have a best-guess for new visitors.
- module IpGeocodeLookup
- # Mix below class methods into ActionController.
- def self.included(base) # :nodoc:
- base.extend ClassMethods
- end
-
- # Class method to mix into active record.
- module ClassMethods # :nodoc:
- def geocode_ip_address(filter_options = {})
- before_filter :store_ip_location, filter_options
- end
- end
-
- private
-
- # Places the IP address' geocode location into the session if it
- # can be found. Otherwise, looks for a geo location cookie and
- # uses that value. The last resort is to call the web service to
- # get the value.
- def store_ip_location
- session[:geo_location] ||= retrieve_location_from_cookie_or_service
- cookies[:geo_location] = { :value => session[:geo_location].to_yaml, :expires => 30.days.from_now } if session[:geo_location]
- end
-
- # Uses the stored location value from the cookie if it exists. If
- # no cookie exists, calls out to the web service to get the location.
- def retrieve_location_from_cookie_or_service
- return YAML.load(cookies[:geo_location]) if cookies[:geo_location]
- location = Geocoders::IpGeocoder.geocode(get_ip_address)
- return location.success ? location : nil
- end
-
- # Returns the real ip address, though this could be the localhost ip
- # address. No special handling here anymore.
- def get_ip_address
- request.remote_ip
- end
- end
-end
diff --git a/vendor/plugins/geokit-rails/test/acts_as_mappable_test.rb b/vendor/plugins/geokit-rails/test/acts_as_mappable_test.rb
deleted file mode 100644
index 4fdee0b6..00000000
--- a/vendor/plugins/geokit-rails/test/acts_as_mappable_test.rb
+++ /dev/null
@@ -1,505 +0,0 @@
-require 'rubygems'
-require 'mocha'
-require File.join(File.dirname(__FILE__), 'test_helper')
-
-Geokit::Geocoders::provider_order=[:google,:us]
-
-# Uses defaults
-class Company < ActiveRecord::Base #:nodoc: all
- has_many :locations
-end
-
-# Configures everything.
-class Location < ActiveRecord::Base #:nodoc: all
- belongs_to :company
- acts_as_mappable
-end
-
-# for auto_geocode
-class Store < ActiveRecord::Base
- acts_as_mappable :auto_geocode=>true
-end
-
-# Uses deviations from conventions.
-class CustomLocation < ActiveRecord::Base #:nodoc: all
- belongs_to :company
- acts_as_mappable :distance_column_name => 'dist',
- :default_units => :kms,
- :default_formula => :flat,
- :lat_column_name => 'latitude',
- :lng_column_name => 'longitude'
-
- def to_s
- "lat: #{latitude} lng: #{longitude} dist: #{dist}"
- end
-end
-
-# Uses :through
-class MockOrganization < ActiveRecord::Base #:nodoc: all
- has_one :mock_address, :as => :addressable
- acts_as_mappable :through => :mock_address
-end
-
-# Used by :through
-class MockAddress < ActiveRecord::Base #:nodoc: all
- belongs_to :addressable, :polymorphic => true
- acts_as_mappable
-end
-
-class ActsAsMappableTest < ActiveSupport::TestCase #:nodoc: all
-
- LOCATION_A_IP = "217.10.83.5"
-
- self.fixture_path = File.dirname(__FILE__) + '/fixtures'
- self.use_transactional_fixtures = true
- self.use_instantiated_fixtures = false
- self.pre_loaded_fixtures = true
- fixtures :companies, :locations, :custom_locations, :stores, :mock_organizations, :mock_addresses
-
- def setup
- @location_a = GeoKit::GeoLoc.new
- @location_a.lat = 32.918593
- @location_a.lng = -96.958444
- @location_a.city = "Irving"
- @location_a.state = "TX"
- @location_a.country_code = "US"
- @location_a.success = true
-
- @sw = GeoKit::LatLng.new(32.91663,-96.982841)
- @ne = GeoKit::LatLng.new(32.96302,-96.919495)
- @bounds_center=GeoKit::LatLng.new((@sw.lat+@ne.lat)/2,(@sw.lng+@ne.lng)/2)
-
- @starbucks = companies(:starbucks)
- @loc_a = locations(:a)
- @custom_loc_a = custom_locations(:a)
- @loc_e = locations(:e)
- @custom_loc_e = custom_locations(:e)
-
- @barnes_and_noble = mock_organizations(:barnes_and_noble)
- @address = mock_addresses(:address_barnes_and_noble)
- end
-
- def test_override_default_units_the_hard_way
- Location.default_units = :kms
- locations = Location.find(:all, :origin => @loc_a, :conditions => "distance < 3.97")
- assert_equal 5, locations.size
- locations = Location.count(:origin => @loc_a, :conditions => "distance < 3.97")
- assert_equal 5, locations
- Location.default_units = :miles
- end
-
- def test_include
- locations = Location.find(:all, :origin => @loc_a, :include => :company, :conditions => "company_id = 1")
- assert !locations.empty?
- assert_equal 1, locations[0].company.id
- assert_equal 'Starbucks', locations[0].company.name
- end
-
- def test_distance_between_geocoded
- GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with("Irving, TX").returns(@location_a)
- GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with("San Francisco, CA").returns(@location_a)
- assert_equal 0, Location.distance_between("Irving, TX", "San Francisco, CA")
- end
-
- def test_distance_to_geocoded
- GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with("Irving, TX").returns(@location_a)
- assert_equal 0, @custom_loc_a.distance_to("Irving, TX")
- end
-
- def test_distance_to_geocoded_error
- GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with("Irving, TX").returns(GeoKit::GeoLoc.new)
- assert_raise(GeoKit::Geocoders::GeocodeError) { @custom_loc_a.distance_to("Irving, TX") }
- end
-
- def test_custom_attributes_distance_calculations
- assert_equal 0, @custom_loc_a.distance_to(@loc_a)
- assert_equal 0, CustomLocation.distance_between(@custom_loc_a, @loc_a)
- end
-
- def test_distance_column_in_select
- locations = Location.find(:all, :origin => @loc_a, :order => "distance ASC")
- assert_equal 6, locations.size
- assert_equal 0, @loc_a.distance_to(locations.first)
- assert_in_delta 3.97, @loc_a.distance_to(locations.last, :units => :miles, :formula => :sphere), 0.01
- end
-
- def test_find_with_distance_condition
- locations = Location.find(:all, :origin => @loc_a, :conditions => "distance < 3.97")
- assert_equal 5, locations.size
- locations = Location.count(:origin => @loc_a, :conditions => "distance < 3.97")
- assert_equal 5, locations
- end
-
- def test_find_with_distance_condition_with_units_override
- locations = Location.find(:all, :origin => @loc_a, :units => :kms, :conditions => "distance < 6.387")
- assert_equal 5, locations.size
- locations = Location.count(:origin => @loc_a, :units => :kms, :conditions => "distance < 6.387")
- assert_equal 5, locations
- end
-
- def test_find_with_distance_condition_with_formula_override
- locations = Location.find(:all, :origin => @loc_a, :formula => :flat, :conditions => "distance < 6.387")
- assert_equal 6, locations.size
- locations = Location.count(:origin => @loc_a, :formula => :flat, :conditions => "distance < 6.387")
- assert_equal 6, locations
- end
-
- def test_find_within
- locations = Location.find_within(3.97, :origin => @loc_a)
- assert_equal 5, locations.size
- locations = Location.count_within(3.97, :origin => @loc_a)
- assert_equal 5, locations
- end
-
- def test_find_within_with_token
- locations = Location.find(:all, :within => 3.97, :origin => @loc_a)
- assert_equal 5, locations.size
- locations = Location.count(:within => 3.97, :origin => @loc_a)
- assert_equal 5, locations
- end
-
- def test_find_within_with_coordinates
- locations = Location.find_within(3.97, :origin =>[@loc_a.lat,@loc_a.lng])
- assert_equal 5, locations.size
- locations = Location.count_within(3.97, :origin =>[@loc_a.lat,@loc_a.lng])
- assert_equal 5, locations
- end
-
- def test_find_with_compound_condition
- locations = Location.find(:all, :origin => @loc_a, :conditions => "distance < 5 and city = 'Coppell'")
- assert_equal 2, locations.size
- locations = Location.count(:origin => @loc_a, :conditions => "distance < 5 and city = 'Coppell'")
- assert_equal 2, locations
- end
-
- def test_find_with_secure_compound_condition
- locations = Location.find(:all, :origin => @loc_a, :conditions => ["distance < ? and city = ?", 5, 'Coppell'])
- assert_equal 2, locations.size
- locations = Location.count(:origin => @loc_a, :conditions => ["distance < ? and city = ?", 5, 'Coppell'])
- assert_equal 2, locations
- end
-
- def test_find_beyond
- locations = Location.find_beyond(3.95, :origin => @loc_a)
- assert_equal 1, locations.size
- locations = Location.count_beyond(3.95, :origin => @loc_a)
- assert_equal 1, locations
- end
-
- def test_find_beyond_with_token
- locations = Location.find(:all, :beyond => 3.95, :origin => @loc_a)
- assert_equal 1, locations.size
- locations = Location.count(:beyond => 3.95, :origin => @loc_a)
- assert_equal 1, locations
- end
-
- def test_find_beyond_with_coordinates
- locations = Location.find_beyond(3.95, :origin =>[@loc_a.lat, @loc_a.lng])
- assert_equal 1, locations.size
- locations = Location.count_beyond(3.95, :origin =>[@loc_a.lat, @loc_a.lng])
- assert_equal 1, locations
- end
-
- def test_find_range_with_token
- locations = Location.find(:all, :range => 0..10, :origin => @loc_a)
- assert_equal 6, locations.size
- locations = Location.count(:range => 0..10, :origin => @loc_a)
- assert_equal 6, locations
- end
-
- def test_find_range_with_token_with_conditions
- locations = Location.find(:all, :origin => @loc_a, :range => 0..10, :conditions => ["city = ?", 'Coppell'])
- assert_equal 2, locations.size
- locations = Location.count(:origin => @loc_a, :range => 0..10, :conditions => ["city = ?", 'Coppell'])
- assert_equal 2, locations
- end
-
- def test_find_range_with_token_excluding_end
- locations = Location.find(:all, :range => 0...10, :origin => @loc_a)
- assert_equal 6, locations.size
- locations = Location.count(:range => 0...10, :origin => @loc_a)
- assert_equal 6, locations
- end
-
- def test_find_nearest
- assert_equal @loc_a, Location.find_nearest(:origin => @loc_a)
- end
-
- def test_find_nearest_through_find
- assert_equal @loc_a, Location.find(:nearest, :origin => @loc_a)
- end
-
- def test_find_nearest_with_coordinates
- assert_equal @loc_a, Location.find_nearest(:origin =>[@loc_a.lat, @loc_a.lng])
- end
-
- def test_find_farthest
- assert_equal @loc_e, Location.find_farthest(:origin => @loc_a)
- end
-
- def test_find_farthest_through_find
- assert_equal @loc_e, Location.find(:farthest, :origin => @loc_a)
- end
-
- def test_find_farthest_with_coordinates
- assert_equal @loc_e, Location.find_farthest(:origin =>[@loc_a.lat, @loc_a.lng])
- end
-
- def test_scoped_distance_column_in_select
- locations = @starbucks.locations.find(:all, :origin => @loc_a, :order => "distance ASC")
- assert_equal 5, locations.size
- assert_equal 0, @loc_a.distance_to(locations.first)
- assert_in_delta 3.97, @loc_a.distance_to(locations.last, :units => :miles, :formula => :sphere), 0.01
- end
-
- def test_scoped_find_with_distance_condition
- locations = @starbucks.locations.find(:all, :origin => @loc_a, :conditions => "distance < 3.97")
- assert_equal 4, locations.size
- locations = @starbucks.locations.count(:origin => @loc_a, :conditions => "distance < 3.97")
- assert_equal 4, locations
- end
-
- def test_scoped_find_within
- locations = @starbucks.locations.find_within(3.97, :origin => @loc_a)
- assert_equal 4, locations.size
- locations = @starbucks.locations.count_within(3.97, :origin => @loc_a)
- assert_equal 4, locations
- end
-
- def test_scoped_find_with_compound_condition
- locations = @starbucks.locations.find(:all, :origin => @loc_a, :conditions => "distance < 5 and city = 'Coppell'")
- assert_equal 2, locations.size
- locations = @starbucks.locations.count( :origin => @loc_a, :conditions => "distance < 5 and city = 'Coppell'")
- assert_equal 2, locations
- end
-
- def test_scoped_find_beyond
- locations = @starbucks.locations.find_beyond(3.95, :origin => @loc_a)
- assert_equal 1, locations.size
- locations = @starbucks.locations.count_beyond(3.95, :origin => @loc_a)
- assert_equal 1, locations
- end
-
- def test_scoped_find_nearest
- assert_equal @loc_a, @starbucks.locations.find_nearest(:origin => @loc_a)
- end
-
- def test_scoped_find_farthest
- assert_equal @loc_e, @starbucks.locations.find_farthest(:origin => @loc_a)
- end
-
- def test_ip_geocoded_distance_column_in_select
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
- locations = Location.find(:all, :origin => LOCATION_A_IP, :order => "distance ASC")
- assert_equal 6, locations.size
- assert_equal 0, @loc_a.distance_to(locations.first)
- assert_in_delta 3.97, @loc_a.distance_to(locations.last, :units => :miles, :formula => :sphere), 0.01
- end
-
- def test_ip_geocoded_find_with_distance_condition
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
- locations = Location.find(:all, :origin => LOCATION_A_IP, :conditions => "distance < 3.97")
- assert_equal 5, locations.size
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
- locations = Location.count(:origin => LOCATION_A_IP, :conditions => "distance < 3.97")
- assert_equal 5, locations
- end
-
- def test_ip_geocoded_find_within
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
- locations = Location.find_within(3.97, :origin => LOCATION_A_IP)
- assert_equal 5, locations.size
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
- locations = Location.count_within(3.97, :origin => LOCATION_A_IP)
- assert_equal 5, locations
- end
-
- def test_ip_geocoded_find_with_compound_condition
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
- locations = Location.find(:all, :origin => LOCATION_A_IP, :conditions => "distance < 5 and city = 'Coppell'")
- assert_equal 2, locations.size
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
- locations = Location.count(:origin => LOCATION_A_IP, :conditions => "distance < 5 and city = 'Coppell'")
- assert_equal 2, locations
- end
-
- def test_ip_geocoded_find_with_secure_compound_condition
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
- locations = Location.find(:all, :origin => LOCATION_A_IP, :conditions => ["distance < ? and city = ?", 5, 'Coppell'])
- assert_equal 2, locations.size
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
- locations = Location.count(:origin => LOCATION_A_IP, :conditions => ["distance < ? and city = ?", 5, 'Coppell'])
- assert_equal 2, locations
- end
-
- def test_ip_geocoded_find_beyond
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
- locations = Location.find_beyond(3.95, :origin => LOCATION_A_IP)
- assert_equal 1, locations.size
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
- locations = Location.count_beyond(3.95, :origin => LOCATION_A_IP)
- assert_equal 1, locations
- end
-
- def test_ip_geocoded_find_nearest
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
- assert_equal @loc_a, Location.find_nearest(:origin => LOCATION_A_IP)
- end
-
- def test_ip_geocoded_find_farthest
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with(LOCATION_A_IP).returns(@location_a)
- assert_equal @loc_e, Location.find_farthest(:origin => LOCATION_A_IP)
- end
-
- def test_ip_geocoder_exception
- GeoKit::Geocoders::IpGeocoder.expects(:geocode).with('127.0.0.1').returns(GeoKit::GeoLoc.new)
- assert_raises GeoKit::Geocoders::GeocodeError do
- Location.find_farthest(:origin => '127.0.0.1')
- end
- end
-
- def test_address_geocode
- GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with('Irving, TX').returns(@location_a)
- locations = Location.find(:all, :origin => 'Irving, TX', :conditions => ["distance < ? and city = ?", 5, 'Coppell'])
- assert_equal 2, locations.size
- end
-
- def test_find_with_custom_distance_condition
- locations = CustomLocation.find(:all, :origin => @loc_a, :conditions => "dist < 3.97")
- assert_equal 5, locations.size
- locations = CustomLocation.count(:origin => @loc_a, :conditions => "dist < 3.97")
- assert_equal 5, locations
- end
-
- def test_find_with_custom_distance_condition_using_custom_origin
- locations = CustomLocation.find(:all, :origin => @custom_loc_a, :conditions => "dist < 3.97")
- assert_equal 5, locations.size
- locations = CustomLocation.count(:origin => @custom_loc_a, :conditions => "dist < 3.97")
- assert_equal 5, locations
- end
-
- def test_find_within_with_custom
- locations = CustomLocation.find_within(3.97, :origin => @loc_a)
- assert_equal 5, locations.size
- locations = CustomLocation.count_within(3.97, :origin => @loc_a)
- assert_equal 5, locations
- end
-
- def test_find_within_with_coordinates_with_custom
- locations = CustomLocation.find_within(3.97, :origin =>[@loc_a.lat, @loc_a.lng])
- assert_equal 5, locations.size
- locations = CustomLocation.count_within(3.97, :origin =>[@loc_a.lat, @loc_a.lng])
- assert_equal 5, locations
- end
-
- def test_find_with_compound_condition_with_custom
- locations = CustomLocation.find(:all, :origin => @loc_a, :conditions => "dist < 5 and city = 'Coppell'")
- assert_equal 1, locations.size
- locations = CustomLocation.count(:origin => @loc_a, :conditions => "dist < 5 and city = 'Coppell'")
- assert_equal 1, locations
- end
-
- def test_find_with_secure_compound_condition_with_custom
- locations = CustomLocation.find(:all, :origin => @loc_a, :conditions => ["dist < ? and city = ?", 5, 'Coppell'])
- assert_equal 1, locations.size
- locations = CustomLocation.count(:origin => @loc_a, :conditions => ["dist < ? and city = ?", 5, 'Coppell'])
- assert_equal 1, locations
- end
-
- def test_find_beyond_with_custom
- locations = CustomLocation.find_beyond(3.95, :origin => @loc_a)
- assert_equal 1, locations.size
- locations = CustomLocation.count_beyond(3.95, :origin => @loc_a)
- assert_equal 1, locations
- end
-
- def test_find_beyond_with_coordinates_with_custom
- locations = CustomLocation.find_beyond(3.95, :origin =>[@loc_a.lat, @loc_a.lng])
- assert_equal 1, locations.size
- locations = CustomLocation.count_beyond(3.95, :origin =>[@loc_a.lat, @loc_a.lng])
- assert_equal 1, locations
- end
-
- def test_find_nearest_with_custom
- assert_equal @custom_loc_a, CustomLocation.find_nearest(:origin => @loc_a)
- end
-
- def test_find_nearest_with_coordinates_with_custom
- assert_equal @custom_loc_a, CustomLocation.find_nearest(:origin =>[@loc_a.lat, @loc_a.lng])
- end
-
- def test_find_farthest_with_custom
- assert_equal @custom_loc_e, CustomLocation.find_farthest(:origin => @loc_a)
- end
-
- def test_find_farthest_with_coordinates_with_custom
- assert_equal @custom_loc_e, CustomLocation.find_farthest(:origin =>[@loc_a.lat, @loc_a.lng])
- end
-
- def test_find_with_array_origin
- locations = Location.find(:all, :origin =>[@loc_a.lat,@loc_a.lng], :conditions => "distance < 3.97")
- assert_equal 5, locations.size
- locations = Location.count(:origin =>[@loc_a.lat,@loc_a.lng], :conditions => "distance < 3.97")
- assert_equal 5, locations
- end
-
-
- # Bounding box tests
-
- def test_find_within_bounds
- locations = Location.find_within_bounds([@sw,@ne])
- assert_equal 2, locations.size
- locations = Location.count_within_bounds([@sw,@ne])
- assert_equal 2, locations
- end
-
- def test_find_within_bounds_ordered_by_distance
- locations = Location.find_within_bounds([@sw,@ne], :origin=>@bounds_center, :order=>'distance asc')
- assert_equal locations[0], locations(:d)
- assert_equal locations[1], locations(:a)
- end
-
- def test_find_within_bounds_with_token
- locations = Location.find(:all, :bounds=>[@sw,@ne])
- assert_equal 2, locations.size
- locations = Location.count(:bounds=>[@sw,@ne])
- assert_equal 2, locations
- end
-
- def test_find_within_bounds_with_string_conditions
- locations = Location.find(:all, :bounds=>[@sw,@ne], :conditions=>"id !=#{locations(:a).id}")
- assert_equal 1, locations.size
- end
-
- def test_find_within_bounds_with_array_conditions
- locations = Location.find(:all, :bounds=>[@sw,@ne], :conditions=>["id != ?", locations(:a).id])
- assert_equal 1, locations.size
- end
-
- def test_auto_geocode
- GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with("Irving, TX").returns(@location_a)
- store=Store.new(:address=>'Irving, TX')
- store.save
- assert_equal store.lat,@location_a.lat
- assert_equal store.lng,@location_a.lng
- assert_equal 0, store.errors.size
- end
-
- def test_auto_geocode_failure
- GeoKit::Geocoders::MultiGeocoder.expects(:geocode).with("BOGUS").returns(GeoKit::GeoLoc.new)
- store=Store.new(:address=>'BOGUS')
- store.save
- assert store.new_record?
- assert_equal 1, store.errors.size
- end
-
-
- # Test :through
-
- def test_find_with_through
- organizations = MockOrganization.find(:all, :origin => @location_a, :order => 'distance ASC')
- assert_equal 2, organizations.size
- organizations = MockOrganization.count(:origin => @location_a, :conditions => "distance < 3.97")
- assert_equal 1, organizations
- end
-end
diff --git a/vendor/plugins/geokit-rails/test/database.yml b/vendor/plugins/geokit-rails/test/database.yml
deleted file mode 100644
index c2c65914..00000000
--- a/vendor/plugins/geokit-rails/test/database.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-mysql:
- adapter: mysql
- host: localhost
- username: root
- password:
- database: geokit_plugin_test
-postgresql:
- adapter: postgresql
- host: localhost
- username: root
- password:
- database: geokit_plugin_test
\ No newline at end of file
diff --git a/vendor/plugins/geokit-rails/test/fixtures/companies.yml b/vendor/plugins/geokit-rails/test/fixtures/companies.yml
deleted file mode 100644
index d48a2e82..00000000
--- a/vendor/plugins/geokit-rails/test/fixtures/companies.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-starbucks:
- id: 1
- name: Starbucks
-
-barnes_and_noble:
- id: 2
- name: Barnes & Noble
\ No newline at end of file
diff --git a/vendor/plugins/geokit-rails/test/fixtures/custom_locations.yml b/vendor/plugins/geokit-rails/test/fixtures/custom_locations.yml
deleted file mode 100644
index f5a1e928..00000000
--- a/vendor/plugins/geokit-rails/test/fixtures/custom_locations.yml
+++ /dev/null
@@ -1,54 +0,0 @@
-a:
- id: 1
- company_id: 1
- street: 7979 N MacArthur Blvd
- city: Irving
- state: TX
- postal_code: 75063
- latitude: 32.918593
- longitude: -96.958444
-b:
- id: 2
- company_id: 1
- street: 7750 N Macarthur Blvd # 160
- city: Irving
- state: TX
- postal_code: 75063
- latitude: 32.914144
- longitude: -96.958444
-c:
- id: 3
- company_id: 1
- street: 5904 N Macarthur Blvd # 160
- city: Irving
- state: TX
- postal_code: 75039
- latitude: 32.895155
- longitude: -96.958444
-d:
- id: 4
- company_id: 1
- street: 817 S Macarthur Blvd # 145
- city: Coppell
- state: TX
- postal_code: 75019
- latitude: 32.951613
- longitude: -96.958444
-e:
- id: 5
- company_id: 1
- street: 106 N Denton Tap Rd # 350
- city: Coppell
- state: TX
- postal_code: 75019
- latitude: 32.969527
- longitude: -96.990159
-f:
- id: 6
- company_id: 2
- street: 5904 N Macarthur Blvd # 160
- city: Irving
- state: TX
- postal_code: 75039
- latitude: 32.895155
- longitude: -96.958444
\ No newline at end of file
diff --git a/vendor/plugins/geokit-rails/test/fixtures/locations.yml b/vendor/plugins/geokit-rails/test/fixtures/locations.yml
deleted file mode 100644
index 779fabae..00000000
--- a/vendor/plugins/geokit-rails/test/fixtures/locations.yml
+++ /dev/null
@@ -1,54 +0,0 @@
-a:
- id: 1
- company_id: 1
- street: 7979 N MacArthur Blvd
- city: Irving
- state: TX
- postal_code: 75063
- lat: 32.918593
- lng: -96.958444
-b:
- id: 2
- company_id: 1
- street: 7750 N Macarthur Blvd # 160
- city: Irving
- state: TX
- postal_code: 75063
- lat: 32.914144
- lng: -96.958444
-c:
- id: 3
- company_id: 1
- street: 5904 N Macarthur Blvd # 160
- city: Irving
- state: TX
- postal_code: 75039
- lat: 32.895155
- lng: -96.958444
-d:
- id: 4
- company_id: 1
- street: 817 S Macarthur Blvd # 145
- city: Coppell
- state: TX
- postal_code: 75019
- lat: 32.951613
- lng: -96.958444
-e:
- id: 5
- company_id: 1
- street: 106 N Denton Tap Rd # 350
- city: Coppell
- state: TX
- postal_code: 75019
- lat: 32.969527
- lng: -96.990159
-f:
- id: 6
- company_id: 2
- street: 5904 N Macarthur Blvd # 160
- city: Irving
- state: TX
- postal_code: 75039
- lat: 32.895155
- lng: -96.958444
\ No newline at end of file
diff --git a/vendor/plugins/geokit-rails/test/fixtures/mock_addresses.yml b/vendor/plugins/geokit-rails/test/fixtures/mock_addresses.yml
deleted file mode 100644
index a19b4ba8..00000000
--- a/vendor/plugins/geokit-rails/test/fixtures/mock_addresses.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-address_starbucks:
- addressable: starbucks (MockOrganization)
- street: 106 N Denton Tap Rd # 350
- city: Coppell
- state: TX
- postal_code: 75019
- lat: 32.969527
- lng: -96.990159
-
-address_barnes_and_noble:
- addressable: barnes_and_noble (MockOrganization)
- street: 5904 N Macarthur Blvd # 160
- city: Irving
- state: TX
- postal_code: 75039
- lat: 32.895155
- lng: -96.958444
\ No newline at end of file
diff --git a/vendor/plugins/geokit-rails/test/fixtures/mock_organizations.yml b/vendor/plugins/geokit-rails/test/fixtures/mock_organizations.yml
deleted file mode 100644
index 967d762d..00000000
--- a/vendor/plugins/geokit-rails/test/fixtures/mock_organizations.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-starbucks:
- name: Starbucks
-
-barnes_and_noble:
- name: Barnes & Noble
\ No newline at end of file
diff --git a/vendor/plugins/geokit-rails/test/ip_geocode_lookup_test.rb b/vendor/plugins/geokit-rails/test/ip_geocode_lookup_test.rb
deleted file mode 100644
index 17657056..00000000
--- a/vendor/plugins/geokit-rails/test/ip_geocode_lookup_test.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-require ENV['environment'] || File.join(File.dirname(__FILE__), '../../../../config/environment')
-require 'action_controller/test_process'
-require 'test/unit'
-require 'rubygems'
-require 'mocha'
-
-
-class LocationAwareController < ActionController::Base #:nodoc: all
- geocode_ip_address
-
- def index
- render :nothing => true
- end
-end
-
-class ActionController::TestRequest #:nodoc: all
- attr_accessor :remote_ip
-end
-
-# Re-raise errors caught by the controller.
-class LocationAwareController #:nodoc: all
- def rescue_action(e) raise e end;
-end
-
-class IpGeocodeLookupTest < Test::Unit::TestCase #:nodoc: all
-
- def setup
- @success = GeoKit::GeoLoc.new
- @success.provider = "hostip"
- @success.lat = 41.7696
- @success.lng = -88.4588
- @success.city = "Sugar Grove"
- @success.state = "IL"
- @success.country_code = "US"
- @success.success = true
-
- @failure = GeoKit::GeoLoc.new
- @failure.provider = "hostip"
- @failure.city = "(Private Address)"
- @failure.success = false
-
- @controller = LocationAwareController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- end
-
- def test_no_location_in_cookie_or_session
- Geokit::Geocoders::IpGeocoder.expects(:geocode).with("good ip").returns(@success)
- @request.remote_ip = "good ip"
- get :index
- verify
- end
-
- def test_location_in_cookie
- @request.remote_ip = "good ip"
- @request.cookies['geo_location'] = CGI::Cookie.new('geo_location', @success.to_yaml)
- get :index
- verify
- end
-
- def test_location_in_session
- @request.remote_ip = "good ip"
- @request.session[:geo_location] = @success
- @request.cookies['geo_location'] = CGI::Cookie.new('geo_location', @success.to_yaml)
- get :index
- verify
- end
-
- def test_ip_not_located
- Geokit::Geocoders::IpGeocoder.expects(:geocode).with("bad ip").returns(@failure)
- @request.remote_ip = "bad ip"
- get :index
- assert_nil @request.session[:geo_location]
- end
-
- private
-
- def verify
- assert_response :success
- assert_equal @success, @request.session[:geo_location]
- assert_not_nil cookies['geo_location']
- assert_equal @success, YAML.load(cookies['geo_location'].join)
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/geokit-rails/test/schema.rb b/vendor/plugins/geokit-rails/test/schema.rb
deleted file mode 100644
index d86fc253..00000000
--- a/vendor/plugins/geokit-rails/test/schema.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-ActiveRecord::Schema.define(:version => 0) do
- create_table :companies, :force => true do |t|
- t.column :name, :string
- end
-
- create_table :locations, :force => true do |t|
- t.column :company_id, :integer, :default => 0, :null => false
- t.column :street, :string, :limit => 60
- t.column :city, :string, :limit => 60
- t.column :state, :string, :limit => 2
- t.column :postal_code, :string, :limit => 16
- t.column :lat, :decimal, :precision => 15, :scale => 10
- t.column :lng, :decimal, :precision => 15, :scale => 10
- end
-
- create_table :custom_locations, :force => true do |t|
- t.column :company_id, :integer, :default => 0, :null => false
- t.column :street, :string, :limit => 60
- t.column :city, :string, :limit => 60
- t.column :state, :string, :limit => 2
- t.column :postal_code, :string, :limit => 16
- t.column :latitude, :decimal, :precision => 15, :scale => 10
- t.column :longitude, :decimal, :precision => 15, :scale => 10
- end
-
- create_table :stores, :force=> true do |t|
- t.column :address, :string
- t.column :lat, :decimal, :precision => 15, :scale => 10
- t.column :lng, :decimal, :precision => 15, :scale => 10
- end
-
- create_table :mock_organizations, :force => true do |t|
- t.column :name, :string
- end
-
- create_table :mock_addresses, :force => true do |t|
- t.column :addressable_id, :integer, :null => false
- t.column :addressable_type, :string, :null => false
- t.column :street, :string, :limit => 60
- t.column :city, :string, :limit => 60
- t.column :state, :string, :limit => 2
- t.column :postal_code, :string, :limit => 16
- t.column :lat, :decimal, :precision => 15, :scale => 10
- t.column :lng, :decimal, :precision => 15, :scale => 10
- end
-end
\ No newline at end of file
diff --git a/vendor/plugins/geokit-rails/test/test_helper.rb b/vendor/plugins/geokit-rails/test/test_helper.rb
deleted file mode 100644
index 9ddb017f..00000000
--- a/vendor/plugins/geokit-rails/test/test_helper.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-ENV["RAILS_ENV"] = "test"
-require "test/unit"
-require "rubygems"
-#require File.dirname(__FILE__) + '/../init'
-require 'geokit'
-
-plugin_test_dir = File.dirname(__FILE__)
-
-# Load the Rails environment
-require ENV['environment'] || File.join(plugin_test_dir, '../../../../config/environment')
-require 'test_help'
-#require 'active_record/fixtures'
-databases = YAML::load(IO.read(plugin_test_dir + '/database.yml'))
-ActiveRecord::Base.logger = Logger.new(plugin_test_dir + "/debug.log")
-
-# A specific database can be used by setting the DB environment variable
-ActiveRecord::Base.establish_connection(databases[ENV['DB'] || 'mysql'])
-
-# Load the test schema into the database
-load(File.join(plugin_test_dir, 'schema.rb'))
-
-# Load fixtures from the plugin
-#Test::Unit::TestCase.fixture_path = File.join(plugin_test_dir, 'fixtures/')
diff --git a/vendor/plugins/open_id_authentication/CHANGELOG b/vendor/plugins/open_id_authentication/CHANGELOG
deleted file mode 100644
index 0c8971ef..00000000
--- a/vendor/plugins/open_id_authentication/CHANGELOG
+++ /dev/null
@@ -1,37 +0,0 @@
-* Dump heavy lifting off to rack-openid gem. OpenIdAuthentication is just a simple controller concern.
-
-* Fake HTTP method from OpenID server since they only support a GET. Eliminates the need to set an extra route to match the server's reply. [Josh Peek]
-
-* OpenID 2.0 recommends that forms should use the field name "openid_identifier" rather than "openid_url" [Josh Peek]
-
-* Return open_id_response.display_identifier to the application instead of .endpoints.claimed_id. [nbibler]
-
-* Add Timeout protection [Rick]
-
-* An invalid identity url passed through authenticate_with_open_id will no longer raise an InvalidOpenId exception. Instead it will return Result[:missing] to the completion block.
-
-* Allow a return_to option to be used instead of the requested url [Josh Peek]
-
-* Updated plugin to use Ruby OpenID 2.x.x [Josh Peek]
-
-* Tied plugin to ruby-openid 1.1.4 gem until we can make it compatible with 2.x [DHH]
-
-* Use URI instead of regexps to normalize the URL and gain free, better matching #8136 [dkubb]
-
-* Allow -'s in #normalize_url [Rick]
-
-* remove instance of mattr_accessor, it was breaking tests since they don't load ActiveSupport. Fix Timeout test [Rick]
-
-* Throw a InvalidOpenId exception instead of just a RuntimeError when the URL can't be normalized [DHH]
-
-* Just use the path for the return URL, so extra query parameters don't interfere [DHH]
-
-* Added a new default database-backed store after experiencing trouble with the filestore on NFS. The file store is still available as an option [DHH]
-
-* Added normalize_url and applied it to all operations going through the plugin [DHH]
-
-* Removed open_id? as the idea of using the same input box for both OpenID and username has died -- use using_open_id? instead (which checks for the presence of params[:openid_url] by default) [DHH]
-
-* Added OpenIdAuthentication::Result to make it easier to deal with default situations where you don't care to do something particular for each error state [DHH]
-
-* Stop relying on root_url being defined, we can just grab the current url instead [DHH]
\ No newline at end of file
diff --git a/vendor/plugins/open_id_authentication/README b/vendor/plugins/open_id_authentication/README
deleted file mode 100644
index fe2b37e2..00000000
--- a/vendor/plugins/open_id_authentication/README
+++ /dev/null
@@ -1,223 +0,0 @@
-OpenIdAuthentication
-====================
-
-Provides a thin wrapper around the excellent ruby-openid gem from JanRan. Be sure to install that first:
-
- gem install ruby-openid
-
-To understand what OpenID is about and how it works, it helps to read the documentation for lib/openid/consumer.rb
-from that gem.
-
-The specification used is http://openid.net/specs/openid-authentication-2_0.html.
-
-
-Prerequisites
-=============
-
-OpenID authentication uses the session, so be sure that you haven't turned that off.
-
-Alternatively, you can use the file-based store, which just relies on on tmp/openids being present in RAILS_ROOT. But be aware that this store only works if you have a single application server. And it's not safe to use across NFS. It's recommended that you use the database store if at all possible. To use the file-based store, you'll also have to add this line to your config/environment.rb:
-
- OpenIdAuthentication.store = :file
-
-This particular plugin also relies on the fact that the authentication action allows for both POST and GET operations.
-If you're using RESTful authentication, you'll need to explicitly allow for this in your routes.rb.
-
-The plugin also expects to find a root_url method that points to the home page of your site. You can accomplish this by using a root route in config/routes.rb:
-
- map.root :controller => 'articles'
-
-This plugin relies on Rails Edge revision 6317 or newer.
-
-
-Example
-=======
-
-This example is just to meant to demonstrate how you could use OpenID authentication. You might well want to add
-salted hash logins instead of plain text passwords and other requirements on top of this. Treat it as a starting point,
-not a destination.
-
-Note that the User model referenced in the simple example below has an 'identity_url' attribute. You will want to add the same or similar field to whatever
-model you are using for authentication.
-
-Also of note is the following code block used in the example below:
-
- authenticate_with_open_id do |result, identity_url|
- ...
- end
-
-In the above code block, 'identity_url' will need to match user.identity_url exactly. 'identity_url' will be a string in the form of 'http://example.com' -
-If you are storing just 'example.com' with your user, the lookup will fail.
-
-There is a handy method in this plugin called 'normalize_url' that will help with validating OpenID URLs.
-
- OpenIdAuthentication.normalize_url(user.identity_url)
-
-The above will return a standardized version of the OpenID URL - the above called with 'example.com' will return 'http://example.com/'
-It will also raise an InvalidOpenId exception if the URL is determined to not be valid.
-Use the above code in your User model and validate OpenID URLs before saving them.
-
-config/routes.rb
-
- map.root :controller => 'articles'
- map.resource :session
-
-
-app/views/sessions/new.erb
-
- <% form_tag(session_url) do %>
-
- <% end %>
-
-app/controllers/sessions_controller.rb
- class SessionsController < ApplicationController
- def create
- if using_open_id?
- open_id_authentication
- else
- password_authentication(params[:name], params[:password])
- end
- end
-
-
- protected
- def password_authentication(name, password)
- if @current_user = @account.users.authenticate(params[:name], params[:password])
- successful_login
- else
- failed_login "Sorry, that username/password doesn't work"
- end
- end
-
- def open_id_authentication
- authenticate_with_open_id do |result, identity_url|
- if result.successful?
- if @current_user = @account.users.find_by_identity_url(identity_url)
- successful_login
- else
- failed_login "Sorry, no user by that identity URL exists (#{identity_url})"
- end
- else
- failed_login result.message
- end
- end
- end
-
-
- private
- def successful_login
- session[:user_id] = @current_user.id
- redirect_to(root_url)
- end
-
- def failed_login(message)
- flash[:error] = message
- redirect_to(new_session_url)
- end
- end
-
-
-
-If you're fine with the result messages above and don't need individual logic on a per-failure basis,
-you can collapse the case into a mere boolean:
-
- def open_id_authentication
- authenticate_with_open_id do |result, identity_url|
- if result.successful? && @current_user = @account.users.find_by_identity_url(identity_url)
- successful_login
- else
- failed_login(result.message || "Sorry, no user by that identity URL exists (#{identity_url})")
- end
- end
- end
-
-
-Simple Registration OpenID Extension
-====================================
-
-Some OpenID Providers support this lightweight profile exchange protocol. See more: http://www.openidenabled.com/openid/simple-registration-extension
-
-You can support it in your app by changing #open_id_authentication
-
- def open_id_authentication(identity_url)
- # Pass optional :required and :optional keys to specify what sreg fields you want.
- # Be sure to yield registration, a third argument in the #authenticate_with_open_id block.
- authenticate_with_open_id(identity_url,
- :required => [ :nickname, :email ],
- :optional => :fullname) do |result, identity_url, registration|
- case result.status
- when :missing
- failed_login "Sorry, the OpenID server couldn't be found"
- when :invalid
- failed_login "Sorry, but this does not appear to be a valid OpenID"
- when :canceled
- failed_login "OpenID verification was canceled"
- when :failed
- failed_login "Sorry, the OpenID verification failed"
- when :successful
- if @current_user = @account.users.find_by_identity_url(identity_url)
- assign_registration_attributes!(registration)
-
- if current_user.save
- successful_login
- else
- failed_login "Your OpenID profile registration failed: " +
- @current_user.errors.full_messages.to_sentence
- end
- else
- failed_login "Sorry, no user by that identity URL exists"
- end
- end
- end
- end
-
- # registration is a hash containing the valid sreg keys given above
- # use this to map them to fields of your user model
- def assign_registration_attributes!(registration)
- model_to_registration_mapping.each do |model_attribute, registration_attribute|
- unless registration[registration_attribute].blank?
- @current_user.send("#{model_attribute}=", registration[registration_attribute])
- end
- end
- end
-
- def model_to_registration_mapping
- { :login => 'nickname', :email => 'email', :display_name => 'fullname' }
- end
-
-Attribute Exchange OpenID Extension
-===================================
-
-Some OpenID providers also support the OpenID AX (attribute exchange) protocol for exchanging identity information between endpoints. See more: http://openid.net/specs/openid-attribute-exchange-1_0.html
-
-Accessing AX data is very similar to the Simple Registration process, described above -- just add the URI identifier for the AX field to your :optional or :required parameters. For example:
-
- authenticate_with_open_id(identity_url,
- :required => [ :email, 'http://schema.openid.net/birthDate' ]) do |result, identity_url, registration|
-
-This would provide the sreg data for :email, and the AX data for 'http://schema.openid.net/birthDate'
-
-
-
-Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license
\ No newline at end of file
diff --git a/vendor/plugins/open_id_authentication/init.rb b/vendor/plugins/open_id_authentication/init.rb
deleted file mode 100644
index 84ec11fc..00000000
--- a/vendor/plugins/open_id_authentication/init.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-if Rails.version < '3'
- config.gem 'rack-openid', :lib => 'rack/openid', :version => '>=0.2.1'
-end
-
-require 'open_id_authentication'
-
-config.middleware.use OpenIdAuthentication
-
-config.after_initialize do
- OpenID::Util.logger = Rails.logger
- ActionController::Base.send :include, OpenIdAuthentication
-end
diff --git a/vendor/plugins/open_id_authentication/lib/open_id_authentication.rb b/vendor/plugins/open_id_authentication/lib/open_id_authentication.rb
deleted file mode 100644
index b3550497..00000000
--- a/vendor/plugins/open_id_authentication/lib/open_id_authentication.rb
+++ /dev/null
@@ -1,128 +0,0 @@
-require 'uri'
-require 'openid'
-require 'rack/openid'
-
-module OpenIdAuthentication
- def self.new(app)
- store = OpenIdAuthentication.store
- if store.nil?
- Rails.logger.warn "OpenIdAuthentication.store is nil. Using in-memory store."
- end
-
- ::Rack::OpenID.new(app, OpenIdAuthentication.store)
- end
-
- def self.store
- @@store
- end
-
- def self.store=(*store_option)
- store, *parameters = *([ store_option ].flatten)
-
- @@store = case store
- when :memory
- require 'openid/store/memory'
- OpenID::Store::Memory.new
- when :file
- require 'openid/store/filesystem'
- OpenID::Store::Filesystem.new(Rails.root.join('tmp/openids'))
- when :memcache
- require 'memcache'
- require 'openid/store/memcache'
- OpenID::Store::Memcache.new(MemCache.new(parameters))
- else
- store
- end
- end
-
- self.store = nil
-
- class Result
- ERROR_MESSAGES = {
- :missing => "Sorry, the OpenID server couldn't be found",
- :invalid => "Sorry, but this does not appear to be a valid OpenID",
- :canceled => "OpenID verification was canceled",
- :failed => "OpenID verification failed",
- :setup_needed => "OpenID verification needs setup"
- }
-
- def self.[](code)
- new(code)
- end
-
- def initialize(code)
- @code = code
- end
-
- def status
- @code
- end
-
- ERROR_MESSAGES.keys.each { |state| define_method("#{state}?") { @code == state } }
-
- def successful?
- @code == :successful
- end
-
- def unsuccessful?
- ERROR_MESSAGES.keys.include?(@code)
- end
-
- def message
- ERROR_MESSAGES[@code]
- end
- end
-
- protected
- # The parameter name of "openid_identifier" is used rather than
- # the Rails convention "open_id_identifier" because that's what
- # the specification dictates in order to get browser auto-complete
- # working across sites
- def using_open_id?(identifier = nil) #:doc:
- identifier ||= open_id_identifier
- !identifier.blank? || request.env[Rack::OpenID::RESPONSE]
- end
-
- def authenticate_with_open_id(identifier = nil, options = {}, &block) #:doc:
- identifier ||= open_id_identifier
-
- if request.env[Rack::OpenID::RESPONSE]
- complete_open_id_authentication(&block)
- else
- begin_open_id_authentication(identifier, options, &block)
- end
- end
-
- private
- def open_id_identifier
- params[:openid_identifier] || params[:openid_url]
- end
-
- def begin_open_id_authentication(identifier, options = {})
- options[:identifier] = identifier
- value = Rack::OpenID.build_header(options)
- response.headers[Rack::OpenID::AUTHENTICATE_HEADER] = value
- head :unauthorized
- end
-
- def complete_open_id_authentication
- response = request.env[Rack::OpenID::RESPONSE]
- identifier = response.display_identifier
-
- case response.status
- when OpenID::Consumer::SUCCESS
- yield Result[:successful], identifier,
- OpenID::SReg::Response.from_success_response(response)
- when :missing
- yield Result[:missing], identifier, nil
- when :invalid
- yield Result[:invalid], identifier, nil
- when OpenID::Consumer::CANCEL
- yield Result[:canceled], identifier, nil
- when OpenID::Consumer::FAILURE
- yield Result[:failed], identifier, nil
- when OpenID::Consumer::SETUP_NEEDED
- yield Result[:setup_needed], response.setup_url, nil
- end
- end
-end
diff --git a/vendor/plugins/restful-authentication/CHANGELOG b/vendor/plugins/restful-authentication/CHANGELOG
deleted file mode 100644
index acef669d..00000000
--- a/vendor/plugins/restful-authentication/CHANGELOG
+++ /dev/null
@@ -1,68 +0,0 @@
-# Internal Changes to code
-
-As always, this is just a copy-and-pasted version of the CHANGELOG file in the source code tree.
-
-## Changes for the May, 2008 version of restful-authentication
-
-### Changes to user model
-
-* recently_activated? belongs only if stateful
-* Gave migration a 40-char limit on remember_token & an index on users by login
-* **Much** stricter login and email validation
-* put length constraints in migration too
-* password in 6, 40
-* salt and remember_token now much less predictability
-
-### Changes to session_controller
-
-* use uniform logout function
-* use uniform remember_cookie functions
-* avoid calling logged_in? which will auto-log-you-in (safe in the face of
- logout! call, but idiot-proof)
-* Moved reset_session into only the "now logged in" branch
-** wherever it goes, it has to be in front of the current_user= call
-** See more in README-Tradeoffs.txt
-* made a place to take action on failed login attempt
-* recycle login and remember_me setting on failed login
-* nil'ed out the password field in 'new' view
-
-### Changes to users_controller
-
-* use uniform logout function
-* use uniform remember_cookie functions
-* Moved reset_session into only the "now logged in" branch
-** wherever it goes, it has to be in front of the current_user= call
-** See more in README-Tradeoffs.txt
-* made the implicit login only happen for non-activationed sites
-* On a failed signup, kick you back to the signin screen (but strip out the password & confirmation)
-* more descriptive error messages in activate()
-
-### users_helper
-
-* link_to_user, link_to_current_user, link_to_signin_with_IP
-* if_authorized(action, resource, &block) view function (with appropriate
- warning)
-
-### authenticated_system
-
-* Made authorized? take optional arguments action=nil, resource=nil, *args
- This makes its signature better match traditional approaches to access control
- eg Reference Monitor in "Security Patterns":http://www.securitypatterns.org/patterns.html)
-* authorized? should be a helper too
-* added uniform logout! methods
-* format.any (as found in access_denied) doesn't work until
- http://dev.rubyonrails.org/changeset/8987 lands.
-* cookies are now refreshed each time we cross the logged out/in barrier, as
- "best":http://palisade.plynt.com/issues/2004Jul/safe-auth-practices/
- "practice":http://www.owasp.org/index.php/Session_Management#Regeneration_of_Session_Tokens
-
-### Other
-
-* Used escapes <%= %> in email templates (among other reasons, so courtenay's
- "'dumbass' test":http://tinyurl.com/684g9t doesn't complain)
-* Added site key to generator, users.yml.
-* Made site key generation idempotent in the most crude and hackish way
-* 100% coverage apart from the stateful code. (needed some access_control
- checks, and the http_auth stuff)
-* Stories!
-
diff --git a/vendor/plugins/restful-authentication/LICENSE b/vendor/plugins/restful-authentication/LICENSE
deleted file mode 100644
index b2d8f021..00000000
--- a/vendor/plugins/restful-authentication/LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (c) 2009 rick olson
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/plugins/restful-authentication/README.markdown b/vendor/plugins/restful-authentication/README.markdown
deleted file mode 100644
index bc2c5170..00000000
--- a/vendor/plugins/restful-authentication/README.markdown
+++ /dev/null
@@ -1,227 +0,0 @@
-# "Restful Authentication Generator":http://github.com/technoweenie/restful-authentication
-
-This widely-used plugin provides a foundation for securely managing user
-authentication:
-* Login / logout
-* Secure password handling
-* Account activation by validating email
-* Account approval / disabling by admin
-* Rudimentary hooks for authorization and access control.
-
-Several features were updated in May, 2008.
-* "Stable newer version":http://github.com/technoweenie/restful-authentication/tree/master
-* "'Classic' (backward-compatible) version":http://github.com/technoweenie/restful-authentication/tree/classic
-* "Experimental version":http://github.com/technoweenie/restful-authentication/tree/modular (Much more modular, needs testing & review)
-
-> IMPORTANT: if you upgrade your site, existing user account
-> passwords will stop working unless you use --old-passwords
-
-***************************************************************************
-
-## Issue Tracker
-
-Please submit any bugs or annoyances on the lighthouse tracker at
-* "http://rails_security.lighthouseapp.com/projects/15332-restful_authentication/overview":http://rails_security.lighthouseapp.com/projects/15332-restful_authentication/overview
-
-For anything simple enough, please github message both maintainers: Rick Olson
-("technoweenie":http://github.com/technoweenie) and Flip Kromer
-("mrflip":http://github.com/mrflip).
-
-***************************************************************************
-
-## Documentation
-
-This page has notes on
-* "Installation":#INSTALL
-* "New Features":#AWESOME
-* "After installing":#POST-INSTALL
-
-See the "wiki":http://github.com/technoweenie/restful-authentication/wikis/home
-(or the notes/ directory) if you want to learn more about:
-
-* "Extensions, Addons and Alternatives":addons such as HAML templates
-* "Security Design Patterns":security-patterns with "snazzy diagram":http://github.com/technoweenie/restful-authentication/tree/master/notes/SecurityFramework.png
-* Authentication -- Lets a visitor identify herself (and lay claim to her corresponding Roles and measure of Trust)
-* "Trust Metrics":Trustification -- Confidence we can rely on the outcomes of this visitor's actions.
-* Authorization and Policy -- Based on trust and identity, what actions may this visitor perform?
-* Access Control -- How the Authorization policy is actually enforced in your code (A: hopefully without turning it into a spaghetti of if thens)
-* Rails Plugins for Authentication, Trust, Authorization and Access Control
-* Tradeoffs -- for the paranoid or the curious, a rundown of tradeoffs made in the code
-* CHANGELOG -- Summary of changes to internals
-* TODO -- Ideas for how you can help
-
-These best version of the release notes are in the notes/ directory in the
-"source code":http://github.com/technoweenie/restful-authentication/tree/master
--- look there for the latest version. The wiki versions are taken (manually)
-from there.
-
-***************************************************************************
-
-
-
-## Exciting new features
-
-### Stories
-
-There are now "Cucumber":http://wiki.github.com/aslakhellesoy/cucumber/home features that allow expressive, enjoyable tests for the
-authentication code. The flexible code for resource testing in stories was
-extended from "Ben Mabey's.":http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/
-
-### Modularize to match security design patterns:
-
-* Authentication (currently: password, browser cookie token, HTTP basic)
-* Trust metric (email validation)
-* Authorization (stateful roles)
-* Leave a flexible framework that will play nicely with other access control / policy definition / trust metric plugins
-
-### Other
-
-* Added a few helper methods for linking to user pages
-* Uniform handling of logout, remember_token
-* Stricter email, login field validation
-* Minor security fixes -- see CHANGELOG
-
-***************************************************************************
-
-## Non-backwards compatible Changes
-
-Here are a few changes in the May 2008 release that increase "Defense in Depth"
-but may require changes to existing accounts
-
-* If you have an existing site, none of these changes are compelling enough to
- warrant migrating your userbase.
-* If you are generating for a new site, all of these changes are low-impact.
- You should apply them.
-
-### Passwords
-
-The new password encryption (using a site key salt and stretching) will break
-existing user accounts' passwords. We recommend you use the --old-passwords
-option or write a migration tool and submit it as a patch. See the
-[[Tradeoffs]] note for more information.
-
-### Validations
-
-By default, email and usernames are validated against a somewhat strict pattern; your users' values may be now illegal. Adjust to suit.
-
-***************************************************************************
-
-
-
-## Installation
-
-This is a basic restful authentication generator for rails, taken from
-acts as authenticated. Currently it requires Rails 1.2.6 or above.
-
-**IMPORTANT FOR RAILS > 2.1 USERS** To avoid a @NameError@ exception ("lighthouse tracker ticket":http://rails_security.lighthouseapp.com/projects/15332-restful_authentication/tickets/2-not-a-valid-constant-name-errors#ticket-2-2), check out the code to have an _underscore_ and not _dash_ in its name:
-* either use git clone git://github.com/technoweenie/restful-authentication.git restful_authentication
-* or rename the plugin's directory to be restful_authentication after fetching it.
-
-To use the generator:
-
- ./script/generate authenticated user sessions \
- --include-activation \
- --stateful \
- --rspec \
- --skip-migration \
- --skip-routes \
- --old-passwords
-
-* The first parameter specifies the model that gets created in signup (typically
- a user or account model). A model with migration is created, as well as a
- basic controller with the create method. You probably want to say "User" here.
-
-* The second parameter specifies the session controller name. This is the
- controller that handles the actual login/logout function on the site.
- (probably: "Session").
-
-* --include-activation: Generates the code for a ActionMailer and its respective
- Activation Code through email.
-
-* --stateful: Builds in support for acts_as_state_machine and generates
- activation code. (@--stateful@ implies @--include-activation@). Based on the
- idea at [[http://www.vaporbase.com/postings/stateful_authentication]]. Passing
- @--skip-migration@ will skip the user migration, and @--skip-routes@ will skip
- resource generation -- both useful if you've already run this generator.
- (Needs the "acts_as_state_machine plugin":http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/,
- but new installs should probably run with @--aasm@ instead.)
-
-* --aasm: Works the same as stateful but uses the "updated aasm gem":http://github.com/rubyist/aasm/tree/master
-
-* --rspec: Generate RSpec tests and Stories in place of standard rails tests.
- This requires the
- "RSpec and Rspec-on-rails plugins":http://rspec.info/
- (make sure you "./script/generate rspec" after installing RSpec.) The rspec
- and story suite are much more thorough than the rails tests, and changes are
- unlikely to be backported.
-
-* --old-passwords: Use the older password scheme (see [[#COMPATIBILITY]], above)
-
-* --skip-migration: Don't generate a migration file for this model
-
-* --skip-routes: Don't generate a resource line in @config/routes.rb@
-
-***************************************************************************
-
-
-## After installing
-
-The below assumes a Model named 'User' and a Controller named 'Session'; please
-alter to suit. There are additional security minutae in @notes/README-Tradeoffs@
--- only the paranoid or the curious need bother, though.
-
-* Add these familiar login URLs to your @config/routes.rb@ if you like:
-
-
-
- Pay attention, may be this is not an issue for everybody, but if you should
- have problems, that the sent activation_code does match with that in the
- database stored, reload your user object before sending its data through email
- something like:
-
-
- class UserObserver < ActiveRecord::Observer
- def after_create(user)
- user.reload
- UserMailer.deliver_signup_notification(user)
- end
- def after_save(user)
- user.reload
- UserMailer.deliver_activation(user) if user.recently_activated?
- end
- end
-
-
-
-* With @--stateful@, add an observer to config/environment.rb:
-
-
-<%% end -%>
diff --git a/vendor/plugins/restful-authentication/generators/authenticated/templates/activation.erb b/vendor/plugins/restful-authentication/generators/authenticated/templates/activation.erb
deleted file mode 100644
index 9d4ad0b8..00000000
--- a/vendor/plugins/restful-authentication/generators/authenticated/templates/activation.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-<%%=h @<%= file_name %>.login %>, your account has been activated. Welcome aboard!
-
- <%%=h @url %>
diff --git a/vendor/plugins/restful-authentication/generators/authenticated/templates/authenticated_system.rb b/vendor/plugins/restful-authentication/generators/authenticated/templates/authenticated_system.rb
deleted file mode 100644
index 137dea87..00000000
--- a/vendor/plugins/restful-authentication/generators/authenticated/templates/authenticated_system.rb
+++ /dev/null
@@ -1,189 +0,0 @@
-module AuthenticatedSystem
- protected
- # Returns true or false if the <%= file_name %> is logged in.
- # Preloads @current_<%= file_name %> with the <%= file_name %> model if they're logged in.
- def logged_in?
- !!current_<%= file_name %>
- end
-
- # Accesses the current <%= file_name %> from the session.
- # Future calls avoid the database because nil is not equal to false.
- def current_<%= file_name %>
- @current_<%= file_name %> ||= (login_from_session || login_from_basic_auth || login_from_cookie) unless @current_<%= file_name %> == false
- end
-
- # Store the given <%= file_name %> id in the session.
- def current_<%= file_name %>=(new_<%= file_name %>)
- session[:<%= file_name %>_id] = new_<%= file_name %> ? new_<%= file_name %>.id : nil
- @current_<%= file_name %> = new_<%= file_name %> || false
- end
-
- # Check if the <%= file_name %> is authorized
- #
- # Override this method in your controllers if you want to restrict access
- # to only a few actions or if you want to check if the <%= file_name %>
- # has the correct rights.
- #
- # Example:
- #
- # # only allow nonbobs
- # def authorized?
- # current_<%= file_name %>.login != "bob"
- # end
- #
- def authorized?(action = action_name, resource = nil)
- logged_in?
- end
-
- # Filter method to enforce a login requirement.
- #
- # To require logins for all actions, use this in your controllers:
- #
- # before_filter :login_required
- #
- # To require logins for specific actions, use this in your controllers:
- #
- # before_filter :login_required, :only => [ :edit, :update ]
- #
- # To skip this in a subclassed controller:
- #
- # skip_before_filter :login_required
- #
- def login_required
- authorized? || access_denied
- end
-
- # Redirect as appropriate when an access request fails.
- #
- # The default action is to redirect to the login screen.
- #
- # Override this method in your controllers if you want to have special
- # behavior in case the <%= file_name %> is not authorized
- # to access the requested action. For example, a popup window might
- # simply close itself.
- def access_denied
- respond_to do |format|
- format.html do
- store_location
- redirect_to new_<%= controller_routing_name %>_path
- end
- # format.any doesn't work in rails version < http://dev.rubyonrails.org/changeset/8987
- # Add any other API formats here. (Some browsers, notably IE6, send Accept: */* and trigger
- # the 'format.any' block incorrectly. See http://bit.ly/ie6_borken or http://bit.ly/ie6_borken2
- # for a workaround.)
- format.any(:json, :xml) do
- request_http_basic_authentication 'Web Password'
- end
- end
- end
-
- # Store the URI of the current request in the session.
- #
- # We can return to this location by calling #redirect_back_or_default.
- def store_location
- session[:return_to] = request.request_uri
- end
-
- # Redirect to the URI stored by the most recent store_location call or
- # to the passed default. Set an appropriately modified
- # after_filter :store_location, :only => [:index, :new, :show, :edit]
- # for any controller you want to be bounce-backable.
- def redirect_back_or_default(default)
- redirect_to(session[:return_to] || default)
- session[:return_to] = nil
- end
-
- # Inclusion hook to make #current_<%= file_name %> and #logged_in?
- # available as ActionView helper methods.
- def self.included(base)
- base.send :helper_method, :current_<%= file_name %>, :logged_in?, :authorized? if base.respond_to? :helper_method
- end
-
- #
- # Login
- #
-
- # Called from #current_<%= file_name %>. First attempt to login by the <%= file_name %> id stored in the session.
- def login_from_session
- self.current_<%= file_name %> = <%= class_name %>.find_by_id(session[:<%= file_name %>_id]) if session[:<%= file_name %>_id]
- end
-
- # Called from #current_<%= file_name %>. Now, attempt to login by basic authentication information.
- def login_from_basic_auth
- authenticate_with_http_basic do |login, password|
- self.current_<%= file_name %> = <%= class_name %>.authenticate(login, password)
- end
- end
-
- #
- # Logout
- #
-
- # Called from #current_<%= file_name %>. Finaly, attempt to login by an expiring token in the cookie.
- # for the paranoid: we _should_ be storing <%= file_name %>_token = hash(cookie_token, request IP)
- def login_from_cookie
- <%= file_name %> = !cookies[:auth_token].blank? && <%= class_name %>.find_by_remember_token(cookies[:auth_token])
- if <%= file_name %> && <%= file_name %>.remember_token?
- self.current_<%= file_name %> = <%= file_name %>
- handle_remember_cookie! false # freshen cookie token (keeping date)
- self.current_<%= file_name %>
- end
- end
-
- # This is ususally what you want; resetting the session willy-nilly wreaks
- # havoc with forgery protection, and is only strictly necessary on login.
- # However, **all session state variables should be unset here**.
- def logout_keeping_session!
- # Kill server-side auth cookie
- @current_<%= file_name %>.forget_me if @current_<%= file_name %>.is_a? <%= class_name %>
- @current_<%= file_name %> = false # not logged in, and don't do it for me
- kill_remember_cookie! # Kill client-side auth cookie
- session[:<%= file_name %>_id] = nil # keeps the session but kill our variable
- # explicitly kill any other session variables you set
- end
-
- # The session should only be reset at the tail end of a form POST --
- # otherwise the request forgery protection fails. It's only really necessary
- # when you cross quarantine (logged-out to logged-in).
- def logout_killing_session!
- logout_keeping_session!
- reset_session
- end
-
- #
- # Remember_me Tokens
- #
- # Cookies shouldn't be allowed to persist past their freshness date,
- # and they should be changed at each login
-
- # Cookies shouldn't be allowed to persist past their freshness date,
- # and they should be changed at each login
-
- def valid_remember_cookie?
- return nil unless @current_<%= file_name %>
- (@current_<%= file_name %>.remember_token?) &&
- (cookies[:auth_token] == @current_<%= file_name %>.remember_token)
- end
-
- # Refresh the cookie auth token if it exists, create it otherwise
- def handle_remember_cookie!(new_cookie_flag)
- return unless @current_<%= file_name %>
- case
- when valid_remember_cookie? then @current_<%= file_name %>.refresh_token # keeping same expiry date
- when new_cookie_flag then @current_<%= file_name %>.remember_me
- else @current_<%= file_name %>.forget_me
- end
- send_remember_cookie!
- end
-
- def kill_remember_cookie!
- cookies.delete :auth_token
- end
-
- def send_remember_cookie!
- cookies[:auth_token] = {
- :value => @current_<%= file_name %>.remember_token,
- :expires => @current_<%= file_name %>.remember_token_expires_at }
- end
-
-end
diff --git a/vendor/plugins/restful-authentication/generators/authenticated/templates/authenticated_test_helper.rb b/vendor/plugins/restful-authentication/generators/authenticated/templates/authenticated_test_helper.rb
deleted file mode 100644
index 7398f2ec..00000000
--- a/vendor/plugins/restful-authentication/generators/authenticated/templates/authenticated_test_helper.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-module AuthenticatedTestHelper
- # Sets the current <%= file_name %> in the session from the <%= file_name %> fixtures.
- def login_as(<%= file_name %>)
- @request.session[:<%= file_name %>_id] = <%= file_name %> ? (<%= file_name %>.is_a?(<%= file_name.camelize %>) ? <%= file_name %>.id : <%= table_name %>(<%= file_name %>).id) : nil
- end
-
- def authorize_as(<%= file_name %>)
- @request.env["HTTP_AUTHORIZATION"] = <%= file_name %> ? ActionController::HttpAuthentication::Basic.encode_credentials(<%= table_name %>(<%= file_name %>).login, 'monkey') : nil
- end
-
-<% if options[:rspec] -%>
- # rspec
- def mock_<%= file_name %>
- <%= file_name %> = mock_model(<%= class_name %>, :id => 1,
- :login => 'user_name',
- :name => 'U. Surname',
- :to_xml => "<%= class_name %>-in-XML", :to_json => "<%= class_name %>-in-JSON",
- :errors => [])
- <%= file_name %>
- end
-<% end -%>
-end
diff --git a/vendor/plugins/restful-authentication/generators/authenticated/templates/controller.rb b/vendor/plugins/restful-authentication/generators/authenticated/templates/controller.rb
deleted file mode 100644
index b078c7bb..00000000
--- a/vendor/plugins/restful-authentication/generators/authenticated/templates/controller.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# This controller handles the login/logout function of the site.
-class <%= controller_class_name %>Controller < ApplicationController
- # Be sure to include AuthenticationSystem in Application Controller instead
- include AuthenticatedSystem
-
- # render new.erb.html
- def new
- end
-
- def create
- logout_keeping_session!
- <%= file_name %> = <%= class_name %>.authenticate(params[:login], params[:password])
- if <%= file_name %>
- # Protects against session fixation attacks, causes request forgery
- # protection if user resubmits an earlier form using back
- # button. Uncomment if you understand the tradeoffs.
- # reset_session
- self.current_<%= file_name %> = <%= file_name %>
- new_cookie_flag = (params[:remember_me] == "1")
- handle_remember_cookie! new_cookie_flag
- redirect_back_or_default('/')
- flash[:notice] = "Logged in successfully"
- else
- note_failed_signin
- @login = params[:login]
- @remember_me = params[:remember_me]
- render :action => 'new'
- end
- end
-
- def destroy
- logout_killing_session!
- flash[:notice] = "You have been logged out."
- redirect_back_or_default('/')
- end
-
-protected
- # Track failed login attempts
- def note_failed_signin
- flash[:error] = "Couldn't log you in as '#{params[:login]}'"
- logger.warn "Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}"
- end
-end
diff --git a/vendor/plugins/restful-authentication/generators/authenticated/templates/features/accounts.feature b/vendor/plugins/restful-authentication/generators/authenticated/templates/features/accounts.feature
deleted file mode 100644
index 021471cc..00000000
--- a/vendor/plugins/restful-authentication/generators/authenticated/templates/features/accounts.feature
+++ /dev/null
@@ -1,109 +0,0 @@
-Visitors should be in control of creating an account and of proving their
-essential humanity/accountability or whatever it is people think the
-id-validation does. We should be fairly skeptical about this process, as the
-identity+trust chain starts here.
-
-Story: Creating an account
- As an anonymous user
- I want to be able to create an account
- So that I can be one of the cool kids
-
- #
- # Account Creation: Get entry form
- #
- Scenario: Anonymous user can start creating an account
- Given an anonymous user
- When she goes to /signup
- Then she should be at the 'users/new' page
- And the page should look AWESOME
- And she should see a