jekyll-favicon 0.2.9 → 1.0.0.pre.1
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/.devcontainer/Dockerfile +20 -0
- data/.devcontainer/devcontainer.json +35 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +4 -4
- data/.github/workflows/gem-push.yml +3 -3
- data/.github/workflows/test.yml +38 -0
- data/.gitignore +5 -0
- data/CHANGELOG.md +21 -0
- data/Gemfile +2 -0
- data/README.md +74 -24
- data/Rakefile +9 -7
- data/bin/console +1 -0
- data/config/jekyll/favicon.yml +115 -0
- data/config/jekyll/favicon/static_file.yml +3 -0
- data/config/jekyll/favicon/static_file/convertible.yml +42 -0
- data/config/jekyll/favicon/static_file/mutable.yml +22 -0
- data/config/jekyll/favicon/static_file/referenceable.yml +15 -0
- data/config/jekyll/favicon/static_file/sourceable.yml +3 -0
- data/config/jekyll/favicon/static_file/taggable.yml +22 -0
- data/gemfiles/jekyll36.gemfile +6 -0
- data/gemfiles/jekyll37.gemfile +6 -0
- data/gemfiles/jekyll38.gemfile +6 -0
- data/gemfiles/jekyll39.gemfile +6 -0
- data/gemfiles/jekyll40.gemfile +6 -0
- data/gemfiles/jekyll41.gemfile +6 -0
- data/gemfiles/jekyll42.gemfile +6 -0
- data/jekyll-favicon.gemspec +8 -8
- data/lib/jekyll-favicon.rb +7 -14
- data/lib/jekyll/favicon.rb +19 -13
- data/lib/jekyll/favicon/configuration.rb +73 -0
- data/lib/jekyll/favicon/configuration/defaults.rb +49 -0
- data/lib/jekyll/favicon/generator.rb +11 -84
- data/lib/jekyll/favicon/hooks.rb +12 -10
- data/lib/jekyll/favicon/static_data_file.rb +17 -0
- data/lib/jekyll/favicon/static_file.rb +97 -0
- data/lib/jekyll/favicon/static_file/convertible.rb +118 -0
- data/lib/jekyll/favicon/static_file/mutable.rb +81 -0
- data/lib/jekyll/favicon/static_file/referenceable.rb +22 -0
- data/lib/jekyll/favicon/static_file/sourceable.rb +73 -0
- data/lib/jekyll/favicon/static_file/taggable.rb +59 -0
- data/lib/jekyll/favicon/static_graphic_file.rb +21 -0
- data/lib/jekyll/favicon/tag.rb +14 -16
- data/lib/jekyll/favicon/utils.rb +24 -0
- data/lib/jekyll/favicon/utils/configuration/compact.rb +61 -0
- data/lib/jekyll/favicon/utils/configuration/merge.rb +63 -0
- data/lib/jekyll/favicon/utils/configuration/patch.rb +48 -0
- data/lib/jekyll/favicon/utils/convert.rb +42 -0
- data/lib/jekyll/favicon/utils/tag.rb +54 -0
- data/lib/jekyll/favicon/version.rb +3 -1
- metadata +71 -73
- data/.rubocop.yml +0 -5
- data/.ruby-version +0 -1
- data/.travis.yml +0 -21
- data/Gemfile.lock +0 -97
- data/lib/browserconfig.rb +0 -54
- data/lib/hash.rb +0 -12
- data/lib/image.rb +0 -33
- data/lib/jekyll/favicon/config/defaults.yml +0 -55
- data/lib/jekyll/favicon/icon.rb +0 -73
- data/lib/jekyll/favicon/metadata.rb +0 -12
- data/lib/jekyll/favicon/templates/chrome.html.erb +0 -6
- data/lib/jekyll/favicon/templates/classic.html.erb +0 -8
- data/lib/jekyll/favicon/templates/ie.html.erb +0 -4
- data/lib/jekyll/favicon/templates/safari.html.erb +0 -8
- data/lib/string.rb +0 -14
- data/lib/webmanifest.rb +0 -30
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
defaults: &defaults
|
3
|
+
alpha: null
|
4
|
+
background: null
|
5
|
+
define: null
|
6
|
+
density: null
|
7
|
+
extent: null
|
8
|
+
gravity: null
|
9
|
+
resize: null
|
10
|
+
scale: null
|
11
|
+
.svg:
|
12
|
+
.png:
|
13
|
+
<<: *defaults
|
14
|
+
background: :background
|
15
|
+
density: :max
|
16
|
+
extent: :auto
|
17
|
+
gravity: center
|
18
|
+
scale:
|
19
|
+
.ico:
|
20
|
+
<<: *defaults
|
21
|
+
background: :background
|
22
|
+
define:
|
23
|
+
density: :max
|
24
|
+
extent: :auto
|
25
|
+
gravity: center
|
26
|
+
scale:
|
27
|
+
.svg:
|
28
|
+
<<: *defaults
|
29
|
+
.png:
|
30
|
+
.ico:
|
31
|
+
<<: *defaults
|
32
|
+
background: :background
|
33
|
+
define:
|
34
|
+
extent: :auto
|
35
|
+
gravity: center
|
36
|
+
resize:
|
37
|
+
.png:
|
38
|
+
<<: *defaults
|
39
|
+
background: :background
|
40
|
+
extent: :auto
|
41
|
+
gravity: center
|
42
|
+
resize:
|
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
defaults:
|
3
|
+
webmanifest:
|
4
|
+
icons:
|
5
|
+
# https://developer.mozilla.org/en-US/docs/Web/Manifest/icons
|
6
|
+
- sizes: null
|
7
|
+
src: null
|
8
|
+
type: null
|
9
|
+
purpose: null
|
10
|
+
browserconfig:
|
11
|
+
browserconfig:
|
12
|
+
msapplication:
|
13
|
+
tile:
|
14
|
+
TileColor: :background
|
15
|
+
.json:
|
16
|
+
# https://developer.mozilla.org/en-US/docs/Web/Manifest
|
17
|
+
icons: :references
|
18
|
+
.xml:
|
19
|
+
# https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/dn320426(v=vs.85)?redirectedfrom=MSDN
|
20
|
+
browserconfig:
|
21
|
+
msapplication:
|
22
|
+
tile: :references
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
webmanifest: # https://developer.mozilla.org/en-US/docs/Web/Manifest
|
3
|
+
icons: # https://developer.mozilla.org/en-US/docs/Web/Manifest/icons
|
4
|
+
- sizes: :sizes
|
5
|
+
src: :relative_path
|
6
|
+
type: :mime
|
7
|
+
purpose: null
|
8
|
+
browserconfig: # https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/dn320426(v=vs.85)?redirectedfrom=MSDN
|
9
|
+
browserconfig:
|
10
|
+
msapplication:
|
11
|
+
tile:
|
12
|
+
TileColor: :background
|
13
|
+
___element:
|
14
|
+
name: :logo
|
15
|
+
_src: :relative_path
|
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
link:
|
3
|
+
as: null
|
4
|
+
color: null
|
5
|
+
crossorigin: null
|
6
|
+
disabled: null
|
7
|
+
href: null
|
8
|
+
hreflang: null
|
9
|
+
imagesizes: null
|
10
|
+
imagesrcset: null
|
11
|
+
media: null
|
12
|
+
prefetch: null
|
13
|
+
rel: null
|
14
|
+
sizes: null
|
15
|
+
title: null
|
16
|
+
type: null
|
17
|
+
meta:
|
18
|
+
charset: null
|
19
|
+
content: null
|
20
|
+
http-equiv: null
|
21
|
+
itemprop: null
|
22
|
+
name: null
|
data/jekyll-favicon.gemspec
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
@@ -22,15 +23,14 @@ Gem::Specification.new do |spec|
|
|
22
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
24
|
spec.require_paths = ['lib']
|
24
25
|
|
25
|
-
spec.required_ruby_version = '>= 2.
|
26
|
+
spec.required_ruby_version = '>= 2.5.0'
|
26
27
|
|
27
|
-
spec.add_development_dependency '
|
28
|
-
spec.add_development_dependency 'minitest', '~> 5
|
29
|
-
spec.add_development_dependency 'minitest-
|
30
|
-
spec.add_development_dependency '
|
31
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
32
|
-
spec.add_development_dependency 'rubocop', '~> 0.54.0', '>= 0.54.0'
|
28
|
+
spec.add_development_dependency 'minitest', '~> 5.8'
|
29
|
+
spec.add_development_dependency 'minitest-hooks', '~> 1.5'
|
30
|
+
spec.add_development_dependency 'minitest-reporters', '~> 1.4.3'
|
31
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
33
32
|
|
34
33
|
spec.add_runtime_dependency 'jekyll', '>= 3.0', '< 5.0'
|
35
|
-
spec.add_runtime_dependency 'mini_magick', '
|
34
|
+
spec.add_runtime_dependency 'mini_magick', '~> 4.11'
|
35
|
+
spec.add_runtime_dependency 'rexml', '~> 3.2', '>= 3.2.5'
|
36
36
|
end
|
data/lib/jekyll-favicon.rb
CHANGED
@@ -1,16 +1,9 @@
|
|
1
1
|
# rubocop:disable Naming/FileName
|
2
2
|
# rubocop:enable Naming/FileName
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
require_relative 'jekyll/favicon'
|
11
|
-
require_relative 'jekyll/favicon/version'
|
12
|
-
require_relative 'jekyll/favicon/hooks'
|
13
|
-
require_relative 'jekyll/favicon/metadata'
|
14
|
-
require_relative 'jekyll/favicon/icon'
|
15
|
-
require_relative 'jekyll/favicon/generator'
|
16
|
-
require_relative 'jekyll/favicon/tag'
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'jekyll/favicon'
|
6
|
+
require 'jekyll/favicon/generator'
|
7
|
+
require 'jekyll/favicon/tag'
|
8
|
+
require 'jekyll/favicon/hooks'
|
9
|
+
require 'jekyll/favicon/version'
|
data/lib/jekyll/favicon.rb
CHANGED
@@ -1,26 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'yaml'
|
4
|
+
require 'jekyll/favicon/configuration/defaults'
|
5
|
+
require 'jekyll/favicon/configuration'
|
6
|
+
require 'jekyll/favicon/static_data_file'
|
7
|
+
require 'jekyll/favicon/static_graphic_file'
|
2
8
|
|
3
9
|
module Jekyll
|
4
10
|
# Module for custom configurations and defaults
|
5
11
|
module Favicon
|
6
|
-
|
7
|
-
PROJECT_LIB = File.join GEM_ROOT, 'lib'
|
8
|
-
PROJECT_ROOT = File.join PROJECT_LIB, 'jekyll', 'favicon'
|
9
|
-
defaults_path = File.join PROJECT_ROOT, 'config', 'defaults.yml'
|
10
|
-
DEFAULTS = YAML.load_file(defaults_path)['favicon']
|
12
|
+
include Configuration::Defaults
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
@@config = Jekyll::Utils.deep_merge_hashes DEFAULTS, (overrides || {})
|
14
|
+
def self.configuration(site)
|
15
|
+
Configuration.merged site
|
15
16
|
end
|
16
17
|
|
17
|
-
def self.
|
18
|
-
|
18
|
+
def self.assets(site)
|
19
|
+
configuration(site).fetch('assets', [])
|
20
|
+
.collect { |attributes| build_asset site, attributes }
|
21
|
+
.compact
|
19
22
|
end
|
20
|
-
# rubocop:enable Style/ClassVars
|
21
23
|
|
22
|
-
def self.
|
23
|
-
File.
|
24
|
+
def self.build_asset(site, attributes)
|
25
|
+
asset_class = case File.extname attributes['name']
|
26
|
+
when '.ico', '.png', '.svg' then StaticGraphicFile
|
27
|
+
when '.webmanifest', '.json', '.xml' then StaticDataFile
|
28
|
+
end
|
29
|
+
asset_class&.new site, attributes
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'jekyll/utils'
|
4
|
+
|
5
|
+
module Jekyll
|
6
|
+
module Favicon
|
7
|
+
# Favicon configuration
|
8
|
+
module Configuration
|
9
|
+
def self.merged(site)
|
10
|
+
return from_defaults unless (user_overrides = from_user site)
|
11
|
+
|
12
|
+
user_overrides = unlegacify user_overrides
|
13
|
+
user_merged = Jekyll::Utils.deep_merge_hashes from_defaults,
|
14
|
+
user_overrides
|
15
|
+
standardize user_merged
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.from_user(site)
|
19
|
+
site&.config&.fetch 'favicon', {}
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.from_defaults
|
23
|
+
Favicon.defaults
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.standardize(config)
|
27
|
+
return unless config
|
28
|
+
|
29
|
+
config.merge 'source' => standardize_source(config['source'])
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.standardize_source(source)
|
33
|
+
case source
|
34
|
+
when String then standardize_source_string source
|
35
|
+
when Hash then standardize_source_hash source
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private_class_method :standardize_source
|
40
|
+
|
41
|
+
def self.standardize_source_string(source)
|
42
|
+
dir, name = File.split source
|
43
|
+
{ 'name' => name, 'dir' => dir }
|
44
|
+
end
|
45
|
+
|
46
|
+
private_class_method :standardize_source_string
|
47
|
+
|
48
|
+
def self.standardize_source_hash(source)
|
49
|
+
name_dir, name = File.split source['name']
|
50
|
+
dir = source['dir']
|
51
|
+
source_dir = dir && !dir.empty? ? dir : nil
|
52
|
+
{ 'name' => name, 'dir' => standardize_pathname(source_dir, name_dir) }
|
53
|
+
end
|
54
|
+
|
55
|
+
private_class_method :standardize_source_hash
|
56
|
+
|
57
|
+
def self.standardize_pathname(*paths)
|
58
|
+
Pathname.new(File.join(*paths.compact)).cleanpath.to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
private_class_method :standardize_source_string
|
62
|
+
|
63
|
+
def self.unlegacify(config)
|
64
|
+
options = config.slice 'source', 'dir', 'background', 'assets'
|
65
|
+
path = options['path']
|
66
|
+
options['dir'] ||= path if path
|
67
|
+
options
|
68
|
+
end
|
69
|
+
|
70
|
+
private_class_method :unlegacify
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Jekyll
|
6
|
+
module Favicon
|
7
|
+
ROOT = Pathname.new File.dirname(File.dirname(File.dirname(File.dirname(__dir__))))
|
8
|
+
|
9
|
+
module Configuration
|
10
|
+
# Create configurable for include
|
11
|
+
module Defaults
|
12
|
+
def self.included(base)
|
13
|
+
*modules, class_or_module_name = base_name_to_parts base.name
|
14
|
+
method_name = "#{class_or_module_name}_defaults"
|
15
|
+
define_defaults base, method_name do
|
16
|
+
Defaults.load_defaults(*modules, class_or_module_name)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.load_defaults(*parts)
|
21
|
+
load_file 'config', *parts
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.load_file(*parts)
|
25
|
+
path = Favicon::ROOT.join(*parts).to_s
|
26
|
+
path = "#{path}.yml"
|
27
|
+
YAML.load_file path
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.define_defaults(base, method_name, &block)
|
31
|
+
base.define_singleton_method('defaults', &block)
|
32
|
+
define_method(method_name, &block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.base_name_to_parts(name)
|
36
|
+
name.split('::').collect do |module_or_class|
|
37
|
+
camelcase_to_snakecase module_or_class
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.camelcase_to_snakecase(camelcase)
|
42
|
+
camelcase.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
43
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
44
|
+
.downcase
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,91 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'jekyll/plugin'
|
4
|
+
require 'jekyll/generator'
|
5
|
+
require 'jekyll/favicon'
|
6
|
+
|
1
7
|
module Jekyll
|
2
8
|
module Favicon
|
3
|
-
#
|
9
|
+
# New generator that creates all the stastic icons and metadata files
|
4
10
|
class Generator < Jekyll::Generator
|
5
|
-
|
6
|
-
|
7
|
-
attr_accessor :template
|
8
|
-
|
11
|
+
# :reek:UtilityFunction
|
9
12
|
def generate(site)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
generate_icons && generate_metadata
|
14
|
-
else
|
15
|
-
Jekyll.logger.warn 'Jekyll::Favicon: Missing ' \
|
16
|
-
"#{Favicon.config['source']}, not generating " \
|
17
|
-
'favicons.'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def clean
|
22
|
-
return unless @template
|
23
|
-
@template.close
|
24
|
-
@template.unlink
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def source_path(path = nil)
|
30
|
-
File.join(*[@site.source, path].compact)
|
31
|
-
end
|
32
|
-
|
33
|
-
def favicon_tempfile(source)
|
34
|
-
tempfile = Tempfile.new(['favicon-template', '.png'])
|
35
|
-
options = { background: 'none' }
|
36
|
-
if source.svg?
|
37
|
-
options[:density] = Favicon.config['svg']['density']
|
38
|
-
options[:resize] = Favicon.config['svg']['dimensions']
|
39
|
-
elsif source.png?
|
40
|
-
options[:resize] = Favicon.config['png']['dimensions']
|
41
|
-
end
|
42
|
-
Image.convert source, tempfile.path, options
|
43
|
-
tempfile
|
44
|
-
end
|
45
|
-
|
46
|
-
def generate_icons
|
47
|
-
@site.static_files.push ico_icon
|
48
|
-
@site.static_files.push(*png_icons)
|
49
|
-
@site.static_files.push(*svg_icons)
|
50
|
-
end
|
51
|
-
|
52
|
-
def ico_icon
|
53
|
-
target = Favicon.config['ico']['target']
|
54
|
-
Icon.new @site, Favicon.config['source'], @template.path, target
|
55
|
-
end
|
56
|
-
|
57
|
-
def png_icons
|
58
|
-
Favicon.config.deep_find('sizes').uniq.collect do |size|
|
59
|
-
target = File.join Favicon.config['path'], "favicon-#{size}.png"
|
60
|
-
Icon.new @site, Favicon.config['source'], @template.path, target
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def svg_icons
|
65
|
-
return [] unless Favicon.config['source'].svg?
|
66
|
-
source = Favicon.config['source']
|
67
|
-
%w[safari-pinned-tab.svg].collect do |name|
|
68
|
-
target = File.join Favicon.config['path'], name
|
69
|
-
Icon.new @site, source, source_path(source), target
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def generate_metadata
|
74
|
-
@site.pages.push metadata Browserconfig.new,
|
75
|
-
Favicon.config['ie']['browserconfig']
|
76
|
-
@site.pages.push metadata Webmanifest.new,
|
77
|
-
Favicon.config['chrome']['manifest']
|
78
|
-
end
|
79
|
-
|
80
|
-
def metadata(document, config)
|
81
|
-
page = Metadata.new @site, @site.source,
|
82
|
-
File.dirname(config['target']),
|
83
|
-
File.basename(config['target'])
|
84
|
-
favicon_path = File.join (@site.baseurl || ''), Favicon.config['path']
|
85
|
-
document.load source_path(config['source']), config, favicon_path
|
86
|
-
page.content = document.dump
|
87
|
-
page.data = { 'layout' => nil }
|
88
|
-
page
|
13
|
+
Favicon.assets(site)
|
14
|
+
.select(&:generable?)
|
15
|
+
.each { |asset| site.static_files << asset }
|
89
16
|
end
|
90
17
|
end
|
91
18
|
end
|