spree_banner 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/app/helpers/spree/banners_helper.rb +1 -1
- data/app/models/spree/banner.rb +29 -32
- metadata +2 -2
data/app/models/spree/banner.rb
CHANGED
@@ -5,13 +5,13 @@ module Spree
|
|
5
5
|
has_attached_file :attachment,
|
6
6
|
:url => "/spree/banner/:id/:style_:basename.:extension",
|
7
7
|
:path => ":rails_root/public/spree/banner/:id/:style_:basename.:extension",
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
},
|
8
|
+
:styles => lambda {|a| {
|
9
|
+
:thumbnail => "80x80#",
|
10
|
+
:custom => "#{a.instance.attachment_width}x#{a.instance.attachment_height}#"
|
11
|
+
}},
|
13
12
|
:convert_options => {
|
14
|
-
|
13
|
+
:thumbnail => "-gravity center",
|
14
|
+
:custom => "-gravity center"
|
15
15
|
}
|
16
16
|
|
17
17
|
after_post_process :find_dimensions
|
@@ -22,27 +22,22 @@ module Spree
|
|
22
22
|
|
23
23
|
scope :enable, lambda { |category| {:conditions => {:enabled => true, :category => category}} }
|
24
24
|
|
25
|
-
# Load
|
26
|
-
if
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
:storage => 's3',
|
34
|
-
:s3_credentials => {
|
35
|
-
:access_key_id => ENV['S3_KEY'],
|
36
|
-
:secret_access_key => ENV['S3_SECRET']
|
37
|
-
},
|
38
|
-
:bucket => ENV['S3_BUCKET']
|
39
|
-
}
|
40
|
-
else
|
41
|
-
S3_OPTIONS = { :storage => 'filesystem' }
|
25
|
+
# Load user defined paperclip settings
|
26
|
+
if Spree::Config[:use_s3]
|
27
|
+
s3_creds = { :access_key_id => Spree::Config[:s3_access_key], :secret_access_key => Spree::Config[:s3_secret], :bucket => Spree::Config[:s3_bucket] }
|
28
|
+
Spree::Banner.attachment_definitions[:attachment][:storage] = :s3
|
29
|
+
Spree::Banner.attachment_definitions[:attachment][:s3_credentials] = s3_creds
|
30
|
+
Spree::Banner.attachment_definitions[:attachment][:s3_headers] = ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
|
31
|
+
Spree::Banner.attachment_definitions[:attachment][:bucket] = Spree::Config[:s3_bucket]
|
32
|
+
Spree::Banner.attachment_definitions[:attachment][:s3_protocol] = Spree::Config[:s3_protocol] unless Spree::Config[:s3_protocol].blank?
|
42
33
|
end
|
43
|
-
|
44
|
-
attachment_definitions[:attachment] = (
|
45
|
-
|
34
|
+
|
35
|
+
Spree::Banner.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:attachment_styles])
|
36
|
+
Spree::Banner.attachment_definitions[:attachment][:path] = Spree::Config[:attachment_path]
|
37
|
+
Spree::Banner.attachment_definitions[:attachment][:url] = Spree::Config[:attachment_url]
|
38
|
+
Spree::Banner.attachment_definitions[:attachment][:default_url] = Spree::Config[:attachment_default_url]
|
39
|
+
Spree::Banner.attachment_definitions[:attachment][:default_style] = Spree::Config[:attachment_default_style]
|
40
|
+
|
46
41
|
def initialize(*args)
|
47
42
|
super(*args)
|
48
43
|
last_banner = Banner.last
|
@@ -50,12 +45,14 @@ module Spree
|
|
50
45
|
end
|
51
46
|
|
52
47
|
def find_dimensions
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
48
|
+
if self.attachment_width.blank? && self.attachment_height.blank?
|
49
|
+
temporary = attachment.queued_for_write[:original]
|
50
|
+
filename = temporary.path unless temporary.nil?
|
51
|
+
filename = attachment.path if filename.blank?
|
52
|
+
geometry = Paperclip::Geometry.from_file(filename)
|
53
|
+
self.attachment_width = geometry.width
|
54
|
+
self.attachment_height = geometry.height
|
55
|
+
end
|
59
56
|
end
|
60
57
|
|
61
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_banner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_core
|