jekyll-favicon 0.2.5 → 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 +5 -5
- data/.devcontainer/Dockerfile +20 -0
- data/.devcontainer/devcontainer.json +35 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +10 -13
- data/.github/PULL_REQUEST_TEMPLATE.md +11 -9
- data/.github/workflows/gem-push.yml +40 -0
- data/.github/workflows/test.yml +38 -0
- data/.gitignore +5 -0
- data/CHANGELOG.md +44 -0
- data/Gemfile +2 -0
- data/README.md +86 -20
- 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 +9 -9
- 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 -74
- 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 -66
- data/.rubocop.yml +0 -5
- 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 -54
- data/lib/jekyll/favicon/icon.rb +0 -74
- data/lib/jekyll/favicon/metadata.rb +0 -12
- data/lib/jekyll/favicon/templates/chrome.html.erb +0 -5
- 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
data/lib/browserconfig.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'rexml/document'
|
2
|
-
|
3
|
-
# Build browserconfig XML
|
4
|
-
class Browserconfig
|
5
|
-
attr_accessor :document
|
6
|
-
|
7
|
-
def load(source_path, config, prefix)
|
8
|
-
@document = if File.exist? source_path
|
9
|
-
REXML::Document.new File.read source_path
|
10
|
-
else
|
11
|
-
REXML::Document.new
|
12
|
-
end
|
13
|
-
add_browserconfig_schema
|
14
|
-
add_browserconfig_elements config, prefix
|
15
|
-
end
|
16
|
-
|
17
|
-
def add(path, element, attributes = {}, text = nil)
|
18
|
-
parent = @document.elements[path]
|
19
|
-
parent.elements[element] = REXML::Element.new element
|
20
|
-
attributes.each do |key, value|
|
21
|
-
parent.elements[element].add_attribute key, value
|
22
|
-
end
|
23
|
-
parent.add_text text if text
|
24
|
-
end
|
25
|
-
|
26
|
-
def dump
|
27
|
-
output = ''
|
28
|
-
formatter = REXML::Formatters::Pretty.new 2
|
29
|
-
formatter.compact = true
|
30
|
-
formatter.write @document, output
|
31
|
-
output
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def add_browserconfig_schema
|
37
|
-
browserconfig = @document.elements['browserconfig']
|
38
|
-
browserconfig ||= @document.elements.add 'browserconfig'
|
39
|
-
msapplication = browserconfig.elements['msapplication']
|
40
|
-
msapplication ||= browserconfig.elements.add 'msapplication'
|
41
|
-
tile = msapplication.elements['tile']
|
42
|
-
tile || msapplication.elements.add('tile')
|
43
|
-
end
|
44
|
-
|
45
|
-
def add_browserconfig_elements(config, prefix)
|
46
|
-
path = 'browserconfig/msapplication/tile'
|
47
|
-
pathname = Pathname.new prefix
|
48
|
-
add path, 'square70x70logo', 'src' => pathname.join('favicon-128x128.png')
|
49
|
-
add path, 'square150x150logo', 'src' => pathname.join('favicon-270x270.png')
|
50
|
-
add path, 'wide310x150logo', 'src' => pathname.join('favicon-558x270.png')
|
51
|
-
add path, 'square310x310logo', 'src' => pathname.join('favicon-558x558.png')
|
52
|
-
add path, 'TileColor', {}, config['tile-color']
|
53
|
-
end
|
54
|
-
end
|
data/lib/hash.rb
DELETED
data/lib/image.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# Build browserconfig XML
|
2
|
-
module Image
|
3
|
-
def self.convert(source, output, options = {})
|
4
|
-
MiniMagick::Tool::Convert.new do |convert|
|
5
|
-
options_for convert, options
|
6
|
-
convert << source
|
7
|
-
convert << output
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.options_for(convert, options)
|
12
|
-
convert.flatten
|
13
|
-
basic_options convert, options
|
14
|
-
resize_options convert, options
|
15
|
-
odd_options convert, options
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.basic_options(convert, options)
|
19
|
-
convert.background options[:background] if options[:background]
|
20
|
-
convert.define options[:define] if options[:define]
|
21
|
-
convert.density options[:density] if options[:density]
|
22
|
-
convert.alpha options[:alpha] if options[:alpha]
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.resize_options(convert, options)
|
26
|
-
convert.resize options[:resize] if options[:resize]
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.odd_options(convert, options)
|
30
|
-
convert.gravity 'center' if options[:odd]
|
31
|
-
convert.extent options[:resize] if options[:odd] && options[:resize]
|
32
|
-
end
|
33
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
favicon:
|
2
|
-
source: favicon.svg
|
3
|
-
path: /assets/images
|
4
|
-
background: white
|
5
|
-
apple-touch-icon:
|
6
|
-
background: white
|
7
|
-
sizes:
|
8
|
-
- 57x57
|
9
|
-
- 76x76
|
10
|
-
- 120x120
|
11
|
-
- 152x152
|
12
|
-
- 167x167
|
13
|
-
- 180x180
|
14
|
-
safari-pinned-tab:
|
15
|
-
mask-icon-color: '#ffffff'
|
16
|
-
ie:
|
17
|
-
tile-color: '#ffffff'
|
18
|
-
sizes:
|
19
|
-
- 128x128
|
20
|
-
- 270x270
|
21
|
-
- 558x270
|
22
|
-
- 558x558
|
23
|
-
browserconfig:
|
24
|
-
source: browserconfig.xml
|
25
|
-
target: browserconfig.xml
|
26
|
-
chrome:
|
27
|
-
sizes:
|
28
|
-
- 192x192
|
29
|
-
- 96x96
|
30
|
-
- 48x48
|
31
|
-
manifest:
|
32
|
-
source: manifest.webmanifest
|
33
|
-
target: manifest.webmanifest
|
34
|
-
sizes:
|
35
|
-
- 192x192
|
36
|
-
- 96x96
|
37
|
-
- 48x48
|
38
|
-
classic:
|
39
|
-
sizes:
|
40
|
-
- 16x16
|
41
|
-
- 32x32
|
42
|
-
- 64x64
|
43
|
-
- 144x144
|
44
|
-
svg:
|
45
|
-
density: 2000
|
46
|
-
dimensions: 1024x1024
|
47
|
-
png:
|
48
|
-
dimensions: 558x558
|
49
|
-
ico:
|
50
|
-
target: favicon.ico
|
51
|
-
sizes:
|
52
|
-
- 48x48
|
53
|
-
- 32x32
|
54
|
-
- 16x16
|
data/lib/jekyll/favicon/icon.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
module Jekyll
|
2
|
-
module Favicon
|
3
|
-
# Extended static file that generates multpiple favicons
|
4
|
-
class Icon < Jekyll::StaticFile
|
5
|
-
attr_accessor :replica
|
6
|
-
attr_accessor :target
|
7
|
-
|
8
|
-
def initialize(site, source, replica, target, collection = nil)
|
9
|
-
@site = site
|
10
|
-
@base = @site.source
|
11
|
-
@dir = File.dirname source
|
12
|
-
@name = File.basename source
|
13
|
-
@replica = replica
|
14
|
-
@target = target
|
15
|
-
@collection = collection
|
16
|
-
@relative_path = File.join(*[@dir, @name].compact)
|
17
|
-
@extname = File.extname(target)
|
18
|
-
@data = { 'name' => File.basename(target), 'layout' => nil }
|
19
|
-
end
|
20
|
-
|
21
|
-
def destination(dest)
|
22
|
-
basename = File.basename(@target)
|
23
|
-
@site.in_dest_dir(*[dest, destination_rel_dir, basename].compact)
|
24
|
-
end
|
25
|
-
|
26
|
-
def destination_rel_dir
|
27
|
-
File.dirname @target
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def copy_file(dest_path)
|
33
|
-
case @extname
|
34
|
-
when '.svg' then FileUtils.cp @replica, dest_path
|
35
|
-
when '.ico' then Image.convert @replica, dest_path, ico_options
|
36
|
-
when '.png' then Image.convert @replica, dest_path, png_options
|
37
|
-
else Jekyll.logger.warn "Jekyll::Favicon: Can't generate" \
|
38
|
-
" #{dest_path}, extension not supported supported."
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def dimensions
|
43
|
-
basename = File.basename(@target)
|
44
|
-
basename[/favicon-(\d+x\d+).png/, 1].split('x').collect(&:to_i)
|
45
|
-
end
|
46
|
-
|
47
|
-
def png_options
|
48
|
-
options = {}
|
49
|
-
w, h = dimensions
|
50
|
-
options[:background] = background_for dimensions
|
51
|
-
options[:odd] = w != h
|
52
|
-
options[:resize] = dimensions.join('x')
|
53
|
-
options
|
54
|
-
end
|
55
|
-
|
56
|
-
def ico_options
|
57
|
-
options = {}
|
58
|
-
sizes = Favicon.config['ico']['sizes']
|
59
|
-
options[:background] = background_for sizes.first
|
60
|
-
options[:alpha] = 'off'
|
61
|
-
options[:resize] = sizes.first
|
62
|
-
ico_sizes = sizes.collect { |size| size.split('x').first }.join ','
|
63
|
-
options[:define] = "icon:auto-resize=#{ico_sizes}"
|
64
|
-
options
|
65
|
-
end
|
66
|
-
|
67
|
-
def background_for(size)
|
68
|
-
category = Favicon.config['apple-touch-icon']
|
69
|
-
return category['background'] if category['sizes'].include? size
|
70
|
-
Favicon.config['background']
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module Jekyll
|
2
|
-
module Favicon
|
3
|
-
# Extended Page that generate files from ERB templates
|
4
|
-
class Metadata < Jekyll::Page
|
5
|
-
# rubocop:disable Naming/MemoizedInstanceVariableName
|
6
|
-
def read_yaml(*)
|
7
|
-
@data ||= {}
|
8
|
-
end
|
9
|
-
# rubocop:enable Naming/MemoizedInstanceVariableName
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,5 +0,0 @@
|
|
1
|
-
<!-- Chrome -->
|
2
|
-
<%- Favicon.config['chrome']['sizes'].each do |size| -%>
|
3
|
-
<link rel="icon" sizes="<%= size %>" href="<%= File.join prepend_path, Favicon.config['path'], "favicon-#{size}.png" %>">
|
4
|
-
<%- end -%>
|
5
|
-
<link rel="manifest" href="<%= File.join prepend_path, Favicon.config['chrome']['manifest']['target'] %>">
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<!-- Classic -->
|
2
|
-
<%- favicon_ico_path = File.join prepend_path, Favicon.config['ico']['target'] -%>
|
3
|
-
<link rel="shortcut icon" href="<%= favicon_ico_path %>">
|
4
|
-
<link rel="icon" sizes="<%= Favicon.config['ico']['sizes'].join ' ' %>" href="<%= favicon_ico_path %>">
|
5
|
-
<%- favicon_path = File.join prepend_path, Favicon.config['path'] -%>
|
6
|
-
<%- Favicon.config['classic']['sizes'].each do |size| -%>
|
7
|
-
<link rel="icon" sizes="<%= size %>" type="image/png" href="<%= File.join favicon_path, "favicon-#{size}.png" %>">
|
8
|
-
<%- end -%>
|
@@ -1,4 +0,0 @@
|
|
1
|
-
<!-- IE -->
|
2
|
-
<meta name="msapplication-TileColor" content="<%= Favicon.config['ie']['tile-color'] %>">
|
3
|
-
<meta name="msapplication-TileImage" content="<%= File.join prepend_path, Favicon.config['path'], 'favicon-144x144.png' %>">
|
4
|
-
<meta name='msapplication-config' content="<%= File.join prepend_path, Favicon.config['ie']['browserconfig']['target'] %>">
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<!-- Safari -->
|
2
|
-
<%- favicon_path = File.join prepend_path, Favicon.config['path'] -%>
|
3
|
-
<%- Favicon.config['apple-touch-icon']['sizes'].each do |size| -%>
|
4
|
-
<link rel="apple-touch-icon" sizes="<%= size %>" href="<%= File.join favicon_path, "favicon-#{size}.png" %>">
|
5
|
-
<%- end -%>
|
6
|
-
<% if Favicon.config['source'].svg? %>
|
7
|
-
<link rel="mask-icon" color="<%= Favicon.config['safari-pinned-tab']['mask-icon-color'] %>" href="<%= File.join favicon_path, 'safari-pinned-tab.svg' %>">
|
8
|
-
<% end %>
|
data/lib/string.rb
DELETED
data/lib/webmanifest.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# Build Webmanifest JSON
|
2
|
-
class Webmanifest
|
3
|
-
attr_accessor :document
|
4
|
-
|
5
|
-
def load(source_path, config, prefix)
|
6
|
-
@document = if File.exist? source_path
|
7
|
-
JSON.parse File.read source_path
|
8
|
-
else
|
9
|
-
{}
|
10
|
-
end
|
11
|
-
add_webmanifest_elements config, prefix
|
12
|
-
end
|
13
|
-
|
14
|
-
def dump
|
15
|
-
JSON.pretty_generate document
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def add_webmanifest_elements(config, prefix)
|
21
|
-
icons = config['sizes'].collect do |size|
|
22
|
-
{
|
23
|
-
src: File.join(prefix, "favicon-#{size}.png"),
|
24
|
-
type: 'png',
|
25
|
-
sizes: size
|
26
|
-
}
|
27
|
-
end
|
28
|
-
@document = Jekyll::Utils.deep_merge_hashes @document, icons: icons
|
29
|
-
end
|
30
|
-
end
|