brightcontent-attachments 2.0.15 → 2.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brightcontent-attachments (2.0.15)
5
- brightcontent-core (= 2.0.15)
4
+ brightcontent-attachments (2.0.16)
5
+ brightcontent-core (= 2.0.16)
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.15)
12
+ brightcontent-core (2.0.16)
13
13
  bcrypt-ruby
14
14
  bootstrap-wysihtml5-rails
15
15
  has_scope
@@ -4,24 +4,34 @@ module Brightcontent
4
4
 
5
5
  belongs_to :attachable, polymorphic: true
6
6
  has_attached_file :asset, :styles => lambda {|attachment| attachment.instance.attachment_styles }
7
+ before_post_process :resize_images
8
+
7
9
  delegate :url, to: :asset
8
10
 
9
11
  validates :asset, attachment_presence: true
10
12
 
11
13
  def attachment_styles
12
- user_defined_styles.merge(default_attachment_styles)
14
+ default_attachment_styles.merge(user_defined_styles)
15
+ end
16
+
17
+ def image?
18
+ asset_content_type =~ %r{^(image|(x-)?application)/(bmp|gif|jpeg|jpg|pjpeg|png|x-png)$}
13
19
  end
14
20
 
15
21
  private
16
22
 
17
23
  def user_defined_styles
18
- if attachable && attachable.respond_to?(:attachment_styles)
24
+ if attachable && attachable.respond_to?(:attachment_styles) && image?
19
25
  attachable.attachment_styles
20
26
  end || {}
21
27
  end
22
28
 
23
29
  def default_attachment_styles
24
- { brightcontent: "100x100#" }
30
+ { brightcontent: "100x100#", main: "200x200#" }
31
+ end
32
+
33
+ def resize_images
34
+ return false unless image?
25
35
  end
26
36
 
27
37
  end
@@ -1,4 +1,10 @@
1
1
  <%= div_for attachment do %>
2
- <%= image_tag attachment.url(:brightcontent) %>
3
- <%= link_to "Delete", destroy_attachment_path(attachment.id), method: :delete, confirm: "Are you sure?", class: "btn btn-danger btn-mini" %>
2
+ <% if attachment.image? %>
3
+ <%= image_tag attachment.url(:brightcontent) %>
4
+ <%= link_to "Insert", nil, class: "insert insert_image btn btn-mini", data: { insert_image: attachment.url(:main) } %>
5
+ <% else %>
6
+ <div class="attachment-file"><%= attachment.asset_file_name %></div>
7
+ <%= link_to "Insert", nil, class: "insert insert_link btn btn-mini", data: { insert_url: attachment.url(:original), insert_name: attachment.asset_file_name } %>
8
+ <% end %>
9
+ <%= link_to "Delete", destroy_attachment_path(attachment.id), method: :delete, confirm: "Are you sure?", class: "delete btn btn-danger btn-mini" %>
4
10
  <% 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.15
4
+ version: 2.0.16
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.15
21
+ version: 2.0.16
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.15
29
+ version: 2.0.16
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: paperclip
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -238,7 +238,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
238
238
  version: '0'
239
239
  segments:
240
240
  - 0
241
- hash: 4365656323654046573
241
+ hash: 2383915157100861141
242
242
  required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  none: false
244
244
  requirements:
@@ -247,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
247
  version: '0'
248
248
  segments:
249
249
  - 0
250
- hash: 4365656323654046573
250
+ hash: 2383915157100861141
251
251
  requirements: []
252
252
  rubyforge_project:
253
253
  rubygems_version: 1.8.24