jekyll-imgix 1.1.0 → 1.2.0
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/LICENSE +24 -0
- data/README.md +60 -13
- data/jekyll-imgix.gemspec +1 -1
- data/lib/jekyll/imgix.rb +82 -18
- data/lib/jekyll/imgix/version.rb +1 -1
- metadata +6 -5
- data/LICENSE.txt +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad542865239aa228fb356a581da7951434cf636f
|
4
|
+
data.tar.gz: 7d0eda8c4b5386e569ff9aa2f1b608aadb6aefbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11714543b0029e5a2015912fb944340695c228f3e6e4636f15d8f43e7c042ddc15752515722d91f83969839b26c1cf041da86be2b736f15b35646a273dc331c5
|
7
|
+
data.tar.gz: 43c326ae062487653bf2939660f13094f07dd95aa7d593834582396da3d61cd02866301a70206b5ffc6e09f9756c6890d775df084275601732587d8f3244743a
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
5
|
+
|
6
|
+
## [1.2.0](https://github.com/imgix/imgix-rb/compare/1.1.0...1.2.0) - December 18, 2019
|
7
|
+
|
8
|
+
* feat: add multi-source support ([#11](https://github.com/imgix/jekyll-imgix/pull/11))
|
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2018, Zebrafish Labs Inc.
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
15
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
16
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
17
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
18
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
19
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
20
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
21
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
22
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
23
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
24
|
+
POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -1,6 +1,23 @@
|
|
1
|
-
|
1
|
+
<!-- ix-docs-ignore -->
|
2
|
+

|
2
3
|
|
3
|
-
A
|
4
|
+
A Jekyll plugin for integrating imgix into Jekyll sites.
|
5
|
+
|
6
|
+
[](https://rubygems.org/gems/jekyll-imgix)
|
7
|
+
[](https://travis-ci.org/imgix/jekyll-imgix)
|
8
|
+

|
9
|
+
[](https://github.com/imgix/jekyll-imgix/blob/master/LICENSE)
|
10
|
+
|
11
|
+
---
|
12
|
+
<!-- /ix-docs-ignore -->
|
13
|
+
|
14
|
+
- [Installation](#installation)
|
15
|
+
- [Configuration](#configuration)
|
16
|
+
- [Multi Source Configuration](#multi-source-configuration)
|
17
|
+
- [Usage](#usage)
|
18
|
+
- [Multi Source Usage](#multi-source-usage)
|
19
|
+
- [Contributing](#contributing)
|
20
|
+
- [Code of Conduct](#code-of-conduct)
|
4
21
|
|
5
22
|
## Installation
|
6
23
|
|
@@ -21,6 +38,31 @@ Then include `jekyll-imgix` in the `gems:` section of your `_config.yml` file:
|
|
21
38
|
gems: [jekyll/imgix]
|
22
39
|
```
|
23
40
|
|
41
|
+
## Configuration
|
42
|
+
|
43
|
+
jekyll-imgix requires a configuration block in your `_config.yml`:
|
44
|
+
|
45
|
+
```yaml
|
46
|
+
imgix:
|
47
|
+
source: assets.imgix.net # Your imgix source address
|
48
|
+
secure_url_token: FACEBEEF12 # (optional) The Secure URL Token associated with your source
|
49
|
+
include_library_param: true # (optional) If `true` all the URLs will include `ixlib` parameter
|
50
|
+
```
|
51
|
+
|
52
|
+
### Multi-source configuration
|
53
|
+
|
54
|
+
In addition to the standard configuration flags, the following options can be used to serve images across different sources.
|
55
|
+
|
56
|
+
```yaml
|
57
|
+
imgix:
|
58
|
+
sources: # imgix source-secure_url_token key-value pairs.
|
59
|
+
assets.imgix.net: FACEBEEF12
|
60
|
+
assets2.imgix.net: # Will generate unsigned URLs
|
61
|
+
default_source: assets.imgix.net # (optional) specify a default source for generating URLs.
|
62
|
+
```
|
63
|
+
|
64
|
+
Note: `sources` and `source` *cannot* be used together.
|
65
|
+
|
24
66
|
## Usage
|
25
67
|
|
26
68
|
**jekyll-imgix does not do anything unless JEKYLL_ENV is set to production**. For example,
|
@@ -29,7 +71,7 @@ production.
|
|
29
71
|
|
30
72
|
jekyll-imgix exposes its functionality as a single Jekyll Filter, `imgix_url`.
|
31
73
|
|
32
|
-
|
74
|
+
Pass an existing image path to it to activate it:
|
33
75
|
|
34
76
|
```html
|
35
77
|
<img src={{ "/images/bear.jpg" | imgix_url }} />
|
@@ -53,22 +95,27 @@ Which would result in the following HTML:
|
|
53
95
|
<img src="https://assets.imgix.net/images/bear.jpg?w=400&h=300" />
|
54
96
|
```
|
55
97
|
|
56
|
-
###
|
98
|
+
### Multi-source usage
|
57
99
|
|
58
|
-
jekyll-imgix
|
100
|
+
To use jekyll-imgix in a multi-source setup:
|
59
101
|
|
60
|
-
```
|
61
|
-
imgix:
|
62
|
-
|
63
|
-
secure_url_token: FACEBEEF12 # (optional) The Secure URL Token associated with your source
|
102
|
+
```html
|
103
|
+
<img src={{ "/images/bear.jpg" | imgix_url: "assets2.imgix.net", w: 400, h: 300 }} />
|
104
|
+
<img src={{ "/images/bear.jpg" | imgix_url: w: 400, h: 300 }} /> <!-- will use default_source from config -->
|
64
105
|
```
|
65
106
|
|
66
|
-
|
107
|
+
Which would generate:
|
67
108
|
|
68
|
-
|
109
|
+
```html
|
110
|
+
<img src="https://assets2.imgix.net/images/bear.jpg?w=400&h=300" />
|
111
|
+
<img src="https://assets.imgix.net/images/bear.jpg?w=400&h=300" />
|
112
|
+
```
|
69
113
|
|
114
|
+
In absence of correctly configured `default_source`, `imgix_url` will report `RuntimeError` if it's used without specifying a valid source.
|
70
115
|
|
71
|
-
##
|
116
|
+
## Contributing
|
72
117
|
|
73
|
-
|
118
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/imgix/jekyll-imgix.
|
74
119
|
|
120
|
+
## Code of Conduct
|
121
|
+
Users contributing to or participating in the development of this project are subject to the terms of imgix's [Code of Conduct](https://github.com/imgix/code-of-conduct).
|
data/jekyll-imgix.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{A simple Ruby gem to bring imgix to your Jekyll site.}
|
13
13
|
spec.homepage = "https://github.com/imgix/jekyll-imgix"
|
14
|
-
spec.license = "
|
14
|
+
spec.license = "BSD-2-Clause"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
17
|
spec.bindir = "exe"
|
data/lib/jekyll/imgix.rb
CHANGED
@@ -4,36 +4,88 @@ require "liquid"
|
|
4
4
|
|
5
5
|
module Jekyll
|
6
6
|
module Imgix
|
7
|
-
def imgix_url(
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
def imgix_url(*args)
|
8
|
+
case args.size
|
9
|
+
when 1
|
10
|
+
path = args[0]
|
11
|
+
source = nil
|
12
|
+
options = {}
|
13
|
+
when 2
|
14
|
+
if args[0].is_a?(String) && args[1].is_a?(Hash)
|
15
|
+
path = args[0]
|
16
|
+
source = nil
|
17
|
+
options = args[1]
|
18
|
+
elsif args[0].is_a?(String) && args[1].is_a?(String)
|
19
|
+
path = args[0]
|
20
|
+
source = args[1]
|
21
|
+
options = {}
|
22
|
+
else
|
23
|
+
raise RuntimeError.new("path and source must be of type String; options must be of type Hash")
|
24
|
+
end
|
25
|
+
when 3
|
26
|
+
path = args[0]
|
27
|
+
source = args[1]
|
28
|
+
options = args[2]
|
29
|
+
else
|
30
|
+
raise RuntimeError.new('path missing')
|
31
|
+
end
|
32
|
+
|
33
|
+
return path unless production?
|
34
|
+
|
35
|
+
verify_config!
|
36
|
+
imgix_client(source).path(path).to_url(options)
|
11
37
|
end
|
12
38
|
|
13
39
|
private
|
14
40
|
|
15
|
-
|
16
|
-
|
41
|
+
DEFAULT_OPTS = {
|
42
|
+
library_param: "jekyll",
|
43
|
+
library_version: VERSION,
|
44
|
+
use_https: true
|
45
|
+
}.freeze
|
46
|
+
|
47
|
+
|
48
|
+
def verify_config!
|
49
|
+
config = @context.registers[:site].config['imgix']
|
50
|
+
unless config
|
17
51
|
raise StandardError.new("No 'imgix' section present in _config.yml. Please see https://github.com/imgix/jekyll-imgix for configuration instructions")
|
18
52
|
end
|
53
|
+
if !(config['source'] || config['sources'])
|
54
|
+
raise StandardError.new("One of 'source', 'sources' is required")
|
55
|
+
end
|
56
|
+
if (config['source'] && config['sources'])
|
57
|
+
raise StandardError.new("'source' and 'sources' can't be used together")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def imgix_client(src)
|
62
|
+
begin
|
63
|
+
return imgix_clients.fetch(src)
|
64
|
+
rescue KeyError
|
65
|
+
raise RuntimeError.new("Unknown source '#{src}'")
|
66
|
+
end
|
19
67
|
end
|
20
68
|
|
21
|
-
def
|
22
|
-
return @
|
69
|
+
def imgix_clients
|
70
|
+
return @imgix_clients if @imgix_clients
|
23
71
|
|
24
|
-
opts =
|
72
|
+
opts = DEFAULT_OPTS.dup
|
25
73
|
opts[:secure_url_token] = secure_url_token if secure_url_token
|
26
74
|
opts[:include_library_param] = include_library_param?
|
27
|
-
@client = ::Imgix::Client.new(opts)
|
28
|
-
end
|
29
75
|
|
30
|
-
|
31
|
-
|
32
|
-
host
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
76
|
+
@imgix_clients = {}
|
77
|
+
sources.map do |source, token|
|
78
|
+
opts[:host] = source
|
79
|
+
opts[:secure_url_token] = token
|
80
|
+
@imgix_clients[source] = ::Imgix::Client.new(opts)
|
81
|
+
end
|
82
|
+
|
83
|
+
begin
|
84
|
+
@imgix_clients[nil] = @imgix_clients.fetch(default_source || source)
|
85
|
+
rescue
|
86
|
+
end
|
87
|
+
|
88
|
+
@imgix_clients
|
37
89
|
end
|
38
90
|
|
39
91
|
def production?
|
@@ -52,6 +104,18 @@ module Jekyll
|
|
52
104
|
ix_config.fetch('source', nil)
|
53
105
|
end
|
54
106
|
|
107
|
+
def sources
|
108
|
+
begin
|
109
|
+
return ix_config.fetch('sources')
|
110
|
+
rescue
|
111
|
+
return { ix_config.fetch('source') => secure_url_token }
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def default_source
|
116
|
+
ix_config.fetch('default_source', nil)
|
117
|
+
end
|
118
|
+
|
55
119
|
def secure_url_token
|
56
120
|
ix_config.fetch('secure_url_token', nil)
|
57
121
|
end
|
data/lib/jekyll/imgix/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-imgix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kellysutton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: imgix
|
@@ -90,8 +90,9 @@ files:
|
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
92
|
- ".travis.yml"
|
93
|
+
- CHANGELOG.md
|
93
94
|
- Gemfile
|
94
|
-
- LICENSE
|
95
|
+
- LICENSE
|
95
96
|
- README.md
|
96
97
|
- Rakefile
|
97
98
|
- bin/console
|
@@ -101,7 +102,7 @@ files:
|
|
101
102
|
- lib/jekyll/imgix/version.rb
|
102
103
|
homepage: https://github.com/imgix/jekyll-imgix
|
103
104
|
licenses:
|
104
|
-
-
|
105
|
+
- BSD-2-Clause
|
105
106
|
metadata: {}
|
106
107
|
post_install_message:
|
107
108
|
rdoc_options: []
|
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
version: '0'
|
120
121
|
requirements: []
|
121
122
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.13
|
123
124
|
signing_key:
|
124
125
|
specification_version: 4
|
125
126
|
summary: A simple Ruby gem to bring imgix to your Jekyll site.
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2015 kellysutton
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|