testing out the lastest gems for rails / carrierwave / ...etc
This commit is contained in:
parent
fdfa36838b
commit
49080b737d
15
Gemfile
15
Gemfile
@ -4,26 +4,29 @@ source :rubygems
|
||||
|
||||
gem 'rake', '0.8.7'
|
||||
|
||||
gem 'rails', '>= 3.0.7'
|
||||
gem 'rails', '>= 3.0.8'
|
||||
|
||||
gem 'warden'
|
||||
gem 'devise', '= 1.1.3'
|
||||
gem 'devise', '1.3.4'
|
||||
|
||||
gem 'mongoid', '~> 2.0.2'
|
||||
gem 'bson_ext', '~> 1.3.0'
|
||||
gem 'locomotive_mongoid_acts_as_tree', '0.1.5.7', :require => 'mongoid_acts_as_tree'
|
||||
gem 'will_paginate'
|
||||
|
||||
gem 'haml', '3.0.25'
|
||||
gem 'haml', '3.1.2'
|
||||
gem 'sass', '3.1.2'
|
||||
gem 'locomotive_liquid', '2.2.2', :require => 'liquid'
|
||||
gem 'formtastic', '~> 1.2.3'
|
||||
gem 'inherited_resources', '~> 1.1.2'
|
||||
|
||||
gem 'rmagick', '2.12.2'
|
||||
gem 'locomotive_carrierwave', '0.5.0.1.beta3', :require => 'carrierwave'
|
||||
gem 'carrierwave', :path => '../gems/carrierwave_did'
|
||||
# gem 'locomotive_carrierwave', '0.5.0.1.beta3', :require => 'carrierwave'
|
||||
|
||||
gem 'custom_fields', '1.0.0.beta.15'
|
||||
gem 'fog', '0.3.7'
|
||||
# gem 'custom_fields', '1.0.0.beta.15'
|
||||
gem 'custom_fields', '1.0.0.beta.15', :path => '../gems/custom_fields'
|
||||
gem 'fog', '0.8.2'
|
||||
gem 'mimetype-fu'
|
||||
gem 'actionmailer-with-request', :require => 'actionmailer_with_request'
|
||||
gem 'heroku', '1.19.1'
|
||||
|
113
Gemfile.lock
113
Gemfile.lock
@ -18,6 +18,19 @@ GIT
|
||||
xpath (0.1.2)
|
||||
nokogiri (~> 1.4)
|
||||
|
||||
PATH
|
||||
remote: ../gems/carrierwave_did
|
||||
specs:
|
||||
carrierwave (0.5.4)
|
||||
activesupport (~> 3.0)
|
||||
|
||||
PATH
|
||||
remote: ../gems/custom_fields
|
||||
specs:
|
||||
custom_fields (1.0.0.beta.15)
|
||||
activesupport (>= 3.0.7)
|
||||
mongoid (= 2.0.2)
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
@ -29,14 +42,14 @@ GEM
|
||||
SystemTimer (1.2.3)
|
||||
ZenTest (4.5.0)
|
||||
abstract (1.0.0)
|
||||
actionmailer (3.0.7)
|
||||
actionpack (= 3.0.7)
|
||||
mail (~> 2.2.15)
|
||||
actionmailer (3.0.8)
|
||||
actionpack (= 3.0.8)
|
||||
mail (~> 2.2.19)
|
||||
actionmailer-with-request (0.3.0)
|
||||
rails (>= 3)
|
||||
actionpack (3.0.7)
|
||||
activemodel (= 3.0.7)
|
||||
activesupport (= 3.0.7)
|
||||
actionpack (3.0.8)
|
||||
activemodel (= 3.0.8)
|
||||
activesupport (= 3.0.8)
|
||||
builder (~> 2.1.2)
|
||||
erubis (~> 2.6.6)
|
||||
i18n (~> 0.5.0)
|
||||
@ -44,19 +57,19 @@ GEM
|
||||
rack-mount (~> 0.6.14)
|
||||
rack-test (~> 0.5.7)
|
||||
tzinfo (~> 0.3.23)
|
||||
activemodel (3.0.7)
|
||||
activesupport (= 3.0.7)
|
||||
activemodel (3.0.8)
|
||||
activesupport (= 3.0.8)
|
||||
builder (~> 2.1.2)
|
||||
i18n (~> 0.5.0)
|
||||
activerecord (3.0.7)
|
||||
activemodel (= 3.0.7)
|
||||
activesupport (= 3.0.7)
|
||||
arel (~> 2.0.2)
|
||||
activerecord (3.0.8)
|
||||
activemodel (= 3.0.8)
|
||||
activesupport (= 3.0.8)
|
||||
arel (~> 2.0.10)
|
||||
tzinfo (~> 0.3.23)
|
||||
activeresource (3.0.7)
|
||||
activemodel (= 3.0.7)
|
||||
activesupport (= 3.0.7)
|
||||
activesupport (3.0.7)
|
||||
activeresource (3.0.8)
|
||||
activemodel (= 3.0.8)
|
||||
activesupport (= 3.0.8)
|
||||
activesupport (3.0.8)
|
||||
archive-tar-minitar (0.5.2)
|
||||
arel (2.0.10)
|
||||
autotest (4.4.6)
|
||||
@ -93,10 +106,6 @@ GEM
|
||||
cucumber-rails (0.3.2)
|
||||
cucumber (>= 0.8.0)
|
||||
culerity (0.2.15)
|
||||
custom_fields (1.0.0.beta.15)
|
||||
activesupport (>= 3.0.7)
|
||||
locomotive_carrierwave
|
||||
mongoid (= 2.0.2)
|
||||
daemons (1.1.3)
|
||||
database_cleaner (0.6.7)
|
||||
delayed_job (2.1.4)
|
||||
@ -105,9 +114,10 @@ GEM
|
||||
delayed_job_mongoid (1.0.2)
|
||||
delayed_job (~> 2.1.1)
|
||||
mongoid (~> 2.0.0.rc)
|
||||
devise (1.1.3)
|
||||
devise (1.3.4)
|
||||
bcrypt-ruby (~> 2.1.2)
|
||||
warden (~> 0.10.7)
|
||||
orm_adapter (~> 0.0.3)
|
||||
warden (~> 1.0.3)
|
||||
diff-lcs (1.1.2)
|
||||
erubis (2.6.6)
|
||||
abstract (>= 1.0.0)
|
||||
@ -117,14 +127,14 @@ GEM
|
||||
factory_girl (~> 1.3)
|
||||
railties (>= 3.0.0)
|
||||
ffi (1.0.9)
|
||||
fog (0.3.7)
|
||||
fog (0.8.2)
|
||||
builder
|
||||
excon (>= 0.2.3)
|
||||
formatador (>= 0.0.15)
|
||||
excon (~> 0.6.1)
|
||||
formatador (>= 0.1.3)
|
||||
json
|
||||
mime-types
|
||||
net-ssh (~> 2.0.23)
|
||||
nokogiri (~> 1.4.3.1)
|
||||
net-ssh (>= 2.1.3)
|
||||
nokogiri (>= 1.4.4)
|
||||
ruby-hmac
|
||||
formatador (0.1.4)
|
||||
formtastic (1.2.4)
|
||||
@ -134,12 +144,12 @@ GEM
|
||||
gherkin (2.1.5)
|
||||
trollop (~> 1.16.2)
|
||||
growl-glue (1.0.7)
|
||||
haml (3.0.25)
|
||||
haml (3.1.2)
|
||||
has_scope (0.5.0)
|
||||
heroku (1.19.1)
|
||||
activesupport (>= 2.1.0)
|
||||
launchy (~> 0.3.2)
|
||||
rest-client (>= 1.4.0, < 1.7.0)
|
||||
rest-client (< 1.7.0, >= 1.4.0)
|
||||
highline (1.6.2)
|
||||
httparty (0.7.8)
|
||||
crack (= 0.1.8)
|
||||
@ -158,8 +168,6 @@ GEM
|
||||
linecache (0.43)
|
||||
linecache19 (0.5.12)
|
||||
ruby_core_source (>= 0.1.4)
|
||||
locomotive_carrierwave (0.5.0.1.beta3)
|
||||
activesupport (~> 3.0)
|
||||
locomotive_jammit-s3 (0.5.4.4)
|
||||
jammit (>= 0.5.4)
|
||||
mimemagic (>= 0.1.7)
|
||||
@ -181,9 +189,10 @@ GEM
|
||||
activemodel (~> 3.0)
|
||||
mongo (~> 1.3)
|
||||
tzinfo (~> 0.3.22)
|
||||
net-ssh (2.0.24)
|
||||
nokogiri (1.4.3.1)
|
||||
net-ssh (2.1.4)
|
||||
nokogiri (1.4.4)
|
||||
open4 (1.0.1)
|
||||
orm_adapter (0.0.5)
|
||||
pickle (0.4.7)
|
||||
cucumber (>= 0.8)
|
||||
rake
|
||||
@ -194,17 +203,17 @@ GEM
|
||||
rack (>= 1.0.0)
|
||||
rack-test (0.5.7)
|
||||
rack (>= 1.0)
|
||||
rails (3.0.7)
|
||||
actionmailer (= 3.0.7)
|
||||
actionpack (= 3.0.7)
|
||||
activerecord (= 3.0.7)
|
||||
activeresource (= 3.0.7)
|
||||
activesupport (= 3.0.7)
|
||||
rails (3.0.8)
|
||||
actionmailer (= 3.0.8)
|
||||
actionpack (= 3.0.8)
|
||||
activerecord (= 3.0.8)
|
||||
activeresource (= 3.0.8)
|
||||
activesupport (= 3.0.8)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.0.7)
|
||||
railties (3.0.7)
|
||||
actionpack (= 3.0.7)
|
||||
activesupport (= 3.0.7)
|
||||
railties (= 3.0.8)
|
||||
railties (3.0.8)
|
||||
actionpack (= 3.0.8)
|
||||
activesupport (= 3.0.8)
|
||||
rake (>= 0.8.7)
|
||||
thor (~> 0.14.4)
|
||||
rake (0.8.7)
|
||||
@ -244,6 +253,7 @@ GEM
|
||||
rubyzip (0.9.4)
|
||||
s3 (0.3.8)
|
||||
proxies (~> 0.2.0)
|
||||
sass (3.1.2)
|
||||
selenium-webdriver (0.2.1)
|
||||
childprocess (>= 0.1.7)
|
||||
ffi (>= 1.0.7)
|
||||
@ -259,8 +269,8 @@ GEM
|
||||
unicorn (3.6.2)
|
||||
kgio (~> 2.3)
|
||||
rack
|
||||
warden (0.10.7)
|
||||
rack (>= 1.0.0)
|
||||
warden (1.0.4)
|
||||
rack (>= 1.0)
|
||||
will_paginate (2.3.15)
|
||||
yui-compressor (0.9.6)
|
||||
POpen4 (>= 0.1.4)
|
||||
@ -278,23 +288,23 @@ DEPENDENCIES
|
||||
bushido
|
||||
bushido_stub!
|
||||
capybara
|
||||
carrierwave!
|
||||
cucumber (= 0.8.5)
|
||||
cucumber-rails
|
||||
custom_fields (= 1.0.0.beta.15)
|
||||
custom_fields (= 1.0.0.beta.15)!
|
||||
database_cleaner
|
||||
delayed_job (= 2.1.4)
|
||||
delayed_job_mongoid (= 1.0.2)
|
||||
devise (= 1.1.3)
|
||||
devise (= 1.3.4)
|
||||
factory_girl_rails
|
||||
fog (= 0.3.7)
|
||||
fog (= 0.8.2)
|
||||
formtastic (~> 1.2.3)
|
||||
growl-glue
|
||||
haml (= 3.0.25)
|
||||
haml (= 3.1.2)
|
||||
heroku (= 1.19.1)
|
||||
httparty (>= 0.6.1)
|
||||
inherited_resources (~> 1.1.2)
|
||||
launchy
|
||||
locomotive_carrierwave (= 0.5.0.1.beta3)
|
||||
locomotive_jammit-s3
|
||||
locomotive_liquid (= 2.2.2)
|
||||
locomotive_mongoid_acts_as_tree (= 0.1.5.7)
|
||||
@ -302,13 +312,14 @@ DEPENDENCIES
|
||||
mocha!
|
||||
mongoid (~> 2.0.2)
|
||||
pickle
|
||||
rails (>= 3.0.7)
|
||||
rails (>= 3.0.8)
|
||||
rake (= 0.8.7)
|
||||
rmagick (= 2.12.2)
|
||||
rspec-rails (= 2.3.1)
|
||||
ruby-debug
|
||||
ruby-debug19
|
||||
rubyzip
|
||||
sass (= 3.1.2)
|
||||
spork
|
||||
unicorn
|
||||
warden
|
||||
|
@ -3,10 +3,7 @@
|
||||
class AssetUploader < CarrierWave::Uploader::Base
|
||||
|
||||
include CarrierWave::RMagick
|
||||
|
||||
def store_dir
|
||||
self.build_store_dir('sites', model.collection.site_id, 'assets', model.id)
|
||||
end
|
||||
include Locomotive::CarrierWave::Uploader::Asset
|
||||
|
||||
version :thumb, :if => :image? do
|
||||
process :resize_to_fill => [50, 50]
|
||||
@ -23,51 +20,58 @@ class AssetUploader < CarrierWave::Uploader::Base
|
||||
process :convert => 'png'
|
||||
end
|
||||
|
||||
process :set_content_type
|
||||
process :set_size
|
||||
process :set_width_and_height
|
||||
|
||||
def set_content_type(*args)
|
||||
value = :other
|
||||
|
||||
content_type = file.content_type == 'application/octet-stream' ? File.mime_type?(original_filename) : file.content_type
|
||||
|
||||
self.class.content_types.each_pair do |type, rules|
|
||||
rules.each do |rule|
|
||||
case rule
|
||||
when String then value = type if content_type == rule
|
||||
when Regexp then value = type if (content_type =~ rule) == 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
model.content_type = value
|
||||
def store_dir
|
||||
# puts "model = #{model.inspect}"
|
||||
# puts "collection = #{model.collection.inspect}"
|
||||
# puts "====="
|
||||
self.build_store_dir('sites', model.collection.site_id, 'assets', model.id)
|
||||
end
|
||||
|
||||
def set_size(*args)
|
||||
model.size = file.size
|
||||
end
|
||||
# process :set_content_type
|
||||
# process :set_size
|
||||
# process :set_width_and_height
|
||||
#
|
||||
# def set_content_type(*args)
|
||||
# value = :other
|
||||
#
|
||||
# content_type = file.content_type == 'application/octet-stream' ? File.mime_type?(original_filename) : file.content_type
|
||||
#
|
||||
# self.class.content_types.each_pair do |type, rules|
|
||||
# rules.each do |rule|
|
||||
# case rule
|
||||
# when String then value = type if content_type == rule
|
||||
# when Regexp then value = type if (content_type =~ rule) == 0
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# model.content_type = value
|
||||
# end
|
||||
|
||||
def set_width_and_height
|
||||
if model.image?
|
||||
magick = ::Magick::Image.read(current_path).first
|
||||
model.width, model.height = magick.columns, magick.rows
|
||||
end
|
||||
end
|
||||
# def set_size(*args)
|
||||
# model.size = file.size
|
||||
# end
|
||||
#
|
||||
# def set_width_and_height
|
||||
# if model.image?
|
||||
# magick = ::Magick::Image.read(current_path).first
|
||||
# model.width, model.height = magick.columns, magick.rows
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def image?(file)
|
||||
# model.image?
|
||||
# end
|
||||
|
||||
def image?
|
||||
model.image?
|
||||
end
|
||||
|
||||
def self.content_types
|
||||
{
|
||||
:image => ['image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg', 'image/x-icon'],
|
||||
:media => [/^video/, 'application/x-shockwave-flash', 'application/x-swf', /^audio/, 'application/ogg', 'application/x-mp3'],
|
||||
:pdf => ['application/pdf', 'application/x-pdf'],
|
||||
:stylesheet => ['text/css'],
|
||||
:javascript => ['text/javascript', 'text/js', 'application/x-javascript', 'application/javascript'],
|
||||
:font => ['application/x-font-ttf', 'application/vnd.ms-fontobject', 'image/svg+xml', 'application/x-woff']
|
||||
}
|
||||
end
|
||||
# def self.content_types
|
||||
# {
|
||||
# :image => ['image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg', 'image/x-icon'],
|
||||
# :media => [/^video/, 'application/x-shockwave-flash', 'application/x-swf', /^audio/, 'application/ogg', 'application/x-mp3'],
|
||||
# :pdf => ['application/pdf', 'application/x-pdf'],
|
||||
# :stylesheet => ['text/css'],
|
||||
# :javascript => ['text/javascript', 'text/js', 'application/x-javascript', 'application/javascript'],
|
||||
# :font => ['application/x-font-ttf', 'application/vnd.ms-fontobject', 'image/svg+xml', 'application/x-woff']
|
||||
# }
|
||||
# end
|
||||
|
||||
end
|
||||
|
@ -4,8 +4,4 @@ class EditableFileUploader < ::CarrierWave::Uploader::Base
|
||||
self.build_store_dir('sites', model.page.site_id, 'pages', model.page.id, 'files')
|
||||
end
|
||||
|
||||
# def cache_dir
|
||||
# "#{Rails.root}/tmp/uploads"
|
||||
# end
|
||||
|
||||
end
|
@ -1,18 +1,21 @@
|
||||
# encoding: utf-8
|
||||
|
||||
class ThemeAssetUploader < AssetUploader
|
||||
class ThemeAssetUploader < CarrierWave::Uploader::Base
|
||||
|
||||
process :set_content_type
|
||||
process :set_size
|
||||
process :set_width_and_height
|
||||
include Locomotive::CarrierWave::Uploader::Asset
|
||||
|
||||
# process :set_content_type
|
||||
# process :set_size
|
||||
# process :set_width_and_height
|
||||
|
||||
def store_dir
|
||||
self.build_store_dir('sites', (model.site_id_was || model.site_id).to_s, 'theme', model.folder_was || model.folder)
|
||||
# self.build_store_dir('sites', (model.site_id_was || model.site_id).to_s, 'theme', model.folder_was || model.folder)
|
||||
self.build_store_dir('sites', model.site_id, 'theme', model.folder)
|
||||
end
|
||||
|
||||
def stale_model?
|
||||
!model.new_record? && model.folder_changed?
|
||||
end
|
||||
# def stale_model?
|
||||
# !model.new_record? && model.folder_changed?
|
||||
# end
|
||||
|
||||
def extension_white_list
|
||||
%w(jpg jpeg gif png css js swf flv eot svg ttf woff otf ico)
|
||||
|
@ -1,5 +1,6 @@
|
||||
require 'carrierwave/orm/mongoid'
|
||||
require 'locomotive/carrierwave/base'
|
||||
# require 'locomotive/carrierwave/base'
|
||||
require 'locomotive/carrierwave/asset'
|
||||
require 'locomotive/carrierwave/patches'
|
||||
|
||||
# register missing mime types
|
||||
|
@ -99,11 +99,11 @@ module Locomotive
|
||||
uploader.download!(zipfile)
|
||||
uploader.store!
|
||||
else
|
||||
file = CarrierWave::SanitizedFile.new(zipfile)
|
||||
file = ::CarrierWave::SanitizedFile.new(zipfile)
|
||||
uploader.store!(file)
|
||||
end
|
||||
uploader.identifier
|
||||
rescue CarrierWave::IntegrityError
|
||||
rescue ::CarrierWave::IntegrityError
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user