jekyll-picture-tag-ng 0.2.2 → 0.2.3
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 +2 -0
- data/lib/jekyll-picture-tag-ng/version.rb +1 -1
- data/lib/jekyll-picture-tag-ng.rb +41 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a2819edd23c6ea86844dc240bd5e7919d2feb274973fa0dd3f6a2f8309bfc32
|
4
|
+
data.tar.gz: 4cac1933e03ad045a4e2d362b8d41af0142bf93896658503965df3bcdda11b2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5542a64a8d14317ad90380d0faeea45327b99590af770f0c059bfb7f378148336b8848d130e46f04fef2ef13fdc1026f91bd671115558ec5ee4a71762df918c6
|
7
|
+
data.tar.gz: 6c3aff4446150db753872190fe6d6c7c48d85f229ca456b9ae0ff9be703cb3ce44a18e3e4cb7b15fc86e72bccf0940bc754f73722be1aadc4a023cdd88284b0d
|
data/README.md
CHANGED
@@ -62,6 +62,7 @@ Configuration is done in the `_config.yml` of your website, under the `picture_t
|
|
62
62
|
```yaml
|
63
63
|
picture_tag_ng:
|
64
64
|
parallel: false
|
65
|
+
threads: 16
|
65
66
|
background_color: FFFFFF
|
66
67
|
picture_versions:
|
67
68
|
m: 700
|
@@ -73,6 +74,7 @@ The example above is equivalent to the defaults.
|
|
73
74
|
- `background_color` is the color used to replace transparency when converting from `webp` to `jpeg`
|
74
75
|
- `picture_versions` maps version names to target widths in pixels. The default configuration above produces output files 700px wide in `img/m/` and 400px wide in `img/s/`.
|
75
76
|
- `parallel` is a boolean indicating if you want to generate the output files in parallel threads. With a website that has a lot of large pictures, I get ~30% speed improvements when generating the site locally. However, this seems to make building the site with the recommended Github workflow fail.
|
77
|
+
- `threads` is the number of concurrent threads for generating the website (only used if `parallel` is `true`
|
76
78
|
|
77
79
|
## Development
|
78
80
|
|
@@ -101,15 +101,53 @@ module Jekyll
|
|
101
101
|
class Site
|
102
102
|
alias_method "old_write", "write"
|
103
103
|
|
104
|
+
def n_threads
|
105
|
+
config["picture_tag_ng"]["threads"] || 8
|
106
|
+
end
|
107
|
+
|
108
|
+
def thread_pool
|
109
|
+
@thread_pool ||= (0..n_threads).map do |i|
|
110
|
+
Jekyll.logger.debug "Creating thread num #{i}"
|
111
|
+
Thread.new do
|
112
|
+
j = 0
|
113
|
+
Kernel.loop do
|
114
|
+
Jekyll.logger.debug "Doing task num. #{j}"
|
115
|
+
j += 1
|
116
|
+
task = next_task
|
117
|
+
if task.nil?
|
118
|
+
sleep 0.1
|
119
|
+
elsif task.instance_of?(Proc)
|
120
|
+
res = task.call
|
121
|
+
end
|
122
|
+
|
123
|
+
break if res == -1
|
124
|
+
end
|
125
|
+
Jekyll.logger.debug "Finishing thread num #{i}"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def next_task
|
131
|
+
@task_queue ||= []
|
132
|
+
@task_queue.shift
|
133
|
+
end
|
134
|
+
|
135
|
+
def add_task(&task)
|
136
|
+
@task_queue ||= []
|
137
|
+
@task_queue.push(task)
|
138
|
+
end
|
139
|
+
|
104
140
|
def write
|
105
141
|
if config["picture_tag_ng"]["parallel"]
|
106
142
|
Jekyll.logger.info "Writing files in parallel (should not work on GH Pages)"
|
107
143
|
Jekyll::Commands::Doctor.conflicting_urls(self)
|
108
|
-
threads = []
|
109
144
|
each_site_file do |item|
|
110
|
-
|
145
|
+
regenerator.regenerate?(item) && add_task { item.write(dest) }
|
146
|
+
end
|
147
|
+
thread_pool.each do
|
148
|
+
add_task { -1 }
|
111
149
|
end
|
112
|
-
|
150
|
+
thread_pool.each(&:join)
|
113
151
|
regenerator.write_metadata
|
114
152
|
Jekyll::Hooks.trigger :site, :post_write, self
|
115
153
|
nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-picture-tag-ng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pcouy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|