Skip to content

Commit

Permalink
oops, need file_column for legacy support
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Peychich committed Oct 6, 2009
1 parent 7734427 commit 2e6d46a
Show file tree
Hide file tree
Showing 24 changed files with 2,887 additions and 0 deletions.
69 changes: 69 additions & 0 deletions vendor/plugins/file_column/CHANGELOG
@@ -0,0 +1,69 @@
*svn*
* allow for directories in file_column dirs as well
* use subdirs for versions instead of fiddling with filename
* url_for_image_column_helper for dynamic resizing of images from views
* new "crop" feature [Sean Treadway]
* url_for_file_column helper: do not require model objects to be stored in
instance variables
* allow more fined-grained control over :store_dir via callback
methods [Gerret Apelt]
* allow assignment of regular file objects
* validation of file format and file size [Kyle Maxwell]
* validation of image dimensions [Lee O'Mara]
* file permissions can be set via :permissions option
* fixed bug that prevents deleting of file via assigning nil if
column is declared as NON NULL on some databases
* don't expand absolute paths. This is necessary for file_column to work
when your rails app is deployed into a sub-directory via a symbolic link
* url_for_*_column will no longer return absolute URLs! Instead, although the
generated URL starts with a slash, it will be relative to your application's
root URL. This is so, because rails' image_tag helper will automatically
convert it to an absolute URL. If you need an absolute URL (e.g., to pass
it to link_to) use url_for_file_column's :absolute => true option.
* added support for file_column enabled unit tests [Manuel Holtgrewe]
* support for custom transformation of images [Frederik Fix]
* allow setting of image attributes (e.g., quality) [Frederik Fix]
* :magick columns can optionally ignore non-images (i.e., do not try to
resize them)

0.3.1
* make object with file_columns serializable
* use normal require for RMagick, so that it works with gem
and custom install as well

0.3
* fixed bug where empty file uploads were not recognized with some browsers
* fixed bug on windows when "file" utility is not present
* added option to disable automatic file extension correction
* Only allow one attribute per call to file_column, so that options only
apply to one argument
* try to detect when people forget to set the form encoding to
'multipart/form-data'
* converted to rails plugin
* easy integration with RMagick

0.2
* complete rewrite using state pattern
* fixed sanitize filename [Michael Raidel]
* fixed bug when no file was uploaded [Michael Raidel]
* try to fix filename extensions [Michael Raidel]
* Feed absolute paths through File.expand_path to make them as simple as possible
* Make file_column_field helper work with auto-ids (e.g., "event[]")

0.1.3
* test cases with more than 1 file_column
* fixed bug when file_column was called with several arguments
* treat empty ("") file_columns as nil
* support for binary files on windows

0.1.2
* better rails integration, so that you do not have to include the modules yourself. You
just have to "require 'rails_file_column'" in your "config/environment.rb"
* Rakefile for testing and packaging

0.1.1 (2005-08-11)
* fixed nasty bug in url_for_file_column that made it unusable on Apache
* prepared for public release

0.1 (2005-08-10)
* initial release
54 changes: 54 additions & 0 deletions vendor/plugins/file_column/README
@@ -0,0 +1,54 @@
FEATURES
========

Let's assume an model class named Entry, where we want to define the "image" column
as a "file_upload" column.

class Entry < ActiveRecord::Base
file_column :image
end

* every entry can have one uploaded file, the filename will be stored in the "image" column

* files will be stored in "public/entry/image/<entry.id>/filename.ext"

* Newly uploaded files will be stored in "public/entry/tmp/<random>/filename.ext" so that
they can be reused in form redisplays (due to validation etc.)

* in a view, "<%= file_column_field 'entry', 'image' %> will create a file upload field as well
as a hidden field to recover files uploaded before in a case of a form redisplay

* in a view, "<%= url_for_file_column 'entry', 'image' %> will create an URL to access the
uploaded file. Note that you need an Entry object in the instance variable @entry for this
to work.

* easy integration with RMagick to resize images and/or create thumb-nails.

USAGE
=====

Just drop the whole directory into your application's "vendor/plugins" directory. Starting
with version 1.0rc of rails, it will be automatically picked for you by rails plugin
mechanism.

DOCUMENTATION
=============

Please look at the rdoc-generated documentation in the "doc" directory.

RUNNING UNITTESTS
=================

There are extensive unittests in the "test" directory. Currently, only MySQL is supported, but
you should be able to easily fix this by looking at "connection.rb". You have to create a
database for the tests and put the connection information into "connection.rb". The schema
for MySQL can be found in "test/fixtures/mysql.sql".

You can run the tests by starting the "*_test.rb" in the directory "test"

BUGS & FEEDBACK
===============

Bug reports (as well as patches) and feedback are very welcome. Please send it to
sebastian.kanthak@muehlheim.de

36 changes: 36 additions & 0 deletions vendor/plugins/file_column/Rakefile
@@ -0,0 +1,36 @@
task :default => [:test]

PKG_NAME = "file-column"
PKG_VERSION = "0.3.1"

PKG_DIR = "release/#{PKG_NAME}-#{PKG_VERSION}"

task :clean do
rm_rf "release"
end

task :setup_directories do
mkpath "release"
end


task :checkout_release => :setup_directories do
rm_rf PKG_DIR
revision = ENV["REVISION"] || "HEAD"
sh "svn export -r #{revision} . #{PKG_DIR}"
end

task :release_docs => :checkout_release do
sh "cd #{PKG_DIR}; rdoc lib"
end

task :package => [:checkout_release, :release_docs] do
sh "cd release; tar czf #{PKG_NAME}-#{PKG_VERSION}.tar.gz #{PKG_NAME}-#{PKG_VERSION}"
end

task :test do
sh "cd test; ruby file_column_test.rb"
sh "cd test; ruby file_column_helper_test.rb"
sh "cd test; ruby magick_test.rb"
sh "cd test; ruby magick_view_only_test.rb"
end
6 changes: 6 additions & 0 deletions vendor/plugins/file_column/TODO
@@ -0,0 +1,6 @@
* document configuration options better
* support setting of permissions
* validation methods for file format/size
* delete stale files from tmp directories

* ensure valid URLs are created even when deployed at sub-path (compute_public_url?)
13 changes: 13 additions & 0 deletions vendor/plugins/file_column/init.rb
@@ -0,0 +1,13 @@
# plugin init file for rails
# this file will be picked up by rails automatically and
# add the file_column extensions to rails

require 'file_column'
require 'file_compat'
require 'file_column_helper'
require 'validations'
#require 'test_case' if RAILS_ENV == 'test'

ActiveRecord::Base.send(:include, FileColumn)
ActionView::Base.send(:include, FileColumnHelper)
ActiveRecord::Base.send(:include, FileColumn::Validations)

0 comments on commit 2e6d46a

Please sign in to comment.