bhf 0.7.15 → 0.7.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 932f7d8d57a82dcf9d1c785d1be981f72b707a11
4
- data.tar.gz: 5ab00950684b143db5555fc4c818169eedb0ee42
3
+ metadata.gz: 29fb186c6102a0cb1b84f5513b67e5a669bcab2a
4
+ data.tar.gz: 8ce8a99cfd1a2397d981b5e8162ff9f2bc226e7a
5
5
  SHA512:
6
- metadata.gz: 046a8e067945c9123c4a06ab185b2426bceb8b33b98ab7792da4ecf9985c4a0951a5d3422454e6769890111b03d44c1d432ec0a9354f7f5948a13d056daa5c75
7
- data.tar.gz: 88f0a7dfbb47bd1f63062f02c752a684f0918a07a7d16eacce924cd4c36086699f750bf253a01a2d082343646bb358f9fa5a64f60cc23f3976cdf8bef97f4c7d
6
+ metadata.gz: c20a468692b5edba95a704aef66b930b381611caf152efc7c0b1455537ba7a1171e8da04e4ec8e38862e67e5d34d2fd2d076854ac999b27c8cb7e11ae8157f7a
7
+ data.tar.gz: 7312dbc5e72879cd9fa38053e58854568901d3b50959fc3eccc9076b04e882280f214f60ec27010855cff8f824bb8173fd066bcb3fdcd7d1c0556bfcac68eee2
@@ -31,5 +31,9 @@ module Bhf
31
31
  end
32
32
  end
33
33
 
34
+ def type_is_image?(type)
35
+ Bhf::PAPERCLIP_IMAGE_TYPES.include?(type)
36
+ end
37
+
34
38
  end
35
39
  end
@@ -16,10 +16,6 @@ module Bhf
16
16
  }
17
17
  end
18
18
 
19
- def is_image?(file)
20
- ! file.match(/\.png|\.jpg|\.jpeg|\.gif|\.svg/i).nil?
21
- end
22
-
23
19
  def reflection_title(f, field)
24
20
  title = f.object.class.human_attribute_name(field.reflection.name)
25
21
  if field.link
@@ -3,10 +3,10 @@
3
3
  = node f, field do
4
4
  - file = f.object.send(field.name)
5
5
  - if file.file?
6
- - if ['image/jpeg', 'image/pjpeg', 'image/jpg', 'image/png', 'image/tif', 'image/gif'].include?(f.object.send("#{field.name}_content_type"))
6
+ - if type_is_image?(file.content_type)
7
7
  = image_tag find_smallest_size_url_for_file(file), class: 'uploaded_image'
8
8
  - else
9
- = link_to f.object.send("#{field.name}_file_name"), file.url, class: 'uploaded_file'
9
+ = link_to file.original_filename, file.url, class: 'uploaded_file'
10
10
 
11
11
  - if f.object.respond_to?(:"#{field.name}_destroy")
12
12
  .file_delete
@@ -1,5 +1,6 @@
1
1
  - unless object.send(column.name).blank?
2
- - if ['image/jpeg', 'image/pjpeg', 'image/jpg', 'image/png', 'image/tif', 'image/gif'].include?(object.send("#{column.name}_content_type"))
3
- = image_tag object.send(column.name), alt: object.send(column.name), class: 'preview_image'
2
+ - file = object.send(column.name)
3
+ - if type_is_image?(file.content_type)
4
+ = image_tag find_smallest_size_url_for_file(file), alt: object.send(column.name), class: 'preview_image'
4
5
  - else
5
- = link_to object.send("#{column.name}_file_name"), object.send(column.name).url
6
+ = file.original_filename
data/lib/bhf.rb CHANGED
@@ -44,4 +44,5 @@ module Bhf
44
44
  end
45
45
  end
46
46
  end
47
+ PAPERCLIP_IMAGE_TYPES = ['image/jpeg', 'image/pjpeg', 'image/jpg', 'image/png', 'image/tif', 'image/gif']
47
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bhf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.15
4
+ version: 0.7.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Pawlik