jekyll-picture-tag-ng 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/jekyll-picture-tag-ng/version.rb +1 -1
- data/lib/jekyll-picture-tag-ng.rb +62 -0
- 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
@@ -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
|
|
@@ -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.
|
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
|