jekyll-srcset-hook 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54aa1448f897d2e33593aa63b890dd225cac028cf902f95a38a1ad878ed13aa8
4
- data.tar.gz: 3391cd5b3421fe9265278422bb30e04227bd529c315a2f99807c0421521a6570
3
+ metadata.gz: 116d2a291fb3fe38c63a646ddfbfb436d224b5ffa7e57fff2db1ec1ae07b5a8b
4
+ data.tar.gz: ac685f20b098231ae56458eaba29c6fb4b636938f7c47cd221c425e6e1fe785e
5
5
  SHA512:
6
- metadata.gz: b91d045a1b60f0c6359456c0fd2d6ab597d80214fcab8ffc51e7b54b4f05cc12e47aa645fe7bc556a1846f498a95c876c978e0da338b14f8b89eee7a28a62010
7
- data.tar.gz: 69b734c68d77977c841aa833de57dde0484d3ef90876e6fe2aa011c7626ce171deade56f2b4352ae877112c5201b78d0fff6aca73a5b843dc966de78dfeabe5e
6
+ metadata.gz: babbfbae146435d55949aaa08faf033bb3fa38170764936c1debaaed9e4f0eec34533ca856926d60d5184a720b305980eecbdc6110222c49b909a47227061b68
7
+ data.tar.gz: 24df37d9b70d0d1a67cd0549542179293fcd7c3df97b792b765d17368960878932e987de6b1c72304deb57bfd2dbf38dad5381f60717d15b8d0a716c81435b34
data/.rubocop.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.0
3
+
4
+ Metrics/AbcSize:
5
+ CountRepeatedAttributes: false
3
6
 
4
7
  Style/StringLiterals:
5
8
  Enabled: true
data/Gemfile CHANGED
@@ -4,7 +4,3 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in jekyll-srcset-hook.gemspec
6
6
  gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
10
- gem "rubocop", "~> 1.21"
data/README.md CHANGED
@@ -23,7 +23,7 @@ And change them to (based on the config in `_config.yml`):
23
23
 
24
24
  ## Installation
25
25
 
26
- Add gem 'jekyll-srcset-hook' to the `jekyll_plugin` group in your `Gemfile`:
26
+ Using Bundler, add `gem 'jekyll-srcset-hook'` to the `jekyll_plugins` group in your `Gemfile`:
27
27
 
28
28
  ```
29
29
  source 'https://rubygems.org'
@@ -77,12 +77,12 @@ jekyll-srcset-hook:
77
77
 
78
78
  ## Usage
79
79
 
80
- `jekyll-srcset-hook` will not modify images with the `src` attribute which do not begin with the `url_endpoint` value so
81
- it can be used with local images or images from other sources.
80
+ `jekyll-srcset-hook` will not modify images where the `src` attribute does not begin with the `url_endpoint` value so
81
+ it can be used along with existing local images or images from other sources.
82
82
 
83
83
  ## Contributing
84
84
 
85
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-srcset-hook. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/jekyll-srcset-hook/blob/main/CODE_OF_CONDUCT.md).
85
+ Bug reports and pull requests are welcome on GitHub at https://github.com/juicy-g/jekyll-srcset-hook. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/jekyll-srcset-hook/blob/main/CODE_OF_CONDUCT.md).
86
86
 
87
87
  ## License
88
88
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module SrcsetHook
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -2,32 +2,27 @@
2
2
 
3
3
  require "nokogiri"
4
4
 
5
- module JekyllSrcsetHook
6
- @@config = {}
5
+ module Srcset
6
+ @config = {}
7
7
 
8
8
  def set_config
9
9
  proc do |site|
10
- @@config = site.config["jekyll-srcset-hook"]
10
+ @config = site.config["jekyll-srcset-hook"]
11
11
 
12
- if @@config.nil?
12
+ if @config.nil?
13
13
  Jekyll.logger.warn(
14
- "WARNING: jekyll-srcset-hook configuration is not present in _config.yml",
14
+ "WARNING: jekyll-srcset configuration is not present in _config.yml"
15
15
  )
16
16
  next
17
17
  end
18
18
 
19
- unless @@config["transformations_widths"].nil? && @@config["sizes"].nil?
19
+ unless @config["transformations_widths"].nil? && @config["sizes"].nil?
20
20
  Jekyll::Hooks.register(:posts, :post_render, &modify_post_output)
21
21
  Jekyll::Hooks.register(:pages, :post_render, &modify_page_output)
22
22
  end
23
23
 
24
- unless @@config["posts"].nil?
25
- Jekyll::Hooks.register(:posts, :post_render, &modify_post_output)
26
- end
27
-
28
- unless @@config["pages"].nil?
29
- Jekyll::Hooks.register(:pages, :post_render, &modify_page_output)
30
- end
24
+ Jekyll::Hooks.register(:posts, :post_render, &modify_post_output) unless @config["posts"].nil?
25
+ Jekyll::Hooks.register(:pages, :post_render, &modify_page_output) unless @config["pages"].nil?
31
26
  end
32
27
  end
33
28
 
@@ -38,22 +33,22 @@ module JekyllSrcsetHook
38
33
  fragment
39
34
  .xpath(".//img")
40
35
  .each do |image|
41
- if image[:src].start_with?(
42
- @@config["url_endpoint"] || @@config["posts"]["url_endpoint"],
43
- )
44
- original_image = image
45
- original_image = original_image.to_s.gsub!(">", " />")
46
-
47
- image =
48
- process_image(
49
- image,
50
- @@config["transformations_widths"] ||
51
- @@config["posts"]["transformations_widths"],
52
- @@config["sizes"] || @@config["posts"]["sizes"],
53
- )
54
-
55
- post.output.gsub!(original_image, image)
56
- end
36
+ next unless image[:src].start_with?(
37
+ @config["url_endpoint"] || @config["posts"]["url_endpoint"]
38
+ )
39
+
40
+ original_image = image
41
+ original_image = original_image.to_s.gsub!(">", " />")
42
+
43
+ image =
44
+ process_image(
45
+ image,
46
+ @config["transformations_widths"] ||
47
+ @config["posts"]["transformations_widths"],
48
+ @config["sizes"] || @config["posts"]["sizes"]
49
+ )
50
+
51
+ post.output.gsub!(original_image, image)
57
52
  end
58
53
  end
59
54
  end
@@ -66,29 +61,31 @@ module JekyllSrcsetHook
66
61
  elements.pop
67
62
 
68
63
  elements.each do |image|
69
- if image[:src].start_with?(
70
- @@config["url_endpoint"] || @@config["pages"]["url_endpoint"],
71
- )
72
- original_image = image
73
- original_image = original_image.to_s.gsub!(">", " />")
64
+ next unless image[:src].start_with?(
65
+ @config["url_endpoint"] || @config["pages"]["url_endpoint"]
66
+ )
74
67
 
75
- image =
76
- process_image(
77
- image,
78
- @@config["transformations_widths"] ||
79
- @@config["pages"]["transformations_widths"],
80
- @@config["sizes"] || @@config["pages"]["sizes"],
81
- )
68
+ original_image = image
69
+ original_image = original_image.to_s.gsub!(">", " />")
82
70
 
83
- page.output.gsub!(original_image, image)
84
- end
71
+ image =
72
+ process_image(
73
+ image,
74
+ @config["transformations_widths"] ||
75
+ @config["pages"]["transformations_widths"],
76
+ @config["sizes"] || @config["pages"]["sizes"]
77
+ )
78
+
79
+ page.output.gsub!(original_image, image)
85
80
  end
86
81
  end
87
82
  end
88
83
 
89
84
  def process_image(image, transformations, sizes)
90
85
  srcset_value = ""
91
- transformations.each { |t_w| srcset_value += "#{image[:src]}#{t_w}, " }
86
+ transformations.each do |t_w|
87
+ srcset_value += "#{image[:src]}#{t_w}, "
88
+ end
92
89
  # remove the extra ", " at the end of srcset_value
93
90
  srcset_value.chomp!(", ")
94
91
  # add the attributes to the image
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-srcset-hook
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
  - Jocelyn Gaudette
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-10 00:00:00.000000000 Z
11
+ date: 2022-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -44,7 +44,6 @@ files:
44
44
  - Gemfile
45
45
  - LICENSE
46
46
  - README.md
47
- - Rakefile
48
47
  - lib/jekyll-srcset-hook.rb
49
48
  - lib/jekyll-srcset-hook/version.rb
50
49
  homepage: https://github.com/juicy-g/jekyll-srcset-hook
@@ -72,6 +71,6 @@ requirements: []
72
71
  rubygems_version: 3.3.5
73
72
  signing_key:
74
73
  specification_version: 4
75
- summary: A Jekyll plugin to add srcset and sizes attributes to images without Liquid
76
- tags.
74
+ summary: A Jekyll plugin to add srcset and sizes attributes to images without using
75
+ Liquid tags.
77
76
  test_files: []
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rubocop/rake_task"
5
-
6
- RuboCop::RakeTask.new
7
-
8
- task default: :rubocop