beef-has_assets 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/helpers/assets_helper.rb +16 -2
- data/app/models/asset.rb +3 -3
- data/has_assets.gemspec +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
@@ -1,12 +1,26 @@
|
|
1
1
|
module AssetsHelper
|
2
2
|
|
3
3
|
def gallery(assets, size = :square)
|
4
|
-
|
4
|
+
if assets.respond_to? :images and assets.images.any?
|
5
|
+
images = assets.images
|
6
|
+
elsif assets.any?
|
7
|
+
images = assets.reject{|a| !a.content_type.starts_with?('image')}
|
8
|
+
else
|
9
|
+
return
|
10
|
+
end
|
11
|
+
images_items = images.collect { |asset| content_tag( :li, link_to(image_tag(asset.public_filename(size), :alt => asset.description), asset.public_filename, :title => asset.description, :rel => 'gallery' ) ) }
|
5
12
|
content_tag :ul, images_items.join, :class => 'gallery' unless images_items.empty?
|
6
13
|
end
|
7
14
|
|
8
15
|
def documents(assets)
|
9
|
-
|
16
|
+
if assets.respond_to? :documents and assets.documents.any?
|
17
|
+
documents = assets.documents
|
18
|
+
elsif assets.any?
|
19
|
+
documents = assets.reject{|a| a.content_type.starts_with?('image')}
|
20
|
+
else
|
21
|
+
return
|
22
|
+
end
|
23
|
+
documents_items = documents.collect { |asset| content_tag( :li, link_to("Download #{asset.filename} (#{number_to_human_size(asset.size)})", asset.public_filename, :title => asset.description ) ) }
|
10
24
|
content_tag :ul, documents_items.join, :class => 'documents' unless documents_items.empty?
|
11
25
|
end
|
12
26
|
end
|
data/app/models/asset.rb
CHANGED
@@ -8,9 +8,9 @@ class Asset < ActiveRecord::Base
|
|
8
8
|
has_many :assetings, :dependent => :delete_all
|
9
9
|
belongs_to :assetable, :polymorphic => true
|
10
10
|
|
11
|
-
named_scope :not_thumbnails, :conditions => 'parent_id IS NULL'
|
12
|
-
named_scope :images, :conditions => "content_type LIKE 'image%'"
|
13
|
-
named_scope :documents, :conditions => "content_type NOT LIKE 'image%'"
|
11
|
+
named_scope :not_thumbnails, :conditions => 'parent_id IS NULL'
|
12
|
+
named_scope :images, :conditions => "content_type LIKE 'image%'"
|
13
|
+
named_scope :documents, :conditions => "content_type NOT LIKE 'image%'"
|
14
14
|
|
15
15
|
validates_as_attachment
|
16
16
|
# validates_presence_of :description, :unless => :is_thumbnail?
|
data/has_assets.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{has_assets}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Steve England"]
|
9
|
-
s.date = %q{2009-08-
|
9
|
+
s.date = %q{2009-08-05}
|
10
10
|
s.email = %q{steve@wearebeef.co.uk}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beef-has_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve England
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-05 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|