cheesy-gallery 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +6 -0
- data/lib/cheesy-gallery/base_image_file.rb +21 -0
- data/lib/cheesy-gallery/generator.rb +1 -1
- data/lib/cheesy-gallery/image_file.rb +5 -0
- data/lib/cheesy-gallery/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19931d133435a6a55017ecac411db830706130e548d194cb46acd26a252adfd1
|
4
|
+
data.tar.gz: a1051c7f17f276558d65f681ae61bffb74f3ec3ae6d0089d4f2e1e963f83587a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b13062ca2c8117769df7e288aa285a67dcb467c56818faf6a92292492dd9c12f1319159b09c0f936edef88cec566075d3fa1807b15dfc0332e72e17372cedfa
|
7
|
+
data.tar.gz: cae163728e4f9ca11d2dc5059027f39d1c42930f6802d4917850d7e726c603682adbb47dc986d1d6f6363a5cdce3a4627a40e1bd5888c49c9e61a814b083087f
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# 1.1.0
|
2
|
+
|
3
|
+
* Adds aggressive caching to reduce rebuild times.
|
4
|
+
If you need to re-render images for any reason, remove the `.jekyll-cache` folder or change the `_config.yml` file.
|
5
|
+
|
6
|
+
* Changes default quality to 85, and instead strips alls comments.
|
7
|
+
This results in better quality pictures with less size.
|
8
|
+
|
9
|
+
# 1.0.0
|
10
|
+
|
11
|
+
Initial Release
|
data/README.md
CHANGED
@@ -44,6 +44,12 @@ If you want an inline display of your photos, I recommend [glightbox](https://gi
|
|
44
44
|
|
45
45
|
at the bottom of the layout.
|
46
46
|
|
47
|
+
## Caching
|
48
|
+
|
49
|
+
This plugin uses aggressive caching to keep render times short.
|
50
|
+
If you need to re-render images for any reason, remove the `.jekyll-cache` folder or change the `_config.yml` file.
|
51
|
+
See the [Cache API tutorial](https://jekyllrb.com/tutorials/cache-api/) for some background.
|
52
|
+
|
47
53
|
## Development
|
48
54
|
|
49
55
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. There is also a test site in `spec/fixtures/test_site` that you can use to try out changes.
|
@@ -8,6 +8,8 @@ require 'rmagick'
|
|
8
8
|
class CheesyGallery::BaseImageFile < Jekyll::StaticFile
|
9
9
|
extend T::Sig
|
10
10
|
|
11
|
+
@@render_cache = T.let(Jekyll::Cache.new('CheesyGallery::Render'), Jekyll::Cache) # don't need to worry about inheritance here # rubocop:disable Style/ClassVars
|
12
|
+
|
11
13
|
sig { params(site: Jekyll::Site, collection: Jekyll::Collection, file: Jekyll::StaticFile, dest_path: T.nilable(String)).void }
|
12
14
|
def initialize(site, collection, file, dest_path = nil)
|
13
15
|
@source_file = T.let(file, Jekyll::StaticFile)
|
@@ -27,6 +29,25 @@ class CheesyGallery::BaseImageFile < Jekyll::StaticFile
|
|
27
29
|
img.write(path) {}
|
28
30
|
end
|
29
31
|
|
32
|
+
# Inject cache here to override default delete-before-copy behaviour
|
33
|
+
# See jekyll:lib/jekyll/static_file.rb for source
|
34
|
+
def write(dest)
|
35
|
+
dest_path = destination(dest)
|
36
|
+
return false if File.exist?(dest_path) && !modified?
|
37
|
+
|
38
|
+
self.class.mtimes[path] = mtime
|
39
|
+
|
40
|
+
return if @@render_cache.key?("#{dest_path}-rendered") && File.exist?(dest_path)
|
41
|
+
|
42
|
+
FileUtils.mkdir_p(File.dirname(dest_path))
|
43
|
+
FileUtils.rm(dest_path) if File.exist?(dest_path)
|
44
|
+
copy_file(dest_path)
|
45
|
+
|
46
|
+
@@render_cache["#{dest_path}-rendered"] = true
|
47
|
+
|
48
|
+
true
|
49
|
+
end
|
50
|
+
|
30
51
|
private
|
31
52
|
|
32
53
|
# instead of copying, allow rmagick processing
|
@@ -36,7 +36,7 @@ class CheesyGallery::Generator < Jekyll::Generator
|
|
36
36
|
CheesyGallery::ImageFile.new(
|
37
37
|
site, collection, f,
|
38
38
|
max_size: collection.metadata['max_size'] || '1920x1080',
|
39
|
-
quality: collection.metadata['quality'] ||
|
39
|
+
quality: collection.metadata['quality'] || 85
|
40
40
|
)
|
41
41
|
end
|
42
42
|
|
@@ -40,6 +40,11 @@ class CheesyGallery::ImageFile < CheesyGallery::BaseImageFile
|
|
40
40
|
img.change_geometry!(@max_size) do |cols, rows, i|
|
41
41
|
i.resize!(cols, rows)
|
42
42
|
end
|
43
|
+
# follow recommendations from https://stackoverflow.com/a/7262050/4918 to get better compression
|
44
|
+
img.interlace = Magick::PlaneInterlace
|
45
|
+
# but skip the blur to avoid too many changes to the data
|
46
|
+
# img.gaussian_blur(0.05)
|
47
|
+
img.strip!
|
43
48
|
# workaround weird {self} initialisation pattern
|
44
49
|
quality = @quality
|
45
50
|
img.write(path) { self.quality = quality }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheesy-gallery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Schmitt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- ".rspec"
|
163
163
|
- ".rubocop.yml"
|
164
164
|
- ".travis.yml"
|
165
|
+
- CHANGELOG.md
|
165
166
|
- CODE_OF_CONDUCT.md
|
166
167
|
- Gemfile
|
167
168
|
- LICENSE.md
|