forked from Simonandgarfunkel/swfupload-rails-authentication
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
202 changed files
with
12,344 additions
and
5,696 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.bundle | ||
.DS_Store | ||
db/*.sqlite3 | ||
log/*.log | ||
tmp/**/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
source 'http://rubygems.org' | ||
|
||
gem 'rails', '3.0.0.rc' | ||
|
||
# Bundle edge Rails instead: | ||
# gem 'rails', :git => 'git://github.com/rails/rails.git' | ||
|
||
gem 'sqlite3-ruby', :require => 'sqlite3' | ||
gem 'paperclip' | ||
gem 'mime-types', :require => 'mime/types' | ||
|
||
# Use unicorn as the web server | ||
# gem 'unicorn' | ||
|
||
# Deploy with Capistrano | ||
# gem 'capistrano' | ||
|
||
# To use debugger | ||
# gem 'ruby-debug' | ||
|
||
# Bundle the extra gems: | ||
# gem 'bj' | ||
# gem 'nokogiri', '1.4.1' | ||
# gem 'sqlite3-ruby', :require => 'sqlite3' | ||
# gem 'aws-s3', :require => 'aws/s3' | ||
|
||
# Bundle gems for the local environment. Make sure to | ||
# put test-only gems in this group so their generators | ||
# and rake tasks are available in development mode: | ||
# group :development, :test do | ||
# gem 'webrat' | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
abstract (1.0.0) | ||
actionmailer (3.0.0.rc) | ||
actionpack (= 3.0.0.rc) | ||
mail (~> 2.2.5) | ||
actionpack (3.0.0.rc) | ||
activemodel (= 3.0.0.rc) | ||
activesupport (= 3.0.0.rc) | ||
builder (~> 2.1.2) | ||
erubis (~> 2.6.6) | ||
i18n (~> 0.4.1) | ||
rack (~> 1.2.1) | ||
rack-mount (~> 0.6.9) | ||
rack-test (~> 0.5.4) | ||
tzinfo (~> 0.3.22) | ||
activemodel (3.0.0.rc) | ||
activesupport (= 3.0.0.rc) | ||
builder (~> 2.1.2) | ||
i18n (~> 0.4.1) | ||
activerecord (3.0.0.rc) | ||
activemodel (= 3.0.0.rc) | ||
activesupport (= 3.0.0.rc) | ||
arel (~> 0.4.0) | ||
tzinfo (~> 0.3.22) | ||
activeresource (3.0.0.rc) | ||
activemodel (= 3.0.0.rc) | ||
activesupport (= 3.0.0.rc) | ||
activesupport (3.0.0.rc) | ||
arel (0.4.0) | ||
activesupport (>= 3.0.0.beta) | ||
builder (2.1.2) | ||
erubis (2.6.6) | ||
abstract (>= 1.0.0) | ||
i18n (0.4.1) | ||
mail (2.2.5) | ||
activesupport (>= 2.3.6) | ||
mime-types | ||
treetop (>= 1.4.5) | ||
mime-types (1.16) | ||
paperclip (2.3.3) | ||
activerecord | ||
activesupport | ||
polyglot (0.3.1) | ||
rack (1.2.1) | ||
rack-mount (0.6.9) | ||
rack (>= 1.0.0) | ||
rack-test (0.5.4) | ||
rack (>= 1.0) | ||
rails (3.0.0.rc) | ||
actionmailer (= 3.0.0.rc) | ||
actionpack (= 3.0.0.rc) | ||
activerecord (= 3.0.0.rc) | ||
activeresource (= 3.0.0.rc) | ||
activesupport (= 3.0.0.rc) | ||
bundler (>= 1.0.0.rc.1) | ||
railties (= 3.0.0.rc) | ||
railties (3.0.0.rc) | ||
actionpack (= 3.0.0.rc) | ||
activesupport (= 3.0.0.rc) | ||
rake (>= 0.8.3) | ||
thor (~> 0.14.0) | ||
rake (0.8.7) | ||
sqlite3-ruby (1.3.1) | ||
thor (0.14.0) | ||
treetop (1.4.8) | ||
polyglot (>= 0.3.1) | ||
tzinfo (0.3.22) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
mime-types | ||
paperclip | ||
rails (= 3.0.0.rc) | ||
sqlite3-ruby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
= swfupload-rails-authentication | ||
|
||
Demo Rails 3.0.0.rc app showing SWFUpload working in tandem with restful-authentication, CSRF protection and paperclip. | ||
|
||
== Usage | ||
|
||
gem install bundler --pre | ||
bundle install | ||
rake db:migrate | ||
rake db:seed | ||
rails s | ||
|
||
== Login | ||
|
||
The restful authentication test user; | ||
|
||
username: quentin | ||
password: monkey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require(File.join(File.dirname(__FILE__), 'config', 'boot')) | ||
|
||
require File.expand_path('../config/application', __FILE__) | ||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
|
||
require 'tasks/rails' | ||
SwfuploadRailsAuthentication::Application.load_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,5 @@ | ||
# Filters added to this controller apply to all controllers in the application. | ||
# Likewise, all the methods added will be available for all controllers. | ||
|
||
require 'lib/authenticated_system' | ||
class ApplicationController < ActionController::Base | ||
|
||
include AuthenticatedSystem | ||
|
||
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 => 'd307747927b72d71553b39b15089e7da' | ||
|
||
# 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 | ||
|
||
end | ||
protect_from_forgery | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
# Methods added to this helper will be available to all templates in the application. | ||
module ApplicationHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module AssetsHelper | ||
def new_asset_path_with_session_information | ||
session_key = ActionController::Base.session_options[:key] | ||
session_key = Rails.application.config.session_options[:key] | ||
assets_path(session_key => cookies[session_key], request_forgery_protection_token => form_authenticity_token) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
require 'mime/types' | ||
|
||
class Asset < ActiveRecord::Base | ||
|
||
# Relationships | ||
|
||
belongs_to :user | ||
|
||
has_attached_file :image, | ||
:styles => {:thumb => "150x150#"}, | ||
:whiny_thumbnails => true, | ||
:url => "/asset_images/:style/:basename.:extension", | ||
:path => ":rails_root/public/asset_images/:style/:basename.:extension" | ||
|
||
has_attachment :storage => :file_system, | ||
:max_size => 5.megabytes, | ||
:resize_to => '800x600>', | ||
:thumbnails => { :thumb => '150x150>' }, | ||
:processor => :MiniMagick | ||
|
||
|
||
# Validations | ||
validates_as_attachment | ||
validates_attachment_content_type :image, | ||
:content_type => ['image/jpeg', 'image/pjpeg', 'image/jpg', 'image/tiff', 'image/tif'], | ||
:message => 'Picture must be a jpeg, tif or pdf file type' | ||
validates_attachment_size :image, :in => 1..26.megabyte | ||
|
||
# | ||
named_scope :masters, :conditions => {:parent_id => nil} | ||
attr_protected :image_file_name, :image_content_type, :image_size | ||
|
||
|
||
# Map file extensions to mime types. | ||
# Thanks to bug in Flash 8 the content type is always set to application/octet-stream. | ||
# From: http://blog.airbladesoftware.com/2007/8/8/uploading-files-with-swfupload | ||
def swf_uploaded_data=(data) | ||
data.content_type = MIME::Types.type_for(data.original_filename) | ||
self.uploaded_data = data | ||
self.image = data | ||
end | ||
|
||
end |
Oops, something went wrong.