jekyll-picture-tag-ng 0.2.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 991b7c6d81da1fa46e2193cccef939dc7fffeaa396efe3d29f247215a8ad6a61
4
- data.tar.gz: 4b12be741cd2d3ee29c3fb36db63469a271482950ff120a855bc22b52e3693c7
3
+ metadata.gz: 4a2819edd23c6ea86844dc240bd5e7919d2feb274973fa0dd3f6a2f8309bfc32
4
+ data.tar.gz: 4cac1933e03ad045a4e2d362b8d41af0142bf93896658503965df3bcdda11b2d
5
5
  SHA512:
6
- metadata.gz: 877a32abd05c5038f6699fef5f62fbb7ef66c31371d9e5f2888b4fd846334e439b143abd88b7e6c08f182ff19e62dc9517dc5a6aecacf4ef93a2ff90ee3fdc5a
7
- data.tar.gz: 1fab3140ccc61b490bf3eee1af1385b15472ed3bac22c02a5228d53fa3898d876c4afaf5ea9886b65567a57ca7ee4d30d335a1cd50ac826624b19b41b392c033
6
+ metadata.gz: 5542a64a8d14317ad90380d0faeea45327b99590af770f0c059bfb7f378148336b8848d130e46f04fef2ef13fdc1026f91bd671115558ec5ee4a71762df918c6
7
+ data.tar.gz: 6c3aff4446150db753872190fe6d6c7c48d85f229ca456b9ae0ff9be703cb3ce44a18e3e4cb7b15fc86e72bccf0940bc754f73722be1aadc4a023cdd88284b0d
data/README.md CHANGED
@@ -61,6 +61,8 @@ Configuration is done in the `_config.yml` of your website, under the `picture_t
61
61
 
62
62
  ```yaml
63
63
  picture_tag_ng:
64
+ parallel: false
65
+ threads: 16
64
66
  background_color: FFFFFF
65
67
  picture_versions:
66
68
  m: 700
@@ -71,6 +73,8 @@ The example above is equivalent to the defaults.
71
73
 
72
74
  - `background_color` is the color used to replace transparency when converting from `webp` to `jpeg`
73
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/`.
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`
74
78
 
75
79
  ## Development
76
80
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module PictureTag
5
- VERSION = "0.2.1"
5
+ VERSION = "0.2.3"
6
6
  end
7
7
  end
@@ -96,6 +96,68 @@ Jekyll::Hooks.register :site, :after_init do |site|
96
96
  Kramdown::Converter::JEKYLL_SITE = site
97
97
  end
98
98
 
99
+ module Jekyll
100
+ # Override the write methid to paralellize it
101
+ class Site
102
+ alias_method "old_write", "write"
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
+
140
+ def write
141
+ if config["picture_tag_ng"]["parallel"]
142
+ Jekyll.logger.info "Writing files in parallel (should not work on GH Pages)"
143
+ Jekyll::Commands::Doctor.conflicting_urls(self)
144
+ each_site_file do |item|
145
+ regenerator.regenerate?(item) && add_task { item.write(dest) }
146
+ end
147
+ thread_pool.each do
148
+ add_task { -1 }
149
+ end
150
+ thread_pool.each(&:join)
151
+ regenerator.write_metadata
152
+ Jekyll::Hooks.trigger :site, :post_write, self
153
+ nil
154
+ else
155
+ old_write
156
+ end
157
+ end
158
+ end
159
+ end
160
+
99
161
  module Kramdown
100
162
  module Parser
101
163
  # Override Kramdown parser
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.1
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