middleman-img_loading_attribute 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/features/auto.feature +1 -1
- data/features/eager.feature +1 -1
- data/features/lazy.feature +1 -1
- data/features/pre.feature +8 -0
- data/fixtures/pre-app/config.rb +4 -0
- data/fixtures/pre-app/source/images/1x1.png +0 -0
- data/fixtures/pre-app/source/index.html.erb +3 -0
- data/fixtures/pre-app/source/layout.erb +9 -0
- data/lib/middleman-img_loading_attribute/extension.rb +8 -3
- data/middleman-img_loading_attribute.gemspec +2 -1
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b46196a12d807e6c73c452f1dbf7d30908812da618887a8f91850aa8b10acfe1
|
4
|
+
data.tar.gz: a7a1b6b95869837b24be3707f930f3473c37cb1f7e482d7a8a0f63f00d586862
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0737929e356fb843a5925701cd1794f8de59638e9ad8ec36198cfb74659b81c83c7b3ab7f3c421301750373e08441e3a5d166dd93606a6079196387d62bd7df0'
|
7
|
+
data.tar.gz: c9789e0e0f46fbe4a355efb663c84619f0f6fc1ace1e5c13111814cdc7af81a7bb62aa6543e2ef35c84cfeda292eb0dcedce3354298c7ae2594bf8a485a9d627
|
data/CHANGELOG.md
CHANGED
data/features/auto.feature
CHANGED
data/features/eager.feature
CHANGED
data/features/lazy.feature
CHANGED
Binary file
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Require core library
|
2
2
|
require 'middleman-core'
|
3
|
+
require 'nokogiri'
|
3
4
|
|
4
5
|
class Middleman::ImgLoadingAttribute < ::Middleman::Extension
|
5
6
|
option :loading, 'auto', 'A value of "loading" attribute in <img> tag'
|
@@ -22,10 +23,14 @@ class Middleman::ImgLoadingAttribute < ::Middleman::Extension
|
|
22
23
|
def after_build(builder)
|
23
24
|
files = Dir.glob(File.join(app.config[:build_dir], "**", "*.html"))
|
24
25
|
files.each do |file|
|
25
|
-
|
26
|
-
|
26
|
+
doc = Nokogiri::HTML(File.read(file))
|
27
|
+
doc.css('img').each do |elem|
|
28
|
+
next if elem.path.include?('pre') || elem.path.include?('code') || elem.path.include?('blockquote')
|
29
|
+
|
30
|
+
elem['loading'] = options[:loading]
|
31
|
+
end
|
27
32
|
File.open(file, 'w') do |f|
|
28
|
-
f.write
|
33
|
+
f.write doc.to_html
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "middleman-img_loading_attribute"
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.3.0"
|
6
6
|
s.platform = Gem::Platform::RUBY
|
7
7
|
s.authors = ["Yusuke Nakamura"]
|
8
8
|
s.email = ['yusuke1994525@gmail.com']
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
# The version of middleman-core your extension depends on
|
20
20
|
s.add_runtime_dependency("middleman-core")
|
21
21
|
s.add_runtime_dependency("middleman-cli")
|
22
|
+
s.add_runtime_dependency("nokogiri")
|
22
23
|
|
23
24
|
# Additional dependencies
|
24
25
|
# s.add_runtime_dependency("gem-name", "gem-version")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-img_loading_attribute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yusuke Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Specify "loading" attribute value to generated HTML from middleman
|
42
56
|
email:
|
43
57
|
- yusuke1994525@gmail.com
|
@@ -59,6 +73,7 @@ files:
|
|
59
73
|
- features/auto.feature
|
60
74
|
- features/eager.feature
|
61
75
|
- features/lazy.feature
|
76
|
+
- features/pre.feature
|
62
77
|
- features/step_definitions/builder_steps.rb
|
63
78
|
- features/support/env.rb
|
64
79
|
- fixtures/auto-app/config.rb
|
@@ -72,6 +87,10 @@ files:
|
|
72
87
|
- fixtures/lazy-app/source/images/1x1.png
|
73
88
|
- fixtures/lazy-app/source/index.html.erb
|
74
89
|
- fixtures/lazy-app/source/layout.erb
|
90
|
+
- fixtures/pre-app/config.rb
|
91
|
+
- fixtures/pre-app/source/images/1x1.png
|
92
|
+
- fixtures/pre-app/source/index.html.erb
|
93
|
+
- fixtures/pre-app/source/layout.erb
|
75
94
|
- lib/middleman-img_loading_attribute.rb
|
76
95
|
- lib/middleman-img_loading_attribute/extension.rb
|
77
96
|
- middleman-img_loading_attribute.gemspec
|
@@ -102,5 +121,6 @@ test_files:
|
|
102
121
|
- features/auto.feature
|
103
122
|
- features/eager.feature
|
104
123
|
- features/lazy.feature
|
124
|
+
- features/pre.feature
|
105
125
|
- features/step_definitions/builder_steps.rb
|
106
126
|
- features/support/env.rb
|