jekyll-picture-tag-ng 0.2.2 → 0.2.3

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: 24fa31a62f9db299a6bf311f5e9e6786497bf759e26bc1c29ca1e320331c91cc
4
- data.tar.gz: 0472a2f6a44a0a358be737bb2c3bfd42bc5bd266d9c96bedb027a9f889bd0207
3
+ metadata.gz: 4a2819edd23c6ea86844dc240bd5e7919d2feb274973fa0dd3f6a2f8309bfc32
4
+ data.tar.gz: 4cac1933e03ad045a4e2d362b8d41af0142bf93896658503965df3bcdda11b2d
5
5
  SHA512:
6
- metadata.gz: a9d425639ebb2ac9db33b231b19acd323eaa0efa7d3df9cb4aa8233df1c4395f1e1c6d561701d8e6c6389633d6c535e63969663df2b8fa485d873456915cd7de
7
- data.tar.gz: be4985d422441d0ad62dea7f401982d4edb30ce05e01d1819a22eaefe3efef88c7099e1cf702fd79295546ab46d59f3347edbb2bebad180147c191628b72c294
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module PictureTag
5
- VERSION = "0.2.2"
5
+ VERSION = "0.2.3"
6
6
  end
7
7
  end
@@ -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
- threads << Thread.new { item.write(dest) } if regenerator.regenerate?(item)
145
+ regenerator.regenerate?(item) && add_task { item.write(dest) }
146
+ end
147
+ thread_pool.each do
148
+ add_task { -1 }
111
149
  end
112
- threads.each(&:join)
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.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-15 00:00:00.000000000 Z
11
+ date: 2023-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll