spree_multi_slideshow 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  SpreeMultiSlideshow
2
2
  ===================
3
3
 
4
- Add multiple slideshow for Spree Commerce Shop
4
+ Add multiple slideshow for Spree Commerce Shop [compatible with Amazon S3]
5
5
 
6
6
 
7
7
  Basic Installation
@@ -9,7 +9,7 @@ Basic Installation
9
9
 
10
10
  1. Add the following to your Gemfile
11
11
  <pre>
12
- gem 'spree_multi_slideshow', '~> 1.0.0'
12
+ gem 'spree_multi_slideshow', '~> 1.0.1'
13
13
  </pre>
14
14
  2. Run `bundle install`
15
15
  3. To copy and apply migrations run:
@@ -1,28 +1,28 @@
1
1
  module Spree
2
2
  module Admin
3
3
  class SlidesController < ResourceController
4
- before_filter :load_data
5
-
6
- def load_data
7
- @slideshow_type = Spree::SlideshowType.find(params[:slideshow_type_id])
8
- end
9
-
4
+ before_filter :load_data, :only => [:index, :new, :show, :edit]
5
+
10
6
  def update_positions
11
7
  params[:positions].each do |id, index|
12
8
  Spree::Slide.update_all(['position=?', index], ['id=?', id])
13
9
  end
14
10
 
15
11
  respond_to do |format|
16
- format.html { redirect_to admin_slideshow_type_slides_url(params[:slideshow_type_id]) }
12
+ format.html { redirect_to admin_slideshow_type_slides_url(@slideshow_type) }
17
13
  format.js { render :text => 'Ok' }
18
14
  end
19
15
  end
20
16
 
21
- private
17
+ protected
22
18
 
23
19
  def location_after_save
24
20
  admin_slideshow_type_slides_url(@slideshow_type)
25
21
  end
22
+
23
+ def load_data
24
+ @slideshow_type = Spree::SlideshowType.find(params[:slideshow_type_id].to_i)
25
+ end
26
26
 
27
27
  end
28
28
  end
@@ -23,7 +23,7 @@ module Spree
23
23
  slides = Spree::Slide.where("slideshow_type_id = ?", slideshow.first.id).limit(max).sort_by { |slide| slide.position }
24
24
 
25
25
  slides.map do |slide|
26
- content_tag(:li, raw(link_to(image_tag(slide.image.url(style.to_sym)), slide.url, { :title => slide.title })) + raw(content_tag(:div, content_tag(:strong, raw(slide.title)) + content_tag(:p, raw(slide.content)), :class => "text-holder")))
26
+ content_tag(:li, raw(link_to(image_tag(slide.attachment.url(style.to_sym)), slide.url, { :title => slide.title })) + raw(content_tag(:div, content_tag(:strong, raw(slide.title)) + content_tag(:p, raw(slide.content)), :class => "text-holder")))
27
27
  end.join
28
28
  else
29
29
  false
@@ -1,19 +1,20 @@
1
1
  module Spree
2
2
  class Slide < ActiveRecord::Base
3
-
4
- has_many :slideshow_types
3
+
4
+ belongs_to :slideshow_type
5
5
  validates_presence_of :slideshow_type_id
6
-
7
- has_attached_file :image,
6
+
7
+ attr_accessor :attachment_width, :attachment_height
8
+
9
+ has_attached_file :attachment,
8
10
  :url => "/spree/slides/:id/:style_:basename.:extension",
9
11
  :path => ":rails_root/public/spree/slides/:id/:style_:basename.:extension",
10
- #:default_url => "/missing/:style.jpg",
11
12
  :styles => {
12
13
  :thumbnail => "100x33#",
13
14
  :small => "300x100#",
14
15
  :medium => "600x200#",
15
16
  :slide => "900x300#",
16
- :custom => Proc.new { |instance| "#{SlideshowType.find(instance.slideshow_type_id).slide_width}x#{SlideshowType.find(instance.slideshow_type_id).slide_height}#" }
17
+ :custom => lambda {|instance| "#{instance.attachment_width}x#{instance.attachment_height}#"}
17
18
  },
18
19
  :convert_options => {
19
20
  :thumbnail => "-gravity center",
@@ -21,10 +22,31 @@ module Spree
21
22
  :medium => "-gravity center",
22
23
  :slide => "-gravity center",
23
24
  :custom => "-gravity center"
24
- }
25
-
25
+ }
26
+
26
27
  #process_in_background :image UTILE MA OCCORRE ATTIVARE ANCHE LA GEMMA DELAYED-PAPERCLIP
27
-
28
+
29
+ # Load S3 settings
30
+ if (!YAML.load_file(Rails.root.join('config', 's3.yml'))[Rails.env].blank?)
31
+ S3_OPTIONS = {
32
+ :storage => 's3',
33
+ :s3_credentials => Rails.root.join('config', 's3.yml')
34
+ }
35
+ elsif (!ENV['S3_KEY'].blank? && !ENV['S3_SECRET'].blank? && !ENV['S3_BUCKET'].blank?)
36
+ S3_OPTIONS = {
37
+ :storage => 's3',
38
+ :s3_credentials => {
39
+ :access_key_id => ENV['S3_KEY'],
40
+ :secret_access_key => ENV['S3_SECRET']
41
+ },
42
+ :bucket => ENV['S3_BUCKET']
43
+ }
44
+ else
45
+ S3_OPTIONS = { :storage => 'filesystem' }
46
+ end
47
+
48
+ attachment_definitions[:attachment] = (attachment_definitions[:attachment] || {}).merge(S3_OPTIONS)
49
+
28
50
  def initialize(*args)
29
51
  super(*args)
30
52
  last_slide = Slide.last
@@ -1,7 +1,7 @@
1
1
  module Spree
2
2
  class SlideshowType < ActiveRecord::Base
3
3
 
4
- belongs_to :slide
4
+ has_many :slides
5
5
 
6
6
  validates :slide_number, :slide_width, :slide_height, :presence => true
7
7
  validates_uniqueness_of :category
@@ -1,7 +1,9 @@
1
1
  <%= f.inputs do %>
2
2
  <%= f.input :title %>
3
3
  <%= f.input :url %>
4
+ <%= f.input :attachment_width, :input_html => { :value => @slideshow_type.slide_width}, :as => :hidden %>
5
+ <%= f.input :attachment_height, :input_html => { :value => @slideshow_type.slide_height}, :as => :hidden %>
4
6
  <%= f.cktext_area :content, :input_html => { :value => @slide.content }, :label => t("slideshow_type.slide.content") %>
5
- <%= f.input :image, :as => :file, :label => I18n.t("slideshow_type.slide.image.one").capitalize, :hint => f.object.image.blank? ? f.template.content_tag(:span, "No Image Yet") : f.template.image_tag(f.object.image.url(:thumbnail)) %>
7
+ <%= f.input :attachment, :as => :file, :label => I18n.t("slideshow_type.slide.image.one").capitalize, :hint => f.object.attachment.blank? ? f.template.content_tag(:span, "No Image Yet") : f.template.image_tag(f.object.attachment.url(:thumbnail)) %>
6
8
  <%= f.input :slideshow_type_id, :as => :hidden, :value => params[:slideshow_type_id] %>
7
9
  <% end %>
@@ -6,7 +6,7 @@
6
6
  <table class="basic-table" data-hook="edit_image">
7
7
  <tr data-hook="thumbnail">
8
8
  <td><%= t(:thumbnail) %>:</td>
9
- <td><%= link_to image_tag(@slide.image.url(:small)), @slide.image.url(:medium) %></td>
9
+ <td><%= link_to image_tag(@slide.attachment.url(:small)), @slide.attachment.url(:medium) %></td>
10
10
  </tr>
11
11
  <%= render :partial => 'form', :locals => { :f => f } %>
12
12
  </table>
@@ -19,7 +19,7 @@
19
19
  <tr id="<%= dom_id(slide) %>" data-hook="images_row">
20
20
  <td>
21
21
  <span class="handle"></span>
22
- <%= link_to image_tag(slide.image.url(:thumbnail)), slide.image.url(:medium) %>
22
+ <%= link_to image_tag(slide.attachment.url(:thumbnail)), slide.attachment.url(:medium) %>
23
23
  </td>
24
24
  <td><%= slide.title %></td>
25
25
  <td><%= slide.position %></td>
@@ -2,11 +2,11 @@ class CreateSlideshowTypes < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :slideshow_types do |t|
4
4
  t.string :category
5
- t.boolean :enabled, :default => 0
5
+ t.boolean :enabled, :default => false
6
6
  t.integer :slide_height, :default => 400
7
7
  t.integer :slide_width, :default => 900
8
8
  t.integer :slide_number, :default => 4
9
- t.boolean :enable_navigation, :default => 1
9
+ t.boolean :enable_navigation, :default => true
10
10
 
11
11
  t.timestamps
12
12
  end
@@ -4,9 +4,9 @@ class CreateSlides < ActiveRecord::Migration
4
4
  t.string :title, :url
5
5
  t.text :content
6
6
 
7
- t.string :image_content_type, :image_file_name, :image_content_type
8
- t.datetime :image_updated_at
9
- t.integer :image_size, :position
7
+ t.string :attachment_content_type, :attachment_file_name, :attachment_content_type
8
+ t.datetime :attachment_updated_at
9
+ t.integer :attachment_size, :position
10
10
  t.string :type, :limit => 75
11
11
 
12
12
  t.references :slideshow_type
metadata CHANGED
@@ -1,121 +1,99 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: spree_multi_slideshow
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 0
10
- version: 1.0.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Damiano Giacomello
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-03-28 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-04-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: spree_core
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70353872815020 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
32
22
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
23
+ prerelease: false
24
+ version_requirements: *70353872815020
25
+ - !ruby/object:Gem::Dependency
35
26
  name: spree_auth
27
+ requirement: &70353872812420 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
36
34
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
35
+ version_requirements: *70353872812420
36
+ - !ruby/object:Gem::Dependency
37
+ name: aws-sdk
38
+ requirement: &70353872810580 !ruby/object:Gem::Requirement
38
39
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.3.4
46
44
  type: :runtime
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: formtastic
50
45
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
46
+ version_requirements: *70353872810580
47
+ - !ruby/object:Gem::Dependency
48
+ name: formtastic
49
+ requirement: &70353872810040 !ruby/object:Gem::Requirement
52
50
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
60
55
  type: :runtime
61
- version_requirements: *id003
62
- - !ruby/object:Gem::Dependency
63
- name: paperclip
64
56
  prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
57
+ version_requirements: *70353872810040
58
+ - !ruby/object:Gem::Dependency
59
+ name: paperclip
60
+ requirement: &70353872809440 !ruby/object:Gem::Requirement
66
61
  none: false
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- hash: 27
71
- segments:
72
- - 2
73
- - 5
74
- - 0
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
75
65
  version: 2.5.0
76
66
  type: :runtime
77
- version_requirements: *id004
78
- - !ruby/object:Gem::Dependency
79
- name: ckeditor
80
67
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
68
+ version_requirements: *70353872809440
69
+ - !ruby/object:Gem::Dependency
70
+ name: ckeditor
71
+ requirement: &70353872808520 !ruby/object:Gem::Requirement
82
72
  none: false
83
- requirements:
84
- - - "="
85
- - !ruby/object:Gem::Version
86
- hash: 15424003
87
- segments:
88
- - 3
89
- - 7
90
- - 0
91
- - rc
92
- - 3
73
+ requirements:
74
+ - - =
75
+ - !ruby/object:Gem::Version
93
76
  version: 3.7.0.rc3
94
77
  type: :runtime
95
- version_requirements: *id005
96
- - !ruby/object:Gem::Dependency
97
- name: rspec-rails
98
78
  prerelease: false
99
- requirement: &id006 !ruby/object:Gem::Requirement
79
+ version_requirements: *70353872808520
80
+ - !ruby/object:Gem::Dependency
81
+ name: rspec-rails
82
+ requirement: &70353872808020 !ruby/object:Gem::Requirement
100
83
  none: false
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- hash: 3
105
- segments:
106
- - 0
107
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
108
88
  type: :development
109
- version_requirements: *id006
89
+ prerelease: false
90
+ version_requirements: *70353872808020
110
91
  description:
111
92
  email: damiano.giacomello@diginess.it
112
93
  executables: []
113
-
114
94
  extensions: []
115
-
116
95
  extra_rdoc_files: []
117
-
118
- files:
96
+ files:
119
97
  - README.md
120
98
  - LICENSE
121
99
  - lib/generators/spree_multi_slideshow/install/install_generator.rb
@@ -156,33 +134,23 @@ files:
156
134
  - config/routes.rb
157
135
  homepage:
158
136
  licenses: []
159
-
160
137
  post_install_message:
161
138
  rdoc_options: []
162
-
163
- require_paths:
139
+ require_paths:
164
140
  - lib
165
- required_ruby_version: !ruby/object:Gem::Requirement
141
+ required_ruby_version: !ruby/object:Gem::Requirement
166
142
  none: false
167
- requirements:
168
- - - ">="
169
- - !ruby/object:Gem::Version
170
- hash: 57
171
- segments:
172
- - 1
173
- - 8
174
- - 7
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
175
146
  version: 1.8.7
176
- required_rubygems_version: !ruby/object:Gem::Requirement
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
148
  none: false
178
- requirements:
179
- - - ">="
180
- - !ruby/object:Gem::Version
181
- hash: 3
182
- segments:
183
- - 0
184
- version: "0"
185
- requirements:
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements:
186
154
  - none
187
155
  rubyforge_project:
188
156
  rubygems_version: 1.8.10
@@ -190,4 +158,3 @@ signing_key:
190
158
  specification_version: 3
191
159
  summary: Extension to manage multi slideshow for Spree Shop
192
160
  test_files: []
193
-