jekyll-imgflow 0.1.7 → 0.1.8
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 +4 -4
- data/README.md +5 -2
- data/lib/jekyll-imgflow/batch_manager.rb +6 -1
- data/lib/jekyll-imgflow/build_time_processor.rb +13 -6
- data/lib/jekyll-imgflow/imgflow_tag.rb +18 -9
- data/lib/jekyll-imgflow/operation_processor.rb +10 -5
- data/lib/jekyll-imgflow/path_resolver.rb +9 -6
- data/lib/jekyll-imgflow/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '096d8389110e5128cb043db130059fed14d477e859068074645aa2d915453d78'
|
|
4
|
+
data.tar.gz: 47808ceb1562c5445bb3d6b6acbca1477a19ab9477e414c712bce676c8dd579e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6a22f23719023088512647af702af94e220f7697016cac7ee85d1d894e49be7e2f35c67439e1e6701d14d3a1be20d5cc52cf1961d9dd64da39ae06431b868994
|
|
7
|
+
data.tar.gz: e25a2fb82d17e77791776935adfe333cd2f127396702902988b3956b10d41e4a4e3101ec9a50a09aaf44a876c7baa42c32135c37b1fdb785179a946c2472c793
|
data/README.md
CHANGED
|
@@ -5,6 +5,7 @@ A [Jekyll](https://jekyllrb.com/) plugin for automatic image optimization with m
|
|
|
5
5
|
[](https://deepwiki.com/gundestrup/jekyll-imgflow)
|
|
6
6
|
[](https://github.com/gundestrup/jekyll-imgflow)
|
|
7
7
|
[](https://codecov.io/gh/gundestrup/jekyll-imgflow)
|
|
8
|
+
[](https://github.com/gundestrup/jekyll-imgflow-vscode)
|
|
8
9
|
[](LICENSE)
|
|
9
10
|
|
|
10
11
|
## 🚀 Quick Start
|
|
@@ -32,9 +33,11 @@ imgflow:
|
|
|
32
33
|
> and [Configuration Reference](docs/ARCHITECTURE.md).
|
|
33
34
|
|
|
34
35
|
> **Note:** Image references require exact filenames (or paths relative to
|
|
35
|
-
> `originals`). There is no fuzzy matching
|
|
36
|
+
> `originals`). There is no fuzzy matching during the build yet — if you type
|
|
36
37
|
> `photo.jpg` but the file is `photo.jpeg`, the build will fail with an error.
|
|
37
|
-
>
|
|
38
|
+
>
|
|
39
|
+
> For editor autocomplete while writing `{% imgflow %}` tags, install the
|
|
40
|
+
> [VS Code companion extension](https://github.com/gundestrup/jekyll-imgflow-vscode).
|
|
38
41
|
|
|
39
42
|
## ✨ Key Features
|
|
40
43
|
|
|
@@ -213,8 +213,13 @@ module JekyllImgFlow
|
|
|
213
213
|
# Use FilenameGenerator to generate proper filename
|
|
214
214
|
operations = { width: width, format: format, quality: config.quality }
|
|
215
215
|
filename = filename_generator.generate_filename(original_name, operations)
|
|
216
|
+
|
|
217
|
+
# Preserve original directory structure under output
|
|
218
|
+
subdir = File.dirname(original_name)
|
|
219
|
+
subdir = nil if subdir == "."
|
|
220
|
+
|
|
216
221
|
# Write to source directory so Jekyll copies files to _site during write phase
|
|
217
|
-
output_path = path_resolver.resolve_source_output_path(filename)
|
|
222
|
+
output_path = path_resolver.resolve_source_output_path(filename, subdir)
|
|
218
223
|
|
|
219
224
|
tasks << {
|
|
220
225
|
original_name: original_name,
|
|
@@ -42,12 +42,14 @@ module JekyllImgFlow
|
|
|
42
42
|
original_paths = find_original_images
|
|
43
43
|
Jekyll.logger.info "📸 Found #{original_paths.length} original images"
|
|
44
44
|
|
|
45
|
+
originals_dir = File.join(@site.source, @config.originals)
|
|
46
|
+
|
|
45
47
|
# Build tasks for each original image
|
|
46
48
|
original_paths.each do |path|
|
|
47
|
-
original_name =
|
|
49
|
+
original_name = path.sub("#{originals_dir}/", "")
|
|
48
50
|
|
|
49
51
|
# Check if needs processing (file changed or provider changed)
|
|
50
|
-
if needs_processing?(path)
|
|
52
|
+
if needs_processing?(original_name, path)
|
|
51
53
|
Jekyll.logger.info "🔧 Queuing default versions for: #{original_name}"
|
|
52
54
|
|
|
53
55
|
# Build default tasks
|
|
@@ -84,8 +86,10 @@ module JekyllImgFlow
|
|
|
84
86
|
provider_name = @registry.current_provider.class.name.split("::").last.downcase
|
|
85
87
|
|
|
86
88
|
# Convert absolute path to relative for manifest storage
|
|
89
|
+
# Default versions are written to the source directory so Jekyll can
|
|
90
|
+
# copy them to _site during the write phase.
|
|
87
91
|
absolute_path = task[:result]
|
|
88
|
-
relative_path = absolute_path.sub(@site.
|
|
92
|
+
relative_path = absolute_path.sub(@site.source, "")
|
|
89
93
|
|
|
90
94
|
# Register the version in manifest
|
|
91
95
|
@manifest.register_version(
|
|
@@ -113,10 +117,13 @@ module JekyllImgFlow
|
|
|
113
117
|
end
|
|
114
118
|
|
|
115
119
|
# Check if image needs processing
|
|
116
|
-
# @param
|
|
120
|
+
# @param original_name [String] Path to original image relative to originals directory
|
|
121
|
+
# @param path [String, nil] Full path to original image (defaults to original_name)
|
|
117
122
|
# @return [Boolean] True if processing needed
|
|
118
|
-
def needs_processing?(path)
|
|
119
|
-
|
|
123
|
+
def needs_processing?(original_name, path = nil)
|
|
124
|
+
path ||= original_name
|
|
125
|
+
# For single-argument calls, derive a flat original_name from the full path
|
|
126
|
+
original_name = File.basename(original_name) if original_name == path
|
|
120
127
|
|
|
121
128
|
# If no versions exist, needs processing
|
|
122
129
|
return true unless @manifest.versions?(original_name)
|
|
@@ -64,7 +64,15 @@ module Jekyll
|
|
|
64
64
|
|
|
65
65
|
site = context.registers[:site]
|
|
66
66
|
page = context.registers[:page]
|
|
67
|
-
|
|
67
|
+
|
|
68
|
+
# Resolve input path
|
|
69
|
+
input_path = resolve_image_path(parsed[:image_path], site, components[:config])
|
|
70
|
+
raise ArgumentError, "Input image file not found: #{input_path}" unless File.file?(input_path)
|
|
71
|
+
|
|
72
|
+
# Store original name relative to the configured originals directory
|
|
73
|
+
# so output can mirror the original directory structure
|
|
74
|
+
originals_dir = File.join(site.source, components[:config].originals)
|
|
75
|
+
original_name = input_path.sub("#{originals_dir}/", "")
|
|
68
76
|
|
|
69
77
|
# Get page path for manifest tracking
|
|
70
78
|
# Try multiple attributes to get the page identifier
|
|
@@ -74,10 +82,6 @@ module Jekyll
|
|
|
74
82
|
"unknown"
|
|
75
83
|
end
|
|
76
84
|
|
|
77
|
-
# Resolve input path
|
|
78
|
-
input_path = resolve_image_path(parsed[:image_path], site, components[:config])
|
|
79
|
-
raise ArgumentError, "Input image file not found: #{input_path}" unless File.file?(input_path)
|
|
80
|
-
|
|
81
85
|
# Process operations using clean architecture
|
|
82
86
|
operations = parsed[:operations]
|
|
83
87
|
|
|
@@ -96,8 +100,12 @@ module Jekyll
|
|
|
96
100
|
params[:quality] ||= components[:config].quality # Use default quality
|
|
97
101
|
end
|
|
98
102
|
|
|
103
|
+
# Preserve original directory structure under output
|
|
104
|
+
subdir = File.dirname(original_name)
|
|
105
|
+
subdir = nil if subdir == "."
|
|
106
|
+
|
|
99
107
|
filename = components[:filename_generator].generate_filename(input_path, params)
|
|
100
|
-
output_path = components[:path_resolver].resolve_source_output_path(filename)
|
|
108
|
+
output_path = components[:path_resolver].resolve_source_output_path(filename, subdir)
|
|
101
109
|
|
|
102
110
|
# Determine version type
|
|
103
111
|
version_type = determine_version_type(params, components[:config])
|
|
@@ -199,11 +207,12 @@ module Jekyll
|
|
|
199
207
|
path_resolver = JekyllImgFlow::PathResolver.new(config)
|
|
200
208
|
|
|
201
209
|
# Handle different path formats
|
|
202
|
-
if image_path.start_with?("/")
|
|
203
|
-
# Absolute
|
|
210
|
+
if image_path.start_with?("/")
|
|
211
|
+
# Absolute site-root path: /assets/images/originals/valdemar/photo.jpg
|
|
204
212
|
File.join(site.source, image_path)
|
|
205
213
|
else
|
|
206
|
-
#
|
|
214
|
+
# Relative path: photo.jpg or valdemar/photo.jpg
|
|
215
|
+
# Always resolve against the configured originals directory
|
|
207
216
|
path_resolver.cli_path(image_path)
|
|
208
217
|
end
|
|
209
218
|
end
|
|
@@ -42,13 +42,18 @@ module JekyllImgFlow
|
|
|
42
42
|
type = operation[:type]
|
|
43
43
|
params = operation[:params]
|
|
44
44
|
|
|
45
|
+
# Determine version type
|
|
46
|
+
version_type = determine_version_type(params)
|
|
47
|
+
|
|
48
|
+
# Preserve original directory structure under output
|
|
49
|
+
subdir = File.dirname(original_name)
|
|
50
|
+
subdir = nil if subdir == "."
|
|
51
|
+
|
|
45
52
|
# Generate filename using FilenameGenerator (JPT compatible)
|
|
46
53
|
filename = @filename_generator.generate_filename(input_path, params)
|
|
47
|
-
# Write to source directory so Jekyll copies files to _site during write phase
|
|
48
|
-
actual_output_path = @path_resolver.resolve_source_output_path(filename)
|
|
49
54
|
|
|
50
|
-
#
|
|
51
|
-
|
|
55
|
+
# Write to source directory so Jekyll copies files to _site during the write phase
|
|
56
|
+
actual_output_path = @path_resolver.resolve_source_output_path(filename, subdir)
|
|
52
57
|
|
|
53
58
|
# Ensure output directory exists before processing
|
|
54
59
|
FileUtils.mkdir_p(File.dirname(actual_output_path))
|
|
@@ -69,7 +74,7 @@ module JekyllImgFlow
|
|
|
69
74
|
# Register in manifest
|
|
70
75
|
if @manifest
|
|
71
76
|
# Store relative path (with leading /) for manifest storage
|
|
72
|
-
relative_path = "/#{@path_resolver.resolve_relative_output_path(filename)}"
|
|
77
|
+
relative_path = "/#{@path_resolver.resolve_relative_output_path(filename, subdir)}"
|
|
73
78
|
|
|
74
79
|
provider_name = @provider.class.provider_name
|
|
75
80
|
@manifest.register_version(
|
|
@@ -61,26 +61,29 @@ module JekyllImgFlow
|
|
|
61
61
|
|
|
62
62
|
# Resolve output path for generated filename
|
|
63
63
|
# @param filename [String] Generated filename
|
|
64
|
+
# @param subdir [String, nil] Optional subdirectory under output
|
|
64
65
|
# @return [String] Full path to output file in _site (for specialized versions during rendering)
|
|
65
|
-
def resolve_output_path(filename)
|
|
66
|
+
def resolve_output_path(filename, subdir = nil)
|
|
66
67
|
# Resolve output path relative to site destination
|
|
67
|
-
File.join(@config.site.dest, @config.output, filename)
|
|
68
|
+
File.join([@config.site.dest, @config.output, subdir, filename].compact)
|
|
68
69
|
end
|
|
69
70
|
|
|
70
71
|
# Resolve output path to source directory for default images
|
|
71
72
|
# @param filename [String] Generated filename
|
|
73
|
+
# @param subdir [String, nil] Optional subdirectory under output
|
|
72
74
|
# @return [String] Full path to output file in source (for default versions during pre_render)
|
|
73
|
-
def resolve_source_output_path(filename)
|
|
75
|
+
def resolve_source_output_path(filename, subdir = nil)
|
|
74
76
|
# Default images go to source directory so Jekyll can copy them to _site
|
|
75
|
-
File.join(@config.site.source, @config.output, filename)
|
|
77
|
+
File.join([@config.site.source, @config.output, subdir, filename].compact)
|
|
76
78
|
end
|
|
77
79
|
|
|
78
80
|
# Resolve relative output path for manifest storage
|
|
79
81
|
# @param filename [String] Generated filename
|
|
82
|
+
# @param subdir [String, nil] Optional subdirectory under output
|
|
80
83
|
# @return [String] Relative path from site root
|
|
81
|
-
def resolve_relative_output_path(filename)
|
|
84
|
+
def resolve_relative_output_path(filename, subdir = nil)
|
|
82
85
|
# Return path relative to site root (without leading /)
|
|
83
|
-
File.join(@config.output, filename)
|
|
86
|
+
File.join([@config.output, subdir, filename].compact)
|
|
84
87
|
end
|
|
85
88
|
|
|
86
89
|
# Get site destination directory
|