brightcontent-attachments 2.0.7 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  .bundle/
2
2
  log/*.log
3
3
  pkg/
4
+ spec/dummy/public/system
4
5
  spec/dummy/db/migrate/*.brightcontent.rb
5
6
  spec/dummy/db/*.sqlite3
6
7
  spec/dummy/log/*.log
data/Gemfile.lock CHANGED
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brightcontent-attachments (2.0.7)
5
- brightcontent-core (= 2.0.7)
4
+ brightcontent-attachments (2.0.8)
5
+ brightcontent-core (= 2.0.8)
6
6
  jquery-fileupload-rails
7
7
  paperclip
8
8
 
9
9
  PATH
10
10
  remote: ../core
11
11
  specs:
12
- brightcontent-core (2.0.7)
12
+ brightcontent-core (2.0.8)
13
13
  bcrypt-ruby
14
14
  bootstrap-wysihtml5-rails
15
15
  has_scope
@@ -3,9 +3,26 @@ module Brightcontent
3
3
  attr_accessible :attachable_id, :attachable_type, :asset
4
4
 
5
5
  belongs_to :attachable, polymorphic: true
6
- has_attached_file :asset
6
+ has_attached_file :asset, styles: ->(a){ a.instance.attachment_styles }
7
7
  delegate :url, to: :asset
8
8
 
9
9
  validates :asset, attachment_presence: true
10
+
11
+ def attachment_styles
12
+ user_defined_styles.merge(default_attachment_styles)
13
+ end
14
+
15
+ private
16
+
17
+ def user_defined_styles
18
+ if attachable && attachable.respond_to?(:attachment_styles)
19
+ attachable.attachment_styles
20
+ end || {}
21
+ end
22
+
23
+ def default_attachment_styles
24
+ { brightcontent: "100x100#" }
25
+ end
26
+
10
27
  end
11
28
  end
@@ -1,3 +1,3 @@
1
1
  <% @attachments.each do |attachment| %>
2
- <%= image_tag attachment.url %>
2
+ <%= image_tag attachment.url(:brightcontent) %>
3
3
  <% end %>
@@ -1,15 +1,20 @@
1
- <% if item.persisted? %>
2
- <div id="attachments">
3
- <% item.attachments.each do |attachment| %>
4
- <%= image_tag attachment.url %>
5
- <% end %>
6
- </div>
1
+ <div class="control-group optional">
2
+ <label class="optional control-label">Attachments</label>
3
+ <div class="controls">
4
+ <% if item.persisted? %>
5
+ <div id="attachments">
6
+ <% item.attachments.each do |attachment| %>
7
+ <%= image_tag attachment.url(:brightcontent) %>
8
+ <% end %>
9
+ </div>
7
10
 
8
- <input id="fileupload" type="file" name="asset" data-url="<%= new_attachment_path %>" multiple>
9
- <%= hidden_field_tag "attachable_id", item.id %>
10
- <%= hidden_field_tag "attachable_type", item.class.to_s %>
11
- <%= hidden_field_tag "attachable_url", attachments_path(item.class.to_s, item.id) %>
11
+ <input id="fileupload" type="file" name="asset" data-url="<%= new_attachment_path %>" multiple>
12
+ <%= hidden_field_tag "attachable_id", item.id %>
13
+ <%= hidden_field_tag "attachable_type", item.class.to_s %>
14
+ <%= hidden_field_tag "attachable_url", attachments_path(item.class.to_s, item.id) %>
12
15
 
13
- <% else %>
14
- First save to enable uploads
15
- <% end %>
16
+ <% else %>
17
+ First save to enable uploads
18
+ <% end %>
19
+ </div>
20
+ </div>
@@ -1,4 +1,8 @@
1
1
  class Blog < ActiveRecord::Base
2
2
  attr_accessible :body, :name, :featured
3
3
  include Brightcontent::Attachable
4
+
5
+ def attachment_styles
6
+ { test: "200x200" }
7
+ end
4
8
  end
@@ -2,5 +2,18 @@ require 'spec_helper'
2
2
 
3
3
  module Brightcontent
4
4
  describe Attachment do
5
+ subject(:attachment) { Attachment.new }
6
+
7
+ describe ".attachment_styles" do
8
+ context "without extra options" do
9
+ its(:attachment_styles) { should == { brightcontent: "100x100#" } }
10
+ end
11
+ context "with extra options" do
12
+ let(:blog) { build_stubbed(:blog) }
13
+ before { attachment.attachable = blog }
14
+
15
+ its(:attachment_styles) { should == { test: "200x200", brightcontent: "100x100#" } }
16
+ end
17
+ end
5
18
  end
6
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brightcontent-attachments
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7
4
+ version: 2.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 2.0.7
21
+ version: 2.0.8
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 2.0.7
29
+ version: 2.0.8
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: paperclip
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -212,9 +212,6 @@ files:
212
212
  - spec/dummy/public/system/brightcontent/assets/assets/000/000/007/original/iphone.png
213
213
  - spec/dummy/public/system/brightcontent/assets/assets/000/000/008/original/logo.png
214
214
  - spec/dummy/public/system/brightcontent/assets/assets/000/000/009/original/menu-button.png
215
- - spec/dummy/public/system/brightcontent/assets/assets/000/000/010/original/bestuur.jpg
216
- - spec/dummy/public/system/brightcontent/attachments/assets/000/000/001/original/bestuur.jpg
217
- - spec/dummy/public/system/brightcontent/attachments/assets/000/000/002/original/carousel.jpg
218
215
  - spec/dummy/public/system/brightcontent/attachments/assets/000/000/003/original/icon-socialmedia.png
219
216
  - spec/dummy/public/system/brightcontent/attachments/assets/000/000/004/original/icon-calendar.png
220
217
  - spec/dummy/public/system/brightcontent/attachments/assets/000/000/005/original/bg_direction_nav.png
@@ -239,7 +236,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
236
  version: '0'
240
237
  segments:
241
238
  - 0
242
- hash: 496967867413148045
239
+ hash: -2125101471738240797
243
240
  required_rubygems_version: !ruby/object:Gem::Requirement
244
241
  none: false
245
242
  requirements:
@@ -248,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
245
  version: '0'
249
246
  segments:
250
247
  - 0
251
- hash: 496967867413148045
248
+ hash: -2125101471738240797
252
249
  requirements: []
253
250
  rubyforge_project:
254
251
  rubygems_version: 1.8.24
@@ -303,9 +300,6 @@ test_files:
303
300
  - spec/dummy/public/system/brightcontent/assets/assets/000/000/007/original/iphone.png
304
301
  - spec/dummy/public/system/brightcontent/assets/assets/000/000/008/original/logo.png
305
302
  - spec/dummy/public/system/brightcontent/assets/assets/000/000/009/original/menu-button.png
306
- - spec/dummy/public/system/brightcontent/assets/assets/000/000/010/original/bestuur.jpg
307
- - spec/dummy/public/system/brightcontent/attachments/assets/000/000/001/original/bestuur.jpg
308
- - spec/dummy/public/system/brightcontent/attachments/assets/000/000/002/original/carousel.jpg
309
303
  - spec/dummy/public/system/brightcontent/attachments/assets/000/000/003/original/icon-socialmedia.png
310
304
  - spec/dummy/public/system/brightcontent/attachments/assets/000/000/004/original/icon-calendar.png
311
305
  - spec/dummy/public/system/brightcontent/attachments/assets/000/000/005/original/bg_direction_nav.png