Permalink
Browse files

Finally decided not to keep attachment_fu (didn't managed to solve at…

…tachment_fu related errors..)
  • Loading branch information...
1 parent 3bb3dbb commit 7678b67bcc47a1544d25722c17e9d1e0e9a0d4e0 @jbbarth jbbarth committed Jan 30, 2009
Showing with 0 additions and 3,192 deletions.
  1. +0 −14 config/amazon_s3.yml
  2. +0 −35 vendor/plugins/attachment_fu/CHANGELOG
  3. +0 −162 vendor/plugins/attachment_fu/README
  4. +0 −22 vendor/plugins/attachment_fu/Rakefile
  5. +0 −14 vendor/plugins/attachment_fu/amazon_s3.yml.tpl
  6. +0 −16 vendor/plugins/attachment_fu/init.rb
  7. +0 −5 vendor/plugins/attachment_fu/install.rb
  8. +0 −93 vendor/plugins/attachment_fu/lib/geometry.rb
  9. +0 −465 vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb
  10. +0 −39 vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/db_file_backend.rb
  11. +0 −97 vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb
  12. +0 −303 vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb
  13. +0 −56 vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/core_image_processor.rb
  14. +0 −54 vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/gd2_processor.rb
  15. +0 −61 vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb
  16. +0 −59 vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/mini_magick_processor.rb
  17. +0 −54 vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb
  18. +0 −16 vendor/plugins/attachment_fu/test/backends/db_file_test.rb
  19. +0 −80 vendor/plugins/attachment_fu/test/backends/file_system_test.rb
  20. +0 −107 vendor/plugins/attachment_fu/test/backends/remote/s3_test.rb
  21. +0 −57 vendor/plugins/attachment_fu/test/base_attachment_tests.rb
  22. +0 −64 vendor/plugins/attachment_fu/test/basic_test.rb
  23. +0 −18 vendor/plugins/attachment_fu/test/database.yml
  24. +0 −57 vendor/plugins/attachment_fu/test/extra_attachment_test.rb
  25. +0 −148 vendor/plugins/attachment_fu/test/fixtures/attachment.rb
  26. BIN vendor/plugins/attachment_fu/test/fixtures/files/fake/rails.png
  27. +0 −1 vendor/plugins/attachment_fu/test/fixtures/files/foo.txt
  28. BIN vendor/plugins/attachment_fu/test/fixtures/files/rails.png
  29. +0 −101 vendor/plugins/attachment_fu/test/geometry_test.rb
  30. +0 −31 vendor/plugins/attachment_fu/test/processors/core_image_test.rb
  31. +0 −31 vendor/plugins/attachment_fu/test/processors/gd2_test.rb
  32. +0 −31 vendor/plugins/attachment_fu/test/processors/image_science_test.rb
  33. +0 −31 vendor/plugins/attachment_fu/test/processors/mini_magick_test.rb
  34. +0 −255 vendor/plugins/attachment_fu/test/processors/rmagick_test.rb
  35. +0 −108 vendor/plugins/attachment_fu/test/schema.rb
  36. +0 −142 vendor/plugins/attachment_fu/test/test_helper.rb
  37. +0 −55 vendor/plugins/attachment_fu/test/validation_test.rb
  38. +0 −27 vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/color.rb
  39. +0 −31 vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/effects.rb
  40. +0 −25 vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/perspective.rb
  41. +0 −25 vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/quality.rb
  42. +0 −47 vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/scale.rb
  43. +0 −32 vendor/plugins/attachment_fu/vendor/red_artisan/core_image/filters/watermark.rb
  44. +0 −123 vendor/plugins/attachment_fu/vendor/red_artisan/core_image/processor.rb
View
@@ -1,14 +0,0 @@
-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:
@@ -1,35 +0,0 @@
-* Apr 17 2008 *
-* amazon_s3.yml is now passed through ERB before being passed to AWS::S3 [François Beausoleil]
-
-* Mar 22 2008 *
-* Some tweaks to support Rails 2.0 and Rails 2.1 due to ActiveSupport::Callback changes.
- Thanks to http://blog.methodmissing.com/2008/1/19/edge-callback-refactorings-attachment_fu/
-
-* Feb. 26, 2008 *
-* remove breakpoint from test_helper, makes test suite crazy (at least Rails 2+) [Rob Sanheim]
-* make S3 test really optional [Rob Sanheim]
-
-* Nov 27, 2007 *
-* Handle properly ImageScience thumbnails resized from a gif file [Matt Aimonetti]
-* Save thumbnails file size properly when using ImageScience [Matt Aimonetti]
-* fixed s3 config file loading with latest versions of Rails [Matt Aimonetti]
-
-* April 2, 2007 *
-
-* don't copy the #full_filename to the default #temp_paths array if it doesn't exist
-* add default ID partitioning for attachments
-* add #binmode call to Tempfile (note: ruby should be doing this!) [Eric Beland]
-* Check for current type of :thumbnails option.
-* allow customization of the S3 configuration file path with the :s3_config_path option.
-* Don't try to remove thumbnails if there aren't any. Closes #3 [ben stiglitz]
-
-* BC * (before changelog)
-
-* add default #temp_paths entry [mattly]
-* add MiniMagick support to attachment_fu [Isacc]
-* update #destroy_file to clear out any empty directories too [carlivar]
-* fix references to S3Backend module [Hunter Hillegas]
-* make #current_data public with db_file and s3 backends [ebryn]
-* oops, actually svn add the files for s3 backend. [Jeffrey Hardy]
-* experimental s3 support, egad, no tests.... [Jeffrey Hardy]
-* doh, fix a few bad references to ActsAsAttachment [sixty4bit]
@@ -1,162 +0,0 @@
-attachment-fu
-=============
-
-attachment_fu is a plugin by Rick Olson (aka technoweenie <http://techno-weenie.net>) and is the successor to acts_as_attachment. To get a basic run-through of its capabilities, check out Mike Clark's tutorial <http://clarkware.com/cgi/blosxom/2007/02/24#FileUploadFu>.
-
-
-attachment_fu functionality
-===========================
-
-attachment_fu facilitates file uploads in Ruby on Rails. There are a few storage options for the actual file data, but the plugin always at a minimum stores metadata for each file in the database.
-
-There are three storage options for files uploaded through attachment_fu:
- File system
- Database file
- Amazon S3
-
-Each method of storage many options associated with it that will be covered in the following section. Something to note, however, is that the Amazon S3 storage requires you to modify config/amazon_s3.yml and the Database file storage requires an extra table.
-
-
-attachment_fu models
-====================
-
-For all three of these storage options a table of metadata is required. This table will contain information about the file (hence the 'meta') and its location. This table has no restrictions on naming, unlike the extra table required for database storage, which must have a table name of db_files (and by convention a model of DbFile).
-
-In the model there are two methods made available by this plugins: has_attachment and validates_as_attachment.
-
-has_attachment(options = {})
- This method accepts the options in a hash:
- :content_type # Allowed content types.
- # Allows all by default. Use :image to allow all standard image types.
- :min_size # Minimum size allowed.
- # 1 byte is the default.
- :max_size # Maximum size allowed.
- # 1.megabyte is the default.
- :size # Range of sizes allowed.
- # (1..1.megabyte) is the default. This overrides the :min_size and :max_size options.
- :resize_to # Used by RMagick to resize images.
- # Pass either an array of width/height, or a geometry string.
- :thumbnails # Specifies a set of thumbnails to generate.
- # This accepts a hash of filename suffixes and RMagick resizing options.
- # This option need only be included if you want thumbnailing.
- :thumbnail_class # Set which model class to use for thumbnails.
- # This current attachment class is used by default.
- :path_prefix # path to store the uploaded files.
- # Uses public/#{table_name} by default for the filesystem, and just #{table_name} for the S3 backend.
- # Setting this sets the :storage to :file_system.
- :storage # Specifies the storage system to use..
- # Defaults to :db_file. Options are :file_system, :db_file, and :s3.
- :processor # Sets the image processor to use for resizing of the attached image.
- # Options include ImageScience, Rmagick, and MiniMagick. Default is whatever is installed.
-
-
- Examples:
- has_attachment :max_size => 1.kilobyte
- has_attachment :size => 1.megabyte..2.megabytes
- has_attachment :content_type => 'application/pdf'
- has_attachment :content_type => ['application/pdf', 'application/msword', 'text/plain']
- has_attachment :content_type => :image, :resize_to => [50,50]
- has_attachment :content_type => ['application/pdf', :image], :resize_to => 'x50'
- has_attachment :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }
- has_attachment :storage => :file_system, :path_prefix => 'public/files'
- has_attachment :storage => :file_system, :path_prefix => 'public/files',
- :content_type => :image, :resize_to => [50,50]
- has_attachment :storage => :file_system, :path_prefix => 'public/files',
- :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }
- has_attachment :storage => :s3
-
-validates_as_attachment
- This method prevents files outside of the valid range (:min_size to :max_size, or the :size range) from being saved. It does not however, halt the upload of such files. They will be uploaded into memory regardless of size before validation.
-
- Example:
- validates_as_attachment
-
-
-attachment_fu migrations
-========================
-
-Fields for attachment_fu metadata tables...
- in general:
- size, :integer # file size in bytes
- content_type, :string # mime type, ex: application/mp3
- filename, :string # sanitized filename
- that reference images:
- height, :integer # in pixels
- width, :integer # in pixels
- that reference images that will be thumbnailed:
- parent_id, :integer # id of parent image (on the same table, a self-referencing foreign-key).
- # Only populated if the current object is a thumbnail.
- thumbnail, :string # the 'type' of thumbnail this attachment record describes.
- # Only populated if the current object is a thumbnail.
- # Usage:
- # [ In Model 'Avatar' ]
- # has_attachment :content_type => :image,
- # :storage => :file_system,
- # :max_size => 500.kilobytes,
- # :resize_to => '320x200>',
- # :thumbnails => { :small => '10x10>',
- # :thumb => '100x100>' }
- # [ Elsewhere ]
- # @user.avatar.thumbnails.first.thumbnail #=> 'small'
- that reference files stored in the database (:db_file):
- db_file_id, :integer # id of the file in the database (foreign key)
-
-Field for attachment_fu db_files table:
- data, :binary # binary file data, for use in database file storage
-
-
-attachment_fu views
-===================
-
-There are two main views tasks that will be directly affected by attachment_fu: upload forms and displaying uploaded images.
-
-There are two parts of the upload form that differ from typical usage.
- 1. Include ':multipart => true' in the html options of the form_for tag.
- Example:
- <% form_for(:attachment_metadata, :url => { :action => "create" }, :html => { :multipart => true }) do |form| %>
-
- 2. Use the file_field helper with :uploaded_data as the field name.
- Example:
- <%= form.file_field :uploaded_data %>
-
-Displaying uploaded images is made easy by the public_filename method of the ActiveRecord attachment objects using file system and s3 storage.
-
-public_filename(thumbnail = nil)
- Returns the public path to the file. If a thumbnail prefix is specified it will return the public file path to the corresponding thumbnail.
- Examples:
- attachment_obj.public_filename #=> /attachments/2/file.jpg
- attachment_obj.public_filename(:thumb) #=> /attachments/2/file_thumb.jpg
- attachment_obj.public_filename(:small) #=> /attachments/2/file_small.jpg
-
-When serving files from database storage, doing more than simply downloading the file is beyond the scope of this document.
-
-
-attachment_fu controllers
-=========================
-
-There are two considerations to take into account when using attachment_fu in controllers.
-
-The first is when the files have no publicly accessible path and need to be downloaded through an action.
-
-Example:
- def readme
- send_file '/path/to/readme.txt', :type => 'plain/text', :disposition => 'inline'
- end
-
-See the possible values for send_file for reference.
-
-
-The second is when saving the file when submitted from a form.
-Example in view:
- <%= form.file_field :attachable, :uploaded_data %>
-
-Example in controller:
- def create
- @attachable_file = AttachmentMetadataModel.new(params[:attachable])
- if @attachable_file.save
- flash[:notice] = 'Attachment was successfully created.'
- redirect_to attachable_url(@attachable_file)
- else
- render :action => :new
- end
- end
@@ -1,22 +0,0 @@
-require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the attachment_fu plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
-desc 'Generate documentation for the attachment_fu plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'ActsAsAttachment'
- rdoc.options << '--line-numbers --inline-source'
- rdoc.rdoc_files.include('README')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
@@ -1,14 +0,0 @@
-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:
@@ -1,16 +0,0 @@
-require 'tempfile'
-
-Tempfile.class_eval do
- # overwrite so tempfiles use the extension of the basename. important for rmagick and image science
- def make_tmpname(basename, n)
- ext = nil
- sprintf("%s%d-%d%s", basename.to_s.gsub(/\.\w+$/) { |s| ext = s; '' }, $$, n, ext)
- end
-end
-
-require 'geometry'
-ActiveRecord::Base.send(:extend, Technoweenie::AttachmentFu::ActMethods)
-Technoweenie::AttachmentFu.tempfile_path = ATTACHMENT_FU_TEMPFILE_PATH if Object.const_defined?(:ATTACHMENT_FU_TEMPFILE_PATH)
-FileUtils.mkdir_p Technoweenie::AttachmentFu.tempfile_path
-
-$:.unshift(File.dirname(__FILE__) + '/vendor')
@@ -1,5 +0,0 @@
-require 'fileutils'
-
-s3_config = File.dirname(__FILE__) + '/../../../config/amazon_s3.yml'
-FileUtils.cp File.dirname(__FILE__) + '/amazon_s3.yml.tpl', s3_config unless File.exist?(s3_config)
-puts IO.read(File.join(File.dirname(__FILE__), 'README'))
@@ -1,93 +0,0 @@
-# This Geometry class was yanked from RMagick. However, it lets ImageMagick handle the actual change_geometry.
-# Use #new_dimensions_for to get new dimensons
-# Used so I can use spiffy RMagick geometry strings with ImageScience
-class Geometry
- # ! and @ are removed until support for them is added
- FLAGS = ['', '%', '<', '>']#, '!', '@']
- RFLAGS = { '%' => :percent,
- '!' => :aspect,
- '<' => :>,
- '>' => :<,
- '@' => :area }
-
- attr_accessor :width, :height, :x, :y, :flag
-
- def initialize(width=nil, height=nil, x=nil, y=nil, flag=nil)
- # Support floating-point width and height arguments so Geometry
- # objects can be used to specify Image#density= arguments.
- raise ArgumentError, "width must be >= 0: #{width}" if width < 0
- raise ArgumentError, "height must be >= 0: #{height}" if height < 0
- @width = width.to_f
- @height = height.to_f
- @x = x.to_i
- @y = y.to_i
- @flag = flag
- end
-
- # Construct an object from a geometry string
- RE = /\A(\d*)(?:x(\d+))?([-+]\d+)?([-+]\d+)?([%!<>@]?)\Z/
-
- def self.from_s(str)
- raise(ArgumentError, "no geometry string specified") unless str
-
- if m = RE.match(str)
- new(m[1].to_i, m[2].to_i, m[3].to_i, m[4].to_i, RFLAGS[m[5]])
- else
- raise ArgumentError, "invalid geometry format"
- end
- end
-
- # Convert object to a geometry string
- def to_s
- str = ''
- str << "%g" % @width if @width > 0
- str << 'x' if (@width > 0 || @height > 0)
- str << "%g" % @height if @height > 0
- str << "%+d%+d" % [@x, @y] if (@x != 0 || @y != 0)
- str << FLAGS[@flag.to_i]
- end
-
- # attempts to get new dimensions for the current geometry string given these old dimensions.
- # This doesn't implement the aspect flag (!) or the area flag (@). PDI
- def new_dimensions_for(orig_width, orig_height)
- new_width = orig_width
- new_height = orig_height
-
- case @flag
- when :percent
- scale_x = @width.zero? ? 100 : @width
- scale_y = @height.zero? ? @width : @height
- new_width = scale_x.to_f * (orig_width.to_f / 100.0)
- new_height = scale_y.to_f * (orig_height.to_f / 100.0)
- when :<, :>, nil
- scale_factor =
- if new_width.zero? || new_height.zero?
- 1.0
- else
- if @width.nonzero? && @height.nonzero?
- [@width.to_f / new_width.to_f, @height.to_f / new_height.to_f].min
- else
- @width.nonzero? ? (@width.to_f / new_width.to_f) : (@height.to_f / new_height.to_f)
- end
- end
- new_width = scale_factor * new_width.to_f
- new_height = scale_factor * new_height.to_f
- new_width = orig_width if @flag && orig_width.send(@flag, new_width)
- new_height = orig_height if @flag && orig_height.send(@flag, new_height)
- end
-
- [new_width, new_height].collect! { |v| v.round }
- end
-end
-
-class Array
- # allows you to get new dimensions for the current array of dimensions with a given geometry string
- #
- # [50, 64] / '40>' # => [40, 51]
- def /(geometry)
- raise ArgumentError, "Only works with a [width, height] pair" if size != 2
- raise ArgumentError, "Must pass a valid geometry string or object" unless geometry.is_a?(String) || geometry.is_a?(Geometry)
- geometry = Geometry.from_s(geometry) if geometry.is_a?(String)
- geometry.new_dimensions_for first, last
- end
-end
Oops, something went wrong.

0 comments on commit 7678b67

Please sign in to comment.