bridgetown-webp 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 194bf3b0a76df506abecca3fb677ca0f772ea16fa2162f6156aee4e506ad1951
4
+ data.tar.gz: 2b9a00e5520696bfcc2cce48a3d27b55b908f28a58a328cefbc42a75c06a00ad
5
+ SHA512:
6
+ metadata.gz: a2f7701ddc099a2bbd565237de51f73090550fdb650493b512dd62ef1ea8302923df84cc892cd7d270647daabf09de93637ebfe7ec1ed8224b083a4174965ec2
7
+ data.tar.gz: fe677dac3d9bd0dfa47a40f72d01288c280ecb4135e61aa17a5f5622177b765a74eaac57b0d1c579049cc9eaf21cc73a72dd4a4509743d5aefd81beaefcb9533
@@ -0,0 +1,53 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
26
+ * Trolling, insulting/derogatory comments, and personal or political attacks
27
+ * Public or private harassment
28
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
29
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
30
+
31
+ ## Our Responsibilities
32
+
33
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
34
+
35
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
36
+
37
+ ## Scope
38
+
39
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
40
+
41
+ ## Enforcement
42
+
43
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [jekyll@sverrirs.com](mailto:jekyll@sverrirs.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is
44
+ obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
45
+
46
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
47
+
48
+ ## Attribution
49
+
50
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
51
+
52
+ [homepage]: http://contributor-covenant.org
53
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bridgetown-webp.gemspec
4
+ gemspec
5
+
6
+ if ENV["BRIDGETOWN_VERSION"]
7
+ gem "bridgetown", "~> #{ENV["BRIDGETOWN_VERSION"]}"
8
+ end
data/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Sverrir Sigmundarson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11
+
data/README.md ADDED
@@ -0,0 +1,104 @@
1
+ [![Gem Version](https://img.shields.io/gem/v/bridgetown-webp.svg)](https://rubygems.org/gems/bridgetown-webp)
2
+ [![Gem](https://img.shields.io/gem/dt/bridgetown-webp.svg)](https://rubygems.org/gems/bridgetown-webp)
3
+ [![Join the chat at https://gitter.im/bridgetown-webp/Lobby](https://badges.gitter.im/bridgetown-webp/Lobby.svg)](https://gitter.im/bridgetown-webp/Lobby)
4
+ [![Dependency Status](https://gemnasium.com/badges/github.com/sverrirs/bridgetown-webp.svg)](https://gemnasium.com/github.com/sverrirs/bridgetown-webp)
5
+ [![Code Climate](https://codeclimate.com/github/sverrirs/bridgetown-webp/badges/gpa.svg)](https://codeclimate.com/github/sverrirs/bridgetown-webp)
6
+ [![security](https://hakiri.io/github/sverrirs/bridgetown-webp/master.svg)](https://hakiri.io/github/sverrirs/bridgetown-webp/master)
7
+
8
+ # WebP Generator for Bridgetown
9
+ WebP Image Generator for Bridgetown Sites can automatically generate WebP images for all images on your static site and serve them when possible. View on [rubygems.org](https://rubygems.org/gems/bridgetown-webp).
10
+
11
+ > Read more about this tool on my blog at <a href="https://blog.sverrirs.com/2016/06/webp-generator-for-bridgetown-sites.html" target="_blank">blog.sverrirs.com</a>
12
+
13
+ ## Installation
14
+
15
+ ```
16
+ gem install bridgetown-webp
17
+ ```
18
+
19
+ The release includes all necessary files to run, including the WebP redistributable executable files.
20
+
21
+ > Currently the release includes the v0.6.1 version of the WebP utilities for Windows, Linux and Mac OS X 10.9 (Mountain Lion). Other versions and releases can be downloaded directly from <a href="https://developers.google.com/speed/webp/docs/precompiled" target="_blank">the Google page</a>.
22
+
23
+ Add the gem to your `Gemfile` and to Bridgetown's `_config.yml` then run `bridgetown serve` again and you should see the generator run during site generation.
24
+
25
+ ## Configuration
26
+ The plugin can be configured in the site's `_config.yml` file by including the `webp` configuration element
27
+
28
+ ``` yml
29
+ ############################################################
30
+ # Site configuration for the WebP Generator Plugin
31
+ # The values here represent the defaults if nothing is set
32
+ webp:
33
+ enabled: true
34
+
35
+ # The quality of the webp conversion 0 to 100 (where 100 is least lossy)
36
+ quality: 75
37
+
38
+ # List of directories containing images to optimize, nested directories will only be checked if `nested` is true
39
+ # By default the generator will search for a folder called `/img` under the site root and process all jpg, png and tiff image files found there.
40
+ img_dir: ["/img"]
41
+
42
+ # Whether to search in nested directories or not
43
+ nested: false
44
+
45
+ # add ".gif" to the format list to generate webp for animated gifs as well
46
+ formats: [".jpeg", ".jpg", ".png", ".tiff"]
47
+
48
+ # File extensions for animated gif files
49
+ gifs: [".gif"]
50
+
51
+ # Set to true to always regenerate existing webp files
52
+ regenerate: false
53
+
54
+ # Local path to the WebP utilities to use (relative or absolute)
55
+ # Omit or leave as nil to use the utilities shipped with the gem, override only to use your local install
56
+ webp_path: nil
57
+
58
+ # List of files or directories to exclude
59
+ # e.g. custom or hand generated webp conversion files
60
+ exclude: []
61
+
62
+ # append '.webp' to filename after original extension rather than replacing it.
63
+ # Default transforms `image.png` to `image.webp`, while changing to true transforms `image.png` to `image.png.webp`
64
+ append_ext: false
65
+ ############################################################
66
+ ```
67
+
68
+ ## Simplest use: HTML
69
+ In case you don't have control over your webserver then using the `<picture>` element and specifying all image formats available is the best option. This way the browser will decide which format to use based on its own capabilities.
70
+
71
+ ``` html
72
+ <picture>
73
+ <source srcset="/path/to/image.webp" type="image/webp">
74
+ <img src="/path/to/image.jpg" alt="">
75
+ </picture>
76
+ ```
77
+
78
+ ## Advanced use: Webserver Configuration
79
+ If you can, then configuring your webserver to serve your new _.webp_ files to clients that support the format is probably the least problematic approach. This way you don't need to make any changes to your HTML files as your webserver will automatically serve WebP images when the client supports them.
80
+
81
+ Below is an example for a .htaccess configuration section in an Apache web-server. It will redirect users to webp images whenever possible.
82
+
83
+ ```
84
+ ####################
85
+ # Attempt to redirect images to WebP if one exists
86
+ # and the client supports the file format
87
+ ####################
88
+ # check if browser accepts webp
89
+ RewriteCond %{HTTP_ACCEPT} image/webp
90
+
91
+ # check if file is jpg or png
92
+ RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png)$
93
+
94
+ # check if corresponding webp file exists image.png -> image.webp
95
+ RewriteCond %1\.webp -f
96
+
97
+ # serve up webp instead
98
+ RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
99
+
100
+ AddType image/webp .webp
101
+ ```
102
+
103
+ > Depending on other configurations in your `.htaccess` file you might have to update your `ExpiresByType`, `ExpiresDefault` and `Header set Cache-Control` directives to include the webp format as well.
104
+
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs.push 'lib'
6
+ t.libs.push 'specs'
7
+ t.verbose = true
8
+ t.pattern = "spec/*_spec.rb"
9
+ t.test_files = FileList['spec/*_spec.rb']
10
+ end
11
+
12
+ desc "Run tests"
13
+ task :default => [:test]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "bridgetown/webp"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
Binary file
Binary file
data/bin/osx-cwebp ADDED
Binary file
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
Binary file
Binary file
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ require_relative 'lib/bridgetown-webp/version'
3
+ require 'date'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "bridgetown-webp"
7
+ spec.version = Bridgetown::Webp::VERSION
8
+ spec.platform = Gem::Platform::RUBY
9
+ spec.date = DateTime.now.strftime('%Y-%m-%d')
10
+ spec.authors = ["Sverrir Sigmundarson", "Carl Tanner"]
11
+ spec.email = ["hello@gocarlgo.com"]
12
+ spec.homepage = "https://github.com/captproton/bridgetown-webp"
13
+ spec.license = "MIT"
14
+
15
+ spec.summary = %q{WebP image generator for Bridgetown websites}
16
+ spec.description = %q{WebP Image Generator for Bridgetown sites that automatically generate WebP images for all images on your static site and serves them when possible. Includes the v0.6.1 version of the WebP utilities for Windows, Linux and Mac OS X 10.9 (Mountain Lion)}
17
+
18
+ spec.files = Dir['CODE_OF_CONDUCT.md', 'README.md', 'LICENSE', 'Rakefile', '*.gemspec', 'Gemfile', 'lib/**/*', 'spec/**/*', 'bin/**/*']
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^spec/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bridgetown", "~> 0.21.4"
24
+ spec.add_development_dependency "bundler", "~> 2.2"
25
+ spec.add_development_dependency "rake", "~> 13.0"
26
+ spec.add_development_dependency "minitest", '~> 5.14', '>= 5.0.3'
27
+ end
@@ -0,0 +1,50 @@
1
+ module Bridgetown
2
+ module Webp
3
+
4
+ # The default configuration for the Webp generator
5
+ # The values here represent the defaults if nothing is set
6
+ DEFAULT = {
7
+ 'enabled' => false,
8
+
9
+ # The quality of the webp conversion 0 to 100 (where 100 is least lossy)
10
+ 'quality' => 75,
11
+
12
+ # Other flags to pass to the webp binary. For a list of valid parameters check here:
13
+ # https://developers.google.com/speed/webp/docs/cwebp#options
14
+ 'flags' => "-m 4 -pass 4 -af",
15
+
16
+ # List of directories containing images to optimize, Nested directories only be checked if `nested` is true
17
+ 'img_dir' => ["/img"],
18
+
19
+ # Whether to search in nested directories or not
20
+ 'nested' => false,
21
+
22
+ # add ".gif" to the format list to generate webp for animated gifs as well
23
+ 'formats' => [".jpeg", ".jpg", ".png", ".tiff"],
24
+
25
+ # append .webp to existing extension instead of replacing it
26
+ # (Enables more efficient nginx rules.
27
+ # See http://www.lazutkin.com/blog/2014/02/23/serve-files-with-nginx-conditionally/)
28
+ 'append_ext' => false,
29
+
30
+ # File extensions for animated gif files
31
+ 'gifs' => [".gif"],
32
+
33
+ # Set to true to always regenerate existing webp files
34
+ 'regenerate'=> false,
35
+
36
+ # Local path to the WebP utilities to use (relative or absolute)
37
+ # Leave as nil to use the cmd line utilities shipped with the gem, override to use your local install
38
+ 'webp_path' => nil,
39
+
40
+ # List of files or directories to exclude
41
+ # e.g. custom or hand generated webp conversion files
42
+ 'exclude' => [],
43
+
44
+ # List of files or directories to explicitly include
45
+ # e.g. single files outside of the main image directories
46
+ 'include' => []
47
+ }
48
+
49
+ end # module Webp
50
+ end # module Bridgetown
@@ -0,0 +1,8 @@
1
+ module Bridgetown
2
+ module Webp
3
+ VERSION = "1.0.0"
4
+ # When modifying remember to issue a new tag command in git before committing, then push the new tag
5
+ # git tag -a v1.0.0 -m "Gem v1.0.0"
6
+ # git push origin --tags
7
+ end #module Webp
8
+ end #module Bridgetown
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "webp/version"
4
+
5
+ module Bridgetown
6
+ module Webp
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
10
+ end
@@ -0,0 +1,104 @@
1
+ require 'open3'
2
+
3
+ module Bridgetown
4
+ module Webp
5
+
6
+ class WebpExec
7
+
8
+ #
9
+ # Runs the WebP executable for the given input parameters
10
+ # the function detects the OS platform and architecture automatically
11
+ #
12
+ def self.run(quality, flags, input_file, output_file)
13
+
14
+ # What is the path to the execs inside the gem? perhaps just bin/?
15
+ bin_path = "bin/"
16
+
17
+ # What is the OS and architecture specific executable name?
18
+ exe_name = WebpExec.exe_name
19
+
20
+ # We need to locate the Gems bin path as we're currently running inside the
21
+ # bridgetown site working directory
22
+ # http://stackoverflow.com/a/10083594/779521
23
+ gem_spec = Gem::Specification.find_by_name("bridgetown-webp")
24
+ gem_root = gem_spec.gem_dir
25
+
26
+ # Construct the full path to the executable
27
+ full_path = File.join(gem_root, bin_path, exe_name)
28
+
29
+ # Construct the full program call
30
+ cmd = "\"#{full_path}\" -quiet -mt -q #{quality.to_s} #{flags} \"#{input_file}\" -o \"#{output_file}\""
31
+
32
+ # Execute the command
33
+ exit_code = 0
34
+ error = ""
35
+ output = ""
36
+ Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
37
+ stdin.close # we don't pass any input to the process
38
+ output = stdout.gets
39
+ error = stderr.gets
40
+ exit_code = wait_thr.value
41
+ end
42
+
43
+ if exit_code != 0
44
+ Bridgetown.logger.error("WebP:","Conversion for image #{input_file} failed, no webp version could be created for this image")
45
+ Bridgetown.logger.debug("WebP:","cwebp returned #{exit_code} with error #{error}")
46
+ end
47
+
48
+ # Return any captured return value
49
+ return [output, error]
50
+ end #function run
51
+
52
+ #
53
+ # Returns the correct executable name depending on the OS platform and OS architecture
54
+ #
55
+ def self.exe_name
56
+ if OS.mac?
57
+ return "osx-cwebp"
58
+ elsif OS.windows?
59
+ if OS.x32?
60
+ return "win-x86-cwebp.exe"
61
+ else
62
+ return "win-x64-cwebp.exe"
63
+ end
64
+ elsif OS.unix? || OS.linux?
65
+ if OS.x32?
66
+ return "linux-x86-cwebp"
67
+ else
68
+ return "linux-x64-cwebp"
69
+ end
70
+ else
71
+ raise ArgumentError.new("OS platform could not be identified (gem can only be run on linux,osx or windows)")
72
+ end
73
+ end #function exe_name
74
+
75
+ end #class WebpExec
76
+
77
+ end #module Webp
78
+
79
+ module OS
80
+ def OS.windows?
81
+ (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
82
+ end
83
+
84
+ def OS.mac?
85
+ (/darwin/ =~ RUBY_PLATFORM) != nil
86
+ end
87
+
88
+ def OS.unix?
89
+ !OS.windows?
90
+ end
91
+
92
+ def OS.linux?
93
+ OS.unix? and not OS.mac?
94
+ end
95
+
96
+ def OS.x32?
97
+ return 1.size != 8
98
+ end
99
+
100
+ def OS.x64?
101
+ return 1.size == 8
102
+ end
103
+ end #module OS
104
+ end #module Bridgetown
@@ -0,0 +1,115 @@
1
+ require 'bridgetown/document'
2
+ require 'fileutils'
3
+
4
+ module Bridgetown
5
+ module Webp
6
+
7
+ #
8
+ # A static file to hold the generated webp image after generation
9
+ # so that Bridgetown will copy it into the site output directory
10
+ class WebpFile < StaticFile
11
+ def write(dest)
12
+ true # Recover from strange exception when starting server without --auto
13
+ end
14
+ end #class WebpFile
15
+
16
+ class WebpGenerator < Generator
17
+ # This generator is safe from arbitrary code execution.
18
+ safe true
19
+
20
+ # This generator should be passive with regard to its execution
21
+ priority :lowest
22
+
23
+ # Generate paginated pages if necessary (Default entry point)
24
+ # site - The Site.
25
+ #
26
+ # Returns nothing.
27
+ def generate(site)
28
+
29
+ # Retrieve and merge the configuration from the site yml file
30
+ @config = DEFAULT.merge(site.config['webp'] || {})
31
+
32
+ # If disabled then simply quit
33
+ if !@config['enabled']
34
+ Bridgetown.logger.info "WebP:","Disabled in site.config."
35
+ return
36
+ end
37
+
38
+ Bridgetown.logger.debug "WebP:","Starting"
39
+
40
+ # If the site destination directory has not yet been created then create it now. Otherwise, we cannot write our file there.
41
+ Dir::mkdir(site.dest) if !File.directory? site.dest
42
+
43
+ # If nesting is enabled, get all the nested directories too
44
+ if @config['nested']
45
+ newdir = []
46
+ for imgdir in @config['img_dir']
47
+ # Get every directory below (and including) imgdir, recursively
48
+ newdir.concat(Dir.glob(imgdir + "/**/"))
49
+ end
50
+ @config['img_dir'] = newdir
51
+ end
52
+
53
+ # Counting the number of files generated
54
+ file_count = 0
55
+
56
+ # Iterate through every image in each of the image folders and create a webp image
57
+ # if one has not been created already for that image.
58
+ for imgdir in @config['img_dir']
59
+ imgdir_source = File.join(site.source, imgdir)
60
+ imgdir_destination = File.join(site.dest, imgdir)
61
+ FileUtils::mkdir_p(imgdir_destination)
62
+ Bridgetown.logger.info "WebP:","Processing #{imgdir_source}"
63
+
64
+ # handle only jpg, jpeg, png and gif
65
+ for imgfile in Dir[imgdir_source + "**/*.*"]
66
+ imgfile_relative_path = File.dirname(imgfile.sub(imgdir_source, ""))
67
+
68
+ # Skip empty stuff
69
+ file_ext = File.extname(imgfile).downcase
70
+
71
+ # If the file is not one of the supported formats, exit early
72
+ next if !@config['formats'].include? file_ext
73
+
74
+ # TODO: Do an exclude check
75
+
76
+ # Create the output file path
77
+ outfile_filename = if @config['append_ext']
78
+ File.basename(imgfile) + '.webp'
79
+ else
80
+ file_noext = File.basename(imgfile, file_ext)
81
+ file_noext + ".webp"
82
+ end
83
+ FileUtils::mkdir_p(imgdir_destination + imgfile_relative_path)
84
+ outfile_fullpath_webp = File.join(imgdir_destination + imgfile_relative_path, outfile_filename)
85
+
86
+ # Check if the file already has a webp alternative?
87
+ # If we're force rebuilding all webp files then ignore the check
88
+ # also check the modified time on the files to ensure that the webp file
89
+ # is newer than the source file, if not then regenerate
90
+ if @config['regenerate'] || !File.file?(outfile_fullpath_webp) ||
91
+ File.mtime(outfile_fullpath_webp) <= File.mtime(imgfile)
92
+ Bridgetown.logger.info "WebP:", "Change to source image file #{imgfile} detected, regenerating WebP"
93
+
94
+ # Generate the file
95
+ WebpExec.run(@config['quality'], @config['flags'], imgfile, outfile_fullpath_webp)
96
+ file_count += 1
97
+ end
98
+ if File.file?(outfile_fullpath_webp)
99
+ # Keep the webp file from being cleaned by Bridgetown
100
+ site.static_files << WebpFile.new(site,
101
+ site.dest,
102
+ File.join(imgdir, imgfile_relative_path),
103
+ outfile_filename)
104
+ end
105
+ end # dir.foreach
106
+ end # img_dir
107
+
108
+ Bridgetown.logger.info "WebP:","Generator Complete: #{file_count} file(s) generated"
109
+
110
+ end #function generate
111
+
112
+ end #class WebPGenerator
113
+
114
+ end #module Webp
115
+ end #module Bridgetown
@@ -0,0 +1,9 @@
1
+ require "bridgetown-webp/version"
2
+ require "bridgetown-webp/defaults"
3
+ require "bridgetown-webp/webpExec"
4
+ require "bridgetown-webp/webpGenerator"
5
+
6
+ module Bridgetown
7
+ module Webp
8
+ end # module Webp
9
+ end # module Bridgetown
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bridgetown-webp
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sverrir Sigmundarson
8
+ - Carl Tanner
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2021-09-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bridgetown
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 0.21.4
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 0.21.4
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '2.2'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '2.2'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '13.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '13.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: minitest
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '5.14'
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 5.0.3
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '5.14'
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 5.0.3
76
+ description: WebP Image Generator for Bridgetown sites that automatically generate
77
+ WebP images for all images on your static site and serves them when possible. Includes
78
+ the v0.6.1 version of the WebP utilities for Windows, Linux and Mac OS X 10.9 (Mountain
79
+ Lion)
80
+ email:
81
+ - hello@gocarlgo.com
82
+ executables:
83
+ - console
84
+ - linux-x64-cwebp
85
+ - linux-x86-cwebp
86
+ - osx-cwebp
87
+ - setup
88
+ - win-x64-cwebp.exe
89
+ - win-x86-cwebp.exe
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - LICENSE
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/linux-x64-cwebp
100
+ - bin/linux-x86-cwebp
101
+ - bin/osx-cwebp
102
+ - bin/setup
103
+ - bin/win-x64-cwebp.exe
104
+ - bin/win-x86-cwebp.exe
105
+ - bridgetown-webp.gemspec
106
+ - lib/bridgetown-webp.rb
107
+ - lib/bridgetown-webp/defaults.rb
108
+ - lib/bridgetown-webp/version.rb
109
+ - lib/bridgetown-webp/webp.rb
110
+ - lib/bridgetown-webp/webpExec.rb
111
+ - lib/bridgetown-webp/webpGenerator.rb
112
+ homepage: https://github.com/captproton/bridgetown-webp
113
+ licenses:
114
+ - MIT
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubygems_version: 3.2.15
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: WebP image generator for Bridgetown websites
135
+ test_files: []