unveil-rails 0.1.0 → 0.2.0

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: 11ac877c26c44d8716fcd650f8539357e06f94a3
4
- data.tar.gz: 803b516ad64838c23968b555167e01d90830c81a
3
+ metadata.gz: 54f93550291407b2f15222f3ae4dd458d2f726c8
4
+ data.tar.gz: fdc41bff5a571597264d1af293201f637e0594ac
5
5
  SHA512:
6
- metadata.gz: 68f73d490a9ad2603714f43a39274d5a53f07e2cb6db0d16f337cc782bd6da229890fa6ecc6dc867aff0054364813ce36931ff0541c692224ce08653af99591b
7
- data.tar.gz: 1ada1b0cdb1497d1c196723253f817c356c026b7bcde1a330bc209981b0e2c9d2394b3b2e2f6b4412b6758c02c90d80fc5483a27ce855db5f690320447ed38b2
6
+ metadata.gz: a82c646a4272422ccfecd354e8ad57449588d122e3220958dd6075dcf9b738d4bf1a393ae621cfae148ac50fe3e43608b264701c1f5ab06919fd7be3411c7704
7
+ data.tar.gz: 9762a3d277cd0d1c4383922aaa9f1b6c798df033a3aa1b56925c61820021f4305354ecc3d508c0acc00c2d3cd7951bbbb0d4a12da295ca2b551189057fb38550
data/README.md CHANGED
@@ -1,28 +1,32 @@
1
1
  # Unveil.js for Rails
2
2
 
3
- This gem will help you get started with unveil.js rather quickly.
3
+ Lazy loaded images on rails. If you want a quick start using
4
+ [unveil.js][unveil-github] with rails there is now a gem for that.
5
+
6
+ By loading your images as they appear in the viewport rather than on load you
7
+ can improve your rails application's page speed.
4
8
 
5
9
  ## Installation
6
10
 
7
- Add the gem:
11
+ Add the unveil-rails gem into your `Gemfile`:
8
12
 
9
13
  ``` ruby
10
14
  gem 'unveil-rails', '~> 0.1.0'
11
15
  ```
12
16
 
13
- Install the assets:
17
+ Install unveil.js and initializer into your rails app:
14
18
 
15
19
  ```
16
20
  bin/rails g unveil:rails:install
17
21
  ```
18
22
 
19
- Include the asset in your JS:
23
+ Include the unveil.js initializer in `app/assets/javascripts/application.js`:
20
24
 
21
25
  ``` js
22
26
  //= require unveil_init
23
27
  ```
24
28
 
25
- Now use the helper method whereever you want lazy images:
29
+ Now use the helper method where ever you want lazy images:
26
30
 
27
31
  ```erb
28
32
  <%= lazy_image_tag('an-image.png') %>
@@ -66,6 +70,8 @@ Developed and maintained by [Made Tech][made]. Key contributions:
66
70
 
67
71
  * [Luke Morton](https://github.com/DrPheltRight)
68
72
 
73
+ And of course [Luís Almeida][luis-github] creator of [unveil.js][unveil-github].
74
+
69
75
  ## License
70
76
 
71
77
  Copyright © 2014 Made Tech Ltd. It is free software, and may be
@@ -75,3 +81,4 @@ redistributed under the terms specified in the [LICENSE][license] file.
75
81
  [license]: https://github.com/madebymade/cf-deploy/blob/master/LICENSE
76
82
  [unveil-github]: https://github.com/luis-almeida/unveil
77
83
  [unveil-docs]: http://luis-almeida.github.io/unveil/
84
+ [luis-github]: https://github.com/luis-almeida
@@ -1,5 +1,5 @@
1
1
  module Unveil
2
2
  class Rails
3
- VERSION='0.1.0'
3
+ VERSION='0.2.0'
4
4
  end
5
5
  end
@@ -3,9 +3,9 @@ module Unveil
3
3
  module ViewHelper
4
4
  def lazy_image_tag(source, options = {})
5
5
  placeholder_source = options[:placeholder] || Unveil::Rails.config.default_placeholder
6
+ options[:alt] = options[:alt] || image_alt(source)
6
7
 
7
- lazy_options = options.merge('data-src' => image_path(source),
8
- alt: image_alt(source))
8
+ lazy_options = options.merge('data-src' => image_path(source))
9
9
 
10
10
  if options.has_key?(:retina)
11
11
  lazy_options['data-src-retina'] = image_path(options[:retina])
@@ -18,9 +18,9 @@ describe Unveil::Rails::ViewHelper do
18
18
 
19
19
  let(:expected_html) do
20
20
  <<-HTML
21
- <img src="/blank.gif" data-src="/my-image.png" />
21
+ <img src="/blank.gif" alt="my-image.png" data-src="/my-image.png" />
22
22
  <noscript>
23
- <img src="/my-image.png" />
23
+ <img src="/my-image.png" alt="my-image.png" />
24
24
  </noscript>
25
25
  HTML
26
26
  end
@@ -33,9 +33,9 @@ describe Unveil::Rails::ViewHelper do
33
33
 
34
34
  let(:expected_html) do
35
35
  <<-HTML
36
- <img src="/place.gif" data-src="/my-image.png" />
36
+ <img src="/place.gif" alt="my-image.png" data-src="/my-image.png" />
37
37
  <noscript>
38
- <img src="/my-image.png" />
38
+ <img src="/my-image.png" alt="my-image.png" />
39
39
  </noscript>
40
40
  HTML
41
41
  end
@@ -48,9 +48,24 @@ describe Unveil::Rails::ViewHelper do
48
48
 
49
49
  let(:expected_html) do
50
50
  <<-HTML
51
- <img src="/blank.gif" data-src="/my-image.png" data-src-retina="/my-retina-image.png" />
51
+ <img src="/blank.gif" alt="my-image.png" data-src="/my-image.png" data-src-retina="/my-retina-image.png" />
52
52
  <noscript>
53
- <img src="/my-image.png" />
53
+ <img src="/my-image.png" alt="my-image.png" />
54
+ </noscript>
55
+ HTML
56
+ end
57
+
58
+ it { is_expected.to eq(expected_html.strip) }
59
+ end
60
+
61
+ context 'when alt text provided' do
62
+ let(:options) { { alt: 'Alt text' } }
63
+
64
+ let(:expected_html) do
65
+ <<-HTML
66
+ <img src="/blank.gif" alt="Alt text" data-src="/my-image.png" />
67
+ <noscript>
68
+ <img src="/my-image.png" alt="Alt text" />
54
69
  </noscript>
55
70
  HTML
56
71
  end
@@ -11,6 +11,7 @@ class ContextMock
11
11
 
12
12
  def image_tag(source, options = {})
13
13
  options_html = ''
14
+ options_html << " alt=\"#{options[:alt]}\"" if options[:alt]
14
15
  options_html << " data-src=\"#{options['data-src']}\"" if options['data-src']
15
16
  options_html << " data-src-retina=\"#{options['data-src-retina']}\"" if options['data-src-retina']
16
17
  "<img src=\"#{image_path(source)}\"#{options_html} />"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unveil-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Morton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-04 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -91,9 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.2.2
94
+ rubygems_version: 2.4.5
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Lazy loaded images for rails
98
98
  test_files: []
99
- has_rdoc: