jekyll-images 0.4.3 → 0.4.4

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
  SHA256:
3
- metadata.gz: 31a40d18c9380fea4e41a5c35d4f73df78a4cb610a9c0a5f056078f1b2f18348
4
- data.tar.gz: 8389124ff7506350947e659502d3509031a02f7996b59142946e777d351f3061
3
+ metadata.gz: 93c7297749522fea4bb9f7649b667642ca7bab5f8eefe7cbaf8347f1c7891f89
4
+ data.tar.gz: baa710b682e54e422ef5fccb6d9c705411dcc21f47b5f6ad5801784084129b00
5
5
  SHA512:
6
- metadata.gz: 6d17d68159495120c0f8c8bdb4a723754a427ef97f6c80267447f477b384b8d5febbd865ea3e875fe6887b50dc5f7b52a7561150083b0d5f59e9851767a9fe5a
7
- data.tar.gz: 7f9de94e83e0c032e0c5ae097d504fe767c47511d53c97365344ca458e811d511c57fe69f575de39a6452a589b5aecece5a25839bb73aadc904b61e7d24b42a0
6
+ metadata.gz: 1c40800e9cea6523339a6c1667a4fce3c590ca6d64f6ac9a3b56944349e0f3ce2cae417cecb5b3735f8b340b5fde1c29ac13285b58b289b816bc383626c6dc87
7
+ data.tar.gz: ce3c6b76282750b05a1e2baf888ae2545da139a734bc855fd55d8244ea5b91db023cb086636c966f475e5ae81d960bd65acbdeb2101b03c998738358064e1b17
@@ -10,17 +10,30 @@ module Jekyll
10
10
  def dzsave(input, layout = 'google', tile_size = 256)
11
11
  return input unless input
12
12
 
13
- path = @context.registers[:site].in_source_dir input
13
+ site = @context.registers[:site]
14
+ path = site.in_source_dir(input)
14
15
 
15
- unless ::File.exist? path
16
+ unless ::File.exist?(path)
16
17
  Jekyll.logger.warn "File doesn't exist #{input}"
17
18
  return input
18
19
  end
19
20
 
20
21
  dir = ::File.dirname(input)
21
- image = Vips::Image.new_from_file path, access: :sequential
22
+ previous_tiles = []
23
+
24
+ Dir.chdir(site.source) do
25
+ previous_tiles = Dir.glob(::File.join(dir, '*', '**', '*.jpg'))
26
+ end
27
+
28
+ image = Vips::Image.new_from_file(path, access: :sequential)
22
29
  image.dzsave(dir, layout: layout, tile_size: tile_size)
23
30
 
31
+ Dir.chdir(site.source) do
32
+ (Dir.glob(::File.join(dir, '*', '**', '*.jpg')) - previous_tiles).each do |tile|
33
+ site.static_files << Jekyll::StaticFile.new(site, site.source, ::File.dirname(tile), ::File.basename(tile))
34
+ end
35
+ end
36
+
24
37
  "#{dir}/{z}/{y}/{x}.jpg"
25
38
  rescue Vips::Error => e
26
39
  Jekyll.logger.warn "Failed to process #{input}: #{e.message}"
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Filters
5
+ # Maximum zoom level
6
+ module MaxZoomLevel
7
+ # Finds the maximum zoom level for an image
8
+ #
9
+ # @param :input [String]
10
+ # @return [Integer]
11
+ def max_zoom_level(input)
12
+ return input unless input
13
+
14
+ path = ::File.dirname(@context.registers[:site].in_source_dir(input))
15
+
16
+ unless ::File.exist? path
17
+ Jekyll.logger.warn 'Max zoom level:', "File doesn't exist #{input}"
18
+ return input
19
+ end
20
+
21
+ max_zoom_level = 0
22
+
23
+ loop do
24
+ unless ::File.directory?(::File.join(path, max_zoom_level.to_s))
25
+ max_zoom_level -= 1
26
+ break
27
+ end
28
+
29
+ break if max_zoom_level > 18
30
+
31
+ max_zoom_level += 1
32
+ end
33
+
34
+ max_zoom_level
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ Liquid::Template.register_filter(Jekyll::Filters::MaxZoomLevel)
data/lib/jekyll-images.rb CHANGED
@@ -12,5 +12,6 @@ require_relative 'jekyll/filters/thumbnail'
12
12
  require_relative 'jekyll/filters/width'
13
13
  require_relative 'jekyll/filters/height'
14
14
  require_relative 'jekyll/filters/dzsave'
15
+ require_relative 'jekyll/filters/max_zoom_level'
15
16
  require_relative 'jekyll/images/oxipng'
16
17
  require_relative 'jekyll/images/jpeg_optim'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-images
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-08 00:00:00.000000000 Z
11
+ date: 2024-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -66,6 +66,7 @@ files:
66
66
  - lib/jekyll-images.rb
67
67
  - lib/jekyll/filters/dzsave.rb
68
68
  - lib/jekyll/filters/height.rb
69
+ - lib/jekyll/filters/max_zoom_level.rb
69
70
  - lib/jekyll/filters/thumbnail.rb
70
71
  - lib/jekyll/filters/width.rb
71
72
  - lib/jekyll/images/cache.rb