holder_rails 2.3.2 → 2.9.3.1

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
- SHA1:
3
- metadata.gz: 9d4c5391864aeeb4e04e5b8f0b467ca61cca8358
4
- data.tar.gz: d179ff86cc9c397770b216fbcddf9f0d9d42637b
2
+ SHA256:
3
+ metadata.gz: 1647e82904f852a88dd02b8b37054e7126413bffb0a399d14d39695f8ff850cc
4
+ data.tar.gz: 7b7fef0ae9ead9b12a94045e3f9e2275fa771871c85507efc9ced740a4978fb3
5
5
  SHA512:
6
- metadata.gz: fe0699d0b3d113166e4f3e2a4a0a363b1a44780959493b760ae776aceb8448ca5224752f37d39acbc4a619dc85ae309ff277a82cd5486943a1091df9c192e830
7
- data.tar.gz: 5951359b06cf9e48bd39d7a8eb276514a5d60db3c4b37994e2b6c4c4fd387cb3f1374beb6e9921e29246ff9863a07e078f5244604e9d6fccacc333bde644e7c3
6
+ metadata.gz: 99ce5d45ef4f2886b5b67d1698491e854d53b9e619ca7c461dc7a699396f1d83572f6bf93a7a458055002f2ae79010b608e32a767d0ec5cece8ea5d391731706
7
+ data.tar.gz: c72be02418a324043ebeb739d46a3bcfc196c7fb2353834f50272aefe22ec663dc7db88622f0f516f9cd72c5a8786f8d04cfed1fb9f6b8adc485b629c84ea5d0
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-2014 Nihad Abbasov <mail@narkoz.me>
1
+ Copyright (c) 2012-2019 Nihad Abbasov <nihad@42na.in>
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Holder.js for Rails
2
2
 
3
- [![Build Status](https://travis-ci.org/NARKOZ/holder_rails.png)](https://travis-ci.org/NARKOZ/holder_rails)
4
- [![Gem Version](https://fury-badge.herokuapp.com/rb/holder_rails.png)](http://badge.fury.io/rb/holder_rails)
3
+ [![Build Status](https://img.shields.io/travis/NARKOZ/holder_rails.svg)](https://travis-ci.org/NARKOZ/holder_rails)
4
+ [![Gem Version](https://img.shields.io/gem/v/holder_rails.svg)](https://rubygems.org/gems/holder_rails)
5
5
 
6
6
  Provides Holder.js to render image placeholders entirely on the client side.
7
7
 
@@ -27,7 +27,7 @@ Add to your JavaScript manifest file:
27
27
  //= require holder
28
28
  ```
29
29
 
30
- And if you're using [turbolinks](https://github.com/rails/turbolinks)
30
+ For versions **less than 2.3.2**, if you're using [turbolinks](https://github.com/rails/turbolinks)
31
31
  don't forget to run `Holder` after `page:change` event:
32
32
 
33
33
  ```coffee
@@ -39,19 +39,22 @@ You can use `holder_tag` helper in your views:
39
39
 
40
40
  ```ruby
41
41
  holder_tag 100
42
- # => <img data-src="holder.js/100x100/text:100x100/" src="" />
42
+ # => <img data-src="holder.js/100x100?" src="" />
43
43
 
44
44
  holder_tag '200x300'
45
- # => <img data-src="holder.js/200x300/text:200x300/" src="" />
45
+ # => <img data-src="holder.js/200x300?" src="" />
46
46
 
47
47
  holder_tag '200x300', 'Lorem ipsum'
48
- # => <img data-src="holder.js/200x300/text:Lorem ipsum/" src="" />
48
+ # => <img data-src="holder.js/200x300?text=Lorem ipsum" src="" />
49
49
 
50
50
  holder_tag '200x300', 'Lorem ipsum', 'social'
51
- # => <img data-src="holder.js/200x300/text:Lorem ipsum/social" src="" />
51
+ # => <img data-src="holder.js/200x300?text=Lorem ipsum&amp;theme=social" src="" />
52
52
 
53
- holder_tag '500x800', 'Example text', 'gray', :id => 'new', :class => 'special'
54
- # => <img class="special" data-src="holder.js/500x800/text:Example text/gray" id="new" src="" />
53
+ holder_tag '500x800', 'Example text', 'gray', id: 'new', class: 'special'
54
+ # => <img class="special" data-src="holder.js/500x800?text=Example text&amp;theme=gray" id="new" src="" />
55
+
56
+ holder_tag '500x800', 'Example text', 'gray', { id: 'new', class: 'special' }, { font: 'Helvetica' }
57
+ # => <img class="special" data-src="holder.js/500x800?font=Helvetica&amp;text=Example text&amp;theme=gray" id="new" src="" />
55
58
  ```
56
59
 
57
60
  For more information, check out [holder readme](https://github.com/imsky/holder#readme).
data/holder_rails.gemspec CHANGED
@@ -7,9 +7,9 @@ Gem::Specification.new do |gem|
7
7
  gem.name = "holder_rails"
8
8
  gem.version = HolderRails::VERSION
9
9
  gem.authors = ["Nihad Abbasov"]
10
- gem.email = ["mail@narkoz.me"]
10
+ gem.email = ["nihad@42na.in"]
11
11
  gem.description = %q{Provides Holder.js to render image placeholders entirely on the client side}
12
- gem.summary = %q{Holder.js for Rails 3.1 asset pipeline}
12
+ gem.summary = %q{Holder.js for Rails asset pipeline}
13
13
  gem.homepage = "https://github.com/narkoz/holder_rails"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
@@ -1,9 +1,13 @@
1
1
  module HolderRails
2
2
  module Helpers
3
- def holder_tag(size, text='', theme=nil, html_options={})
4
- size = "#{size}x#{size}" unless size =~ /\A\d+%?x\d+\z/
5
- text = text.to_s.empty? ? size : text
6
- options = {:src => '', :data => {:src => "holder.js/#{size}/text:#{text}/#{theme}"}}
3
+ def holder_tag(size, text='', theme=nil, html_options={}, holder_options={})
4
+ size = "#{size}x#{size}" unless size =~ /\A\d+p?x\d+\z/
5
+
6
+ holder_options[:text] = text unless text.to_s.empty?
7
+ holder_options[:theme] = theme unless theme.nil?
8
+ holder_options = holder_options.map {|e| e.join('=') }.join('&')
9
+
10
+ options = { src: '', data: { src: "holder.js/#{size}?#{holder_options}" }}
7
11
  options = options.merge(html_options)
8
12
 
9
13
  tag :img, options
@@ -1,3 +1,3 @@
1
1
  module HolderRails
2
- VERSION = "2.3.2"
2
+ VERSION = "2.9.3.1"
3
3
  end
@@ -1,25 +1,30 @@
1
1
  require 'holder_rails'
2
- require 'test/unit'
2
+ require 'minitest/autorun'
3
3
 
4
4
  class HolderRailsTest < ActionView::TestCase
5
5
  include HolderRails::Helpers
6
6
 
7
7
  test "size" do
8
- assert_equal '<img data-src="holder.js/100x100/text:100x100/" src="" />', holder_tag(100)
9
- assert_equal '<img data-src="holder.js/200x300/text:200x300/" src="" />', holder_tag('200x300')
10
- assert_equal '<img data-src="holder.js/100%x75/text:100%x75/" src="" />', holder_tag('100%x75')
8
+ assert_dom_equal '<img data-src="holder.js/100x100?" src="" />', holder_tag(100)
9
+ assert_dom_equal '<img data-src="holder.js/200x300?" src="" />', holder_tag('200x300')
10
+ assert_dom_equal '<img data-src="holder.js/100px75?" src="" />', holder_tag('100px75')
11
11
  end
12
12
 
13
13
  test "text" do
14
- assert_equal '<img data-src="holder.js/200x300/text:Lorem ipsum/" src="" />', holder_tag('200x300', 'Lorem ipsum')
14
+ assert_dom_equal '<img data-src="holder.js/200x300?text=Lorem ipsum" src="" />', holder_tag('200x300', 'Lorem ipsum')
15
15
  end
16
16
 
17
17
  test "theme" do
18
- assert_equal '<img data-src="holder.js/200x300/text:Lorem ipsum/social" src="" />', holder_tag('200x300', 'Lorem ipsum', 'social')
18
+ assert_dom_equal '<img data-src="holder.js/200x300?text=Lorem ipsum&amp;theme=social" src="" />', holder_tag('200x300', 'Lorem ipsum', 'social')
19
19
  end
20
20
 
21
21
  test "html_options" do
22
- assert_equal '<img class="special" data-src="holder.js/500x800/text:Example text/gray" id="new" src="" />',
23
- holder_tag('500x800', 'Example text', 'gray', :id => 'new', :class => 'special')
22
+ assert_dom_equal '<img class="special" data-src="holder.js/500x800?text=Example text&amp;theme=gray" id="new" src="" />',
23
+ holder_tag('500x800', 'Example text', 'gray', id: 'new', class: 'special')
24
+ end
25
+
26
+ test "holder_options" do
27
+ assert_dom_equal '<img class="special" data-src="holder.js/500x800?font=Helvetica&amp;text=Example text&amp;theme=gray" id="new" src="" />',
28
+ holder_tag('500x800', 'Example text', 'gray', { id: 'new', class: 'special' }, { font: 'Helvetica' })
24
29
  end
25
30
  end