jekyll_picture_tag 1.12.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.envrc +4 -0
- data/.github/workflows/code-checks.yml +33 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +31 -3
- data/.ruby-version +1 -1
- data/docs/.envrc +2 -0
- data/docs/devs/contributing/code.md +14 -4
- data/docs/devs/contributing/docs.md +24 -6
- data/docs/devs/contributing/setup.md +21 -1
- data/docs/devs/contributing/testing.md +19 -37
- data/docs/devs/releases.md +45 -4
- data/docs/index.md +43 -18
- data/docs/logo.png +0 -0
- data/docs/logo.svg +880 -0
- data/docs/users/configuration/disable.md +1 -1
- data/docs/users/configuration/ignore_missing.md +1 -1
- data/docs/users/configuration/kramdown_fix.md +1 -1
- data/docs/users/configuration/suppress_warnings.md +1 -1
- data/docs/users/configuration/urls.md +69 -0
- data/docs/users/deployment.md +49 -0
- data/docs/users/getting_started.md +55 -0
- data/docs/users/installation.md +18 -38
- data/docs/users/liquid_tag/argument_reference/crop.md +21 -36
- data/docs/users/liquid_tag/examples.md +12 -12
- data/docs/users/liquid_tag/index.md +1 -1
- data/docs/users/notes/{migration.md → migration_1.md} +1 -1
- data/docs/users/notes/migration_2.md +99 -0
- data/docs/users/presets/cropping.md +24 -25
- data/docs/users/presets/default.md +11 -2
- data/docs/users/presets/examples.md +77 -45
- data/docs/users/presets/fallback_image.md +1 -1
- data/docs/users/presets/html_attributes.md +1 -1
- data/docs/users/presets/image_formats.md +3 -3
- data/docs/users/presets/image_quality.md +96 -19
- data/docs/users/presets/index.md +19 -45
- data/docs/users/presets/link_source.md +1 -1
- data/docs/users/presets/media_queries.md +1 -1
- data/docs/users/presets/nomarkdown_override.md +1 -1
- data/docs/users/presets/pixel_ratio_srcsets.md +1 -1
- data/docs/users/presets/quality_width_graph.png +0 -0
- data/docs/users/presets/width_height_attributes.md +1 -1
- data/docs/users/presets/width_srcsets.md +61 -23
- data/docs/users/presets/writing_presets.md +65 -0
- data/docs/users/tutorial.md +97 -0
- data/jekyll_picture_tag.gemspec +38 -23
- data/lib/jekyll_picture_tag.rb +11 -10
- data/lib/jekyll_picture_tag/cache.rb +64 -3
- data/lib/jekyll_picture_tag/defaults/global.rb +18 -0
- data/lib/jekyll_picture_tag/defaults/presets.rb +57 -0
- data/lib/jekyll_picture_tag/images.rb +4 -0
- data/lib/jekyll_picture_tag/images/generated_image.rb +92 -0
- data/lib/jekyll_picture_tag/images/image_file.rb +104 -0
- data/lib/jekyll_picture_tag/{img_uri.rb → images/img_uri.rb} +3 -10
- data/lib/jekyll_picture_tag/{source_image.rb → images/source_image.rb} +44 -9
- data/lib/jekyll_picture_tag/instructions.rb +70 -6
- data/lib/jekyll_picture_tag/instructions/children/config.rb +128 -0
- data/lib/jekyll_picture_tag/instructions/children/context.rb +24 -0
- data/lib/jekyll_picture_tag/instructions/children/params.rb +90 -0
- data/lib/jekyll_picture_tag/instructions/children/parsers.rb +48 -0
- data/lib/jekyll_picture_tag/instructions/children/preset.rb +182 -0
- data/lib/jekyll_picture_tag/instructions/parents/conditional_instruction.rb +69 -0
- data/lib/jekyll_picture_tag/instructions/parents/env_instruction.rb +29 -0
- data/lib/jekyll_picture_tag/output_formats/basic.rb +5 -17
- data/lib/jekyll_picture_tag/parsers.rb +6 -0
- data/lib/jekyll_picture_tag/{instructions → parsers}/arg_splitter.rb +1 -1
- data/lib/jekyll_picture_tag/parsers/configuration.rb +28 -0
- data/lib/jekyll_picture_tag/{instructions → parsers}/html_attributes.rb +1 -1
- data/lib/jekyll_picture_tag/parsers/image_backend.rb +33 -0
- data/lib/jekyll_picture_tag/parsers/preset.rb +43 -0
- data/lib/jekyll_picture_tag/{instructions → parsers}/tag_parser.rb +15 -12
- data/lib/jekyll_picture_tag/router.rb +35 -93
- data/lib/jekyll_picture_tag/srcsets/basic.rb +4 -10
- data/lib/jekyll_picture_tag/utils.rb +24 -20
- data/lib/jekyll_picture_tag/version.rb +1 -1
- data/readme.md +46 -15
- metadata +168 -85
- data/.travis.yml +0 -8
- data/Dockerfile +0 -9
- data/docs/users/configuration/cdn.md +0 -35
- data/docs/users/configuration/relative_urls.md +0 -15
- data/docs/users/notes/input_checking.md +0 -6
- data/jekyll-picture-tag.gemspec +0 -52
- data/lib/jekyll-picture-tag.rb +0 -25
- data/lib/jekyll_picture_tag/cache/base.rb +0 -59
- data/lib/jekyll_picture_tag/cache/generated.rb +0 -20
- data/lib/jekyll_picture_tag/cache/source.rb +0 -19
- data/lib/jekyll_picture_tag/defaults/global.yml +0 -11
- data/lib/jekyll_picture_tag/defaults/presets.yml +0 -11
- data/lib/jekyll_picture_tag/generated_image.rb +0 -140
- data/lib/jekyll_picture_tag/instructions/configuration.rb +0 -121
- data/lib/jekyll_picture_tag/instructions/preset.rb +0 -107
- data/lib/jekyll_picture_tag/instructions/set.rb +0 -75
data/.travis.yml
DELETED
data/Dockerfile
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
FROM ruby:alpine
|
2
|
-
WORKDIR /root/jekyll_picture_tag
|
3
|
-
# Dependencies for nokogiri, eventmachine, and JPT
|
4
|
-
RUN apk add git imagemagick g++ musl-dev make libstdc++ zlib build-base
|
5
|
-
COPY Gemfile* jekyll_picture_tag.gemspec ./
|
6
|
-
COPY lib/jekyll_picture_tag/version.rb ./lib/jekyll_picture_tag/version.rb
|
7
|
-
RUN bundle install
|
8
|
-
COPY . .
|
9
|
-
CMD rake
|
@@ -1,35 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sort: 5
|
3
|
-
---
|
4
|
-
|
5
|
-
# CDN
|
6
|
-
|
7
|
-
Use for images that are hosted at a different domain or subdomain than the
|
8
|
-
Jekyll site root. Overrides `relative_url`.
|
9
|
-
|
10
|
-
## URL
|
11
|
-
|
12
|
-
*Format:* `cdn_url: (url)`
|
13
|
-
|
14
|
-
*Example:* `cdn_url: https://cdn.example.com`
|
15
|
-
|
16
|
-
*Default*: none
|
17
|
-
|
18
|
-
## Environments
|
19
|
-
|
20
|
-
It's likely that if you're using a CDN, you may not want to use it in your local
|
21
|
-
development environment. This allows you to build a site with local images while
|
22
|
-
in development, and still push to a CDN when you build for production by
|
23
|
-
specifying a different
|
24
|
-
[environment](https://jekyllrb.com/docs/configuration/environments/).
|
25
|
-
|
26
|
-
*Format:* `cdn_environments: (array of strings)`
|
27
|
-
|
28
|
-
*Example:* `cdn_environments: ['production', 'staging']`
|
29
|
-
|
30
|
-
*Default*: `['production']`
|
31
|
-
|
32
|
-
**Note that the default jekyll environment is `development`**, meaning that if
|
33
|
-
you only set `cdn_url` and run `jekyll serve` or `jekyll build`, nothing will
|
34
|
-
change. Either run `JEKYLL_ENV=production bundle exec jekyll build`, or add
|
35
|
-
`development` to this setting.
|
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sort: 6
|
3
|
-
---
|
4
|
-
|
5
|
-
# Use Relative Urls
|
6
|
-
|
7
|
-
*Format:* `relative_url: (true|false)`
|
8
|
-
|
9
|
-
*Example:* `relative_url: false`
|
10
|
-
|
11
|
-
*Default*: `true`
|
12
|
-
|
13
|
-
Whether to use relative (`/generated/test(...).jpg`) or absolute
|
14
|
-
(`https://example.com/generated/test(...).jpg`) urls in your src and srcset
|
15
|
-
attributes.
|
@@ -1,6 +0,0 @@
|
|
1
|
-
# Getting cryptic build errors?
|
2
|
-
|
3
|
-
Jekyll Picture Tag is very trusting. It doesn't do much checking of your inputs, and it does not
|
4
|
-
fail gracefully if you for example pass it a string when it expects an array. It's on the to-do
|
5
|
-
list, but for now if you get cryptic errors then double-check your settings and tag arguments.
|
6
|
-
|
data/jekyll-picture-tag.gemspec
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# Why 2 gemspecs?
|
2
|
-
#
|
3
|
-
# Originally, this gem was named 'jekyll-picture-tag', and published on rubygems
|
4
|
-
# under this name. There was a break in development, during which push access to
|
5
|
-
# rubygems was lost. Development was later resumed, and as a workaround for that
|
6
|
-
# issue the installation instructions were to source the gem from the Github
|
7
|
-
# repository.
|
8
|
-
#
|
9
|
-
# Ultimately, the decision was made to rename it by switching the dashes for
|
10
|
-
# underscores, which follows best practice and allows pushing it to rubygems
|
11
|
-
# under the new name. The drawback of this situation is that everyone who
|
12
|
-
# followed the installaion instructions previously would see their site
|
13
|
-
# inexplicably break, as it would be searching for a gemspec that doesn't exist.
|
14
|
-
# As a workaround (to the old workaround... sigh) this gemspec lets us print a
|
15
|
-
# warning and then require the new version, which keeps old sites working while
|
16
|
-
# encouraging people to use rubygems.
|
17
|
-
|
18
|
-
lib = File.expand_path('lib', __dir__)
|
19
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
20
|
-
require 'jekyll_picture_tag/version'
|
21
|
-
|
22
|
-
Gem::Specification.new do |spec|
|
23
|
-
spec.name = 'jekyll-picture-tag'
|
24
|
-
spec.version = PictureTag::VERSION
|
25
|
-
spec.authors = ['Robert Wierzbowski', 'Brendan Tobolaski',
|
26
|
-
'Robert Buchberger']
|
27
|
-
spec.email = ['robert@buchberger.cc']
|
28
|
-
|
29
|
-
spec.summary = 'Easy responsive images for Jekyll.'
|
30
|
-
spec.description = <<~HEREDOC
|
31
|
-
____ _ _
|
32
|
-
| _ \ ___ _ __ _ __ ___ ___ __ _| |_ ___ __| |
|
33
|
-
| | | |/ _ \ '_ \| '__/ _ \/ __/ _` | __/ _ \/ _` |
|
34
|
-
| |_| | __/ |_) | | | __/ (_| (_| | || __/ (_| |
|
35
|
-
|____/ \___| .__/|_| \___|\___\__,_|\__\___|\__,_|
|
36
|
-
|_|
|
37
|
-
|
38
|
-
This gem has been renamed! Use jekyll_picture_tag instead, which is now
|
39
|
-
hosted on rubygems.
|
40
|
-
HEREDOC
|
41
|
-
spec.homepage = 'https://github.com/rbuchberger/jekyll_picture_tag'
|
42
|
-
spec.license = 'BSD-3-Clause'
|
43
|
-
spec.require_paths = ['lib']
|
44
|
-
|
45
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
46
|
-
f.match(%r{^(test|spec|features)/})
|
47
|
-
end
|
48
|
-
|
49
|
-
spec.required_ruby_version = ['>= 2.5', '< 3']
|
50
|
-
|
51
|
-
spec.add_dependency 'jekyll_picture_tag'
|
52
|
-
end
|
data/lib/jekyll-picture-tag.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# rubocop:disable Naming/FileName
|
2
|
-
puts '-' * 80
|
3
|
-
# rubocop:enable Naming/FileName
|
4
|
-
|
5
|
-
puts <<~HEREDOC
|
6
|
-
\033[31;1;4m
|
7
|
-
Important message from Jekyll Picture Tag:
|
8
|
-
\033[0m
|
9
|
-
Good news! We're back up on rubygems.
|
10
|
-
Bad news. You need to update your Gemfile. Remove the following line:
|
11
|
-
|
12
|
-
gem 'jekyll-picture-tag', git: 'https://github.com/robwierzbowski/jekyll-picture-tag/'
|
13
|
-
|
14
|
-
and replace it with something like:
|
15
|
-
|
16
|
-
gem 'jekyll_picture_tag', '~> 1.6'
|
17
|
-
|
18
|
-
Sorry about that. For an explanation, see issue #120:
|
19
|
-
https://github.com/rbuchberger/jekyll-picture-tag/issues/120
|
20
|
-
|
21
|
-
HEREDOC
|
22
|
-
|
23
|
-
puts '-' * 80
|
24
|
-
|
25
|
-
require 'jekyll_picture_tag'
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module PictureTag
|
4
|
-
module Cache
|
5
|
-
# Basic image information cache functionality
|
6
|
-
module Base
|
7
|
-
def initialize(base_name)
|
8
|
-
@base_name = base_name
|
9
|
-
end
|
10
|
-
|
11
|
-
def [](key)
|
12
|
-
data[key]
|
13
|
-
end
|
14
|
-
|
15
|
-
def []=(key, value)
|
16
|
-
raise ArgumentError unless template.keys.include? key
|
17
|
-
|
18
|
-
data[key] = value
|
19
|
-
end
|
20
|
-
|
21
|
-
# Call after updating data.
|
22
|
-
def write
|
23
|
-
FileUtils.mkdir_p(File.join(base_directory, sub_directory))
|
24
|
-
|
25
|
-
File.open(filename, 'w+') do |f|
|
26
|
-
f.write JSON.generate(data)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def data
|
33
|
-
@data ||= if File.exist?(filename)
|
34
|
-
JSON.parse(File.read(filename)).transform_keys(&:to_sym)
|
35
|
-
else
|
36
|
-
template
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# /home/dave/my_blog/.jekyll-cache/jpt/(cache_dir)/assets/myimage.jpg.json
|
41
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
42
|
-
def base_directory
|
43
|
-
File.join(PictureTag.site.cache_dir, 'jpt', cache_dir)
|
44
|
-
end
|
45
|
-
|
46
|
-
# /home/dave/my_blog/.jekyll-cache/jpt/(cache_dir)/assets/myimage.jpg.json
|
47
|
-
# ^^^^^^^^
|
48
|
-
def sub_directory
|
49
|
-
File.dirname(@base_name)
|
50
|
-
end
|
51
|
-
|
52
|
-
# /home/dave/my_blog/.jekyll-cache/jpt/somefolder/myimage.jpg.json
|
53
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
54
|
-
def filename
|
55
|
-
File.join(base_directory, @base_name + '.json')
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module PictureTag
|
2
|
-
module Cache
|
3
|
-
# Caches generated image details, so we can skip expensive operations whenever
|
4
|
-
# possible.
|
5
|
-
# Stored width and height are values for the source image, after cropping.
|
6
|
-
class Generated
|
7
|
-
include Base
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def cache_dir
|
12
|
-
'generated'
|
13
|
-
end
|
14
|
-
|
15
|
-
def template
|
16
|
-
{ width: nil, height: nil }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module PictureTag
|
2
|
-
module Cache
|
3
|
-
# Caches source image details, so we can skip expensive operations whenever
|
4
|
-
# possible.
|
5
|
-
class Source
|
6
|
-
include Base
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def template
|
11
|
-
{ digest: nil, width: nil, height: nil }
|
12
|
-
end
|
13
|
-
|
14
|
-
def cache_dir
|
15
|
-
'source'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,140 +0,0 @@
|
|
1
|
-
require 'mini_magick'
|
2
|
-
|
3
|
-
module PictureTag
|
4
|
-
# Represents a generated image file.
|
5
|
-
class GeneratedImage
|
6
|
-
attr_reader :width, :format
|
7
|
-
|
8
|
-
include MiniMagick
|
9
|
-
|
10
|
-
def initialize(source_file:, width:, format:, crop: nil, gravity: '')
|
11
|
-
@source = source_file
|
12
|
-
@width = width
|
13
|
-
@format = process_format format
|
14
|
-
@crop = crop
|
15
|
-
@gravity = gravity
|
16
|
-
end
|
17
|
-
|
18
|
-
def exists?
|
19
|
-
File.exist?(absolute_filename)
|
20
|
-
end
|
21
|
-
|
22
|
-
def generate
|
23
|
-
generate_image unless @source.missing || exists?
|
24
|
-
end
|
25
|
-
|
26
|
-
# /home/dave/my_blog/_site/generated/somefolder/myimage-100-123abc.jpg
|
27
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
28
|
-
def absolute_filename
|
29
|
-
@absolute_filename ||= File.join(PictureTag.dest_dir, name)
|
30
|
-
end
|
31
|
-
|
32
|
-
# /home/dave/my_blog/_site/generated/somefolder/myimage-100-123abc.jpg
|
33
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
34
|
-
def name
|
35
|
-
@name ||= "#{@source.base_name}-#{@width}-#{id}.#{@format}"
|
36
|
-
end
|
37
|
-
|
38
|
-
# https://example.com/assets/images/myimage-100-123abc.jpg
|
39
|
-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
40
|
-
def uri
|
41
|
-
ImgURI.new(name).to_s
|
42
|
-
end
|
43
|
-
|
44
|
-
# Post crop
|
45
|
-
def source_width
|
46
|
-
update_cache unless cache[:width]
|
47
|
-
|
48
|
-
cache[:width]
|
49
|
-
end
|
50
|
-
|
51
|
-
# Post crop
|
52
|
-
def source_height
|
53
|
-
update_cache unless cache[:height]
|
54
|
-
|
55
|
-
cache[:height]
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
# We exclude width and format from the cache name, since it isn't specific to them.
|
61
|
-
def cache
|
62
|
-
@cache ||= Cache::Generated.new("#{@source.base_name}-#{id}")
|
63
|
-
end
|
64
|
-
|
65
|
-
def update_cache
|
66
|
-
return if @source.missing
|
67
|
-
|
68
|
-
# Ensure it's generated:
|
69
|
-
image
|
70
|
-
|
71
|
-
cache[:width] = @source_dimensions[:width]
|
72
|
-
cache[:height] = @source_dimensions[:height]
|
73
|
-
|
74
|
-
cache.write
|
75
|
-
end
|
76
|
-
|
77
|
-
# Hash all inputs and truncate, so we know when they change without getting too long.
|
78
|
-
# /home/dave/my_blog/_site/generated/somefolder/myimage-100-1234abcde.jpg
|
79
|
-
# ^^^^^^^^^
|
80
|
-
def id
|
81
|
-
@id ||= Digest::MD5.hexdigest([@source.digest, @crop, @gravity, quality].join)[0..8]
|
82
|
-
end
|
83
|
-
|
84
|
-
# Post crop, before resizing and reformatting
|
85
|
-
def image
|
86
|
-
@image ||= open_image
|
87
|
-
end
|
88
|
-
|
89
|
-
def open_image
|
90
|
-
image_base = Image.open(@source.name)
|
91
|
-
image_base.combine_options do |i|
|
92
|
-
i.auto_orient
|
93
|
-
if @crop
|
94
|
-
i.gravity @gravity
|
95
|
-
i.crop @crop
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
@source_dimensions = { width: image_base.width, height: image_base.height }
|
100
|
-
|
101
|
-
image_base
|
102
|
-
end
|
103
|
-
|
104
|
-
def generate_image
|
105
|
-
puts 'Generating new image file: ' + name
|
106
|
-
process_image
|
107
|
-
write_image
|
108
|
-
end
|
109
|
-
|
110
|
-
def quality
|
111
|
-
PictureTag.quality(@format)
|
112
|
-
end
|
113
|
-
|
114
|
-
def process_image
|
115
|
-
image.combine_options do |i|
|
116
|
-
i.resize "#{@width}x"
|
117
|
-
i.strip
|
118
|
-
end
|
119
|
-
|
120
|
-
image.format @format
|
121
|
-
image.quality quality
|
122
|
-
end
|
123
|
-
|
124
|
-
def write_image
|
125
|
-
FileUtils.mkdir_p(File.dirname(absolute_filename))
|
126
|
-
|
127
|
-
image.write absolute_filename
|
128
|
-
|
129
|
-
FileUtils.chmod(0o644, absolute_filename)
|
130
|
-
end
|
131
|
-
|
132
|
-
def process_format(format)
|
133
|
-
if format.casecmp('original').zero?
|
134
|
-
@source.ext
|
135
|
-
else
|
136
|
-
format.downcase
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
module PictureTag
|
2
|
-
module Instructions
|
3
|
-
# Global config (big picture). loads jekyll data/config files, and the j-p-t
|
4
|
-
# defaults from included yml files.
|
5
|
-
class Configuration
|
6
|
-
# returns jekyll's configuration (picture is a subset)
|
7
|
-
def [](key)
|
8
|
-
content[key]
|
9
|
-
end
|
10
|
-
|
11
|
-
# picturetag specific configuration
|
12
|
-
def pconfig
|
13
|
-
content['picture']
|
14
|
-
end
|
15
|
-
|
16
|
-
# Digs into jekyll context, returns current environment
|
17
|
-
def jekyll_env
|
18
|
-
# It would be really great if the jekyll devs actually documented
|
19
|
-
# the context object.
|
20
|
-
PictureTag.context.environments.first['jekyll']['environment']
|
21
|
-
end
|
22
|
-
|
23
|
-
# Site.source is the master jekyll source directory
|
24
|
-
# Source dir is the jekyll-picture-tag source directory.
|
25
|
-
def source_dir
|
26
|
-
File.join PictureTag.site.source, pconfig['source']
|
27
|
-
end
|
28
|
-
|
29
|
-
# site.dest is the master jekyll destination directory
|
30
|
-
# source_dest is the jekyll-picture-tag destination directory. (generated
|
31
|
-
# file location setting.)
|
32
|
-
def dest_dir
|
33
|
-
File.join PictureTag.site.config['destination'], pconfig['output']
|
34
|
-
end
|
35
|
-
|
36
|
-
def nomarkdown?
|
37
|
-
Utils.markdown_page? && pconfig['nomarkdown']
|
38
|
-
end
|
39
|
-
|
40
|
-
def continue_on_missing?
|
41
|
-
env_check pconfig['ignore_missing_images']
|
42
|
-
rescue ArgumentError
|
43
|
-
raise ArgumentError,
|
44
|
-
<<~HEREDOC
|
45
|
-
continue_on_missing setting invalid. Must be either a boolean
|
46
|
-
(true/false), an environment name, or an array of environment
|
47
|
-
names.
|
48
|
-
HEREDOC
|
49
|
-
end
|
50
|
-
|
51
|
-
def cdn?
|
52
|
-
pconfig['cdn_url'] && pconfig['cdn_environments'].include?(jekyll_env)
|
53
|
-
end
|
54
|
-
|
55
|
-
def disabled?
|
56
|
-
env_check pconfig['disabled']
|
57
|
-
rescue ArgumentError
|
58
|
-
raise ArgumentError,
|
59
|
-
<<~HEREDOC
|
60
|
-
"disabled" setting invalid. Must be either a boolean
|
61
|
-
(true/false), an environment name, or an array of environment
|
62
|
-
names.
|
63
|
-
HEREDOC
|
64
|
-
end
|
65
|
-
|
66
|
-
def fast_build?
|
67
|
-
env_check pconfig['fast_build']
|
68
|
-
rescue ArgumentError
|
69
|
-
raise ArgumentError,
|
70
|
-
<<~HEREDOC
|
71
|
-
"fast_build" setting invalid. Must be either a boolean
|
72
|
-
(true/false), an environment name, or an array of environment
|
73
|
-
names.
|
74
|
-
HEREDOC
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def content
|
80
|
-
@content ||= setting_merge(defaults, PictureTag.site.config)
|
81
|
-
end
|
82
|
-
|
83
|
-
# There are a few config settings which can either be booleans,
|
84
|
-
# environment names, or arrays of environment names. This method works it
|
85
|
-
# out and returns a boolean.
|
86
|
-
def env_check(setting)
|
87
|
-
if setting.is_a? Array
|
88
|
-
setting.include? jekyll_env
|
89
|
-
elsif setting.is_a? String
|
90
|
-
setting == jekyll_env
|
91
|
-
elsif [true, false].include? setting
|
92
|
-
setting
|
93
|
-
else
|
94
|
-
raise ArgumentError,
|
95
|
-
"#{setting} must either be a string, an array, or a boolean."
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def setting_merge(default, jekyll)
|
100
|
-
jekyll.merge default do |_key, config_setting, default_setting|
|
101
|
-
if default_setting.respond_to? :merge
|
102
|
-
setting_merge(default_setting, config_setting)
|
103
|
-
else
|
104
|
-
config_setting
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def defaults
|
110
|
-
# Jekyll Picture Tag Default settings
|
111
|
-
YAML.safe_load(
|
112
|
-
File.read(
|
113
|
-
File.join(
|
114
|
-
ROOT_PATH, 'jekyll_picture_tag/defaults/global.yml'
|
115
|
-
)
|
116
|
-
)
|
117
|
-
)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|