refactor the asset collections part + disable the image processing for non image assets (use a newer version of locomotive carrierwave for that purpose)

This commit is contained in:
did 2011-03-05 23:27:26 +01:00
parent 7d5018eedc
commit d3abdd3f37
212 changed files with 93 additions and 48 deletions

View File

@ -18,8 +18,9 @@ gem 'formtastic', '~> 1.2.3'
gem 'inherited_resources', '~> 1.1.2'
gem 'rmagick', '2.12.2'
gem 'locomotive_carrierwave', '0.5.0.1.beta2', :require => 'carrierwave'
# gem 'locomotive_carrierwave', '0.5.0.1.beta2', :require => 'carrierwave'
# gem 'carrierwave', :path => '/Users/didier/Desktop/carrierwave'
gem 'locomotive_carrierwave', :path => '../gems/carrierwave', :require => 'carrierwave'
# gem 'custom_fields', '1.0.0.beta.4'
gem 'custom_fields', :path => '../gems/custom_fields'

View File

@ -4,6 +4,12 @@ GIT
specs:
mocha (0.9.12.20110213002255)
PATH
remote: ../gems/carrierwave
specs:
locomotive_carrierwave (0.5.0.1.beta3)
activesupport (~> 3.0)
PATH
remote: ../gems/custom_fields
specs:
@ -118,10 +124,10 @@ GEM
growl-glue (1.0.7)
haml (3.0.25)
has_scope (0.5.0)
heroku (1.18.0)
json (~> 1.5.1)
launchy (~> 0.3.2)
rest-client (>= 1.4.0, < 1.7.0)
heroku (1.6.3)
json (>= 1.1.0)
launchy (>= 0.3.2)
rest-client (>= 1.2.0, < 2.0.0)
httparty (0.7.4)
crack (= 0.1.8)
i18n (0.5.0)
@ -134,14 +140,12 @@ GEM
json (1.5.1)
json_pure (1.4.6)
kgio (2.3.2)
launchy (0.3.7)
launchy (0.4.0)
configuration (>= 0.0.5)
rake (>= 0.8.1)
linecache (0.43)
linecache19 (0.5.11)
ruby_core_source (>= 0.1.4)
locomotive_carrierwave (0.5.0.1.beta2)
activesupport (~> 3.0)
locomotive_jammit-s3 (0.5.4.4)
jammit (>= 0.5.4)
mimemagic (>= 0.1.7)
@ -277,7 +281,7 @@ DEPENDENCIES
httparty (>= 0.6.1)
inherited_resources (~> 1.1.2)
launchy
locomotive_carrierwave (= 0.5.0.1.beta2)
locomotive_carrierwave!
locomotive_jammit-s3
locomotive_liquid (= 2.2.2)
locomotive_mongoid_acts_as_tree (= 0.1.5.5)

View File

@ -1,7 +1,15 @@
module Admin::AssetsHelper
def vignette_tag(asset)
image_tag(asset.vignette_url)
if asset.image?
html, css = image_tag(asset.vignette_url), 'image'
else
css = "icon #{asset.content_type}"
html = asset.content_type.to_s == 'other' ? truncate(asset.extname, :length => 3) : asset.content_type
html = '?' if html.blank?
end
content_tag(:div, content_tag(:div, html, :class => 'inside'), :class => css)
end
def image_dimensions_and_size(asset)

View File

@ -32,6 +32,11 @@ class Asset
end
end
def extname
return nil unless self.source?
File.extname(self.source_filename).gsub(/^\./, '')
end
def site_id # needed by the uploader of custom fields
self.collection.site_id
end

View File

@ -10,32 +10,9 @@ module Models
else
self.source.url(:medium)
end
# elsif asset.pdf?
# image_tag(asset.source.url(:medium))
else
mime_type_to_url(:medium)
end
end
protected
def mime_type_to_url(size)
mime_type = File.mime_type?(self.source_filename)
filename = "unknown"
if !(mime_type =~ /pdf/).nil?
filename = "PDF"
elsif !(mime_type =~ /css/).nil?
filename = "CSS"
elsif !(mime_type =~ /javascript/).nil?
filename = "JAVA"
elsif !(mime_type =~ /font/).nil?
filename = "FON"
end
File.join("admin", "icons", "filetype", size.to_s, filename + ".png")
end
end
end
end

View File

@ -12,17 +12,17 @@ class AssetUploader < CarrierWave::Uploader::Base
"#{Rails.root}/tmp/uploads"
end
version :thumb do
version :thumb, :if => :image? do
process :resize_to_fill => [50, 50]
process :convert => 'png'
end
version :medium do
version :medium, :if => :image? do
process :resize_to_fill => [80, 80]
process :convert => 'png'
end
version :preview do
version :preview, :if => :image? do
process :resize_to_fit => [880, 1100]
process :convert => 'png'
end
@ -58,6 +58,10 @@ class AssetUploader < CarrierWave::Uploader::Base
end
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'],

View File

@ -1,7 +1,5 @@
%li{ :id => "asset-#{asset.id}", :class => "asset #{'last' if (asset_counter + 1) % 6 == 0}"}
%h4= link_to truncate(asset.name, :length => 22), edit_admin_asset_path(@asset_collection, asset)
.image
.inside
= vignette_tag(asset)
%h4= link_to truncate(asset.name, :length => 17), edit_admin_asset_path(@asset_collection, asset)
= vignette_tag(asset)
.actions
= link_to image_tag('admin/list/icons/cross.png'), '#', :class => 'remove', :confirm => t('admin.messages.confirm')

View File

@ -4,7 +4,7 @@
= f.inputs :name => :information do
= f.input :name
= f.input :source
= f.input :source, :hint => preserve(t("formtastic.hints.asset.#{action_name}.source", :url => link_to(@asset.source_filename, @asset.source.url)))
- unless @asset.custom_fields.blank?
= render 'admin/custom_fields/custom_form', :form => f, :title => :other_fields, :parent => @asset_collection

View File

@ -63,6 +63,11 @@ fr:
plain_text_name: "Vous n'avez pas besoin de mettre l'extension du fichier (.css ou .js)"
edit:
source: "Vous pouvez le remplacer par un fichier avec la meme extension."
asset:
new:
source: "Tous les types de fichier sont acceptés."
edit:
source: "Le fichier actuel est accessible ici %{url}"
custom_fields:
field:
_alias: "Champ utilisable dans les templates liquid"

View File

@ -6,7 +6,7 @@ x password / new_password
x custom_fields not deleted (doesn't use index anymore)
? editable_elements slug becomes nil
- editable_elements not updated (doesn't use index anymore)
- uploading videos http://groups.google.com/group/carrierwave/browse_thread/thread/6e211d98f1ff4bc0/51717c2167695ca2?lnk=gst&q=version#51717c2167695ca2
x uploading videos http://groups.google.com/group/carrierwave/browse_thread/thread/6e211d98f1ff4bc0/51717c2167695ca2?lnk=gst&q=version#51717c2167695ca2
- editable_elements: inheritable: false (Mattias)
- duostack version
- 2 different sites on the same main domain (one in www, the other one in something else) (Raphael Costa)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Some files were not shown because too many files have changed in this diff Show More