jekyll-favicon 0.2.3 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: caf32655a87cfda4b33b8a7c71d9b88767a37f6586fc0daf264f46dec0d1720d
4
- data.tar.gz: c7fa97ebcffd2808026f049efabbb5b80e2fcd20254d840e9825f3bdb943811c
2
+ SHA1:
3
+ metadata.gz: 267c48cbc01616267240dda45dad7fb41f60acd8
4
+ data.tar.gz: 3d0017596678b2ec30fe058ff0b99022deeb7305
5
5
  SHA512:
6
- metadata.gz: 5a8de79c35b12649cf20a8f83c706ca1447862a4271b1071216ceb830a7193cd998892ff82277ffc0f93d7932d325cef2841819414bfd5cc12e3f3bee9bc928d
7
- data.tar.gz: a9b0a7bf04a3a13f28b42607cc83845900afb669f636842eff2d22aa7cf37861ec771397f1447cc144b1c72f6c54d5a90af1a26888498791873880b8b4e4f0ec
6
+ metadata.gz: 813ecf6f4517829ba91101fd6c275ec7541910aa343a1b49cde9ac83991a56c37a7fd25fb064f62cddd29ddf90303cd73122eb587b17a31fd6efc6b6b60d5d5a
7
+ data.tar.gz: bf0d9bc8fc038b8c933f1785b98bb5b9ae3e29f0dbbe7253d39293205cc80c7c122d8ac865425b651efaa4f5078765bcbec5bc03b7dd899d76b0402af4db6b72
@@ -10,9 +10,9 @@ A clear and concise description of what the bug is.
10
10
  **To Reproduce**
11
11
  Steps to reproduce the behavior:
12
12
  1. Go to '...'
13
- 2. Click on '....'
14
- 3. Scroll down to '....'
15
- 4. See error
13
+ 2. Create a new project or clone one from '...'
14
+ 3. Add gem
15
+ 4. Bundle/Run/Test/...
16
16
 
17
17
  **Expected behavior**
18
18
  A clear and concise description of what you expected to happen.
@@ -20,16 +20,13 @@ A clear and concise description of what you expected to happen.
20
20
  **Screenshots**
21
21
  If applicable, add screenshots to help explain your problem.
22
22
 
23
- **Desktop (please complete the following information):**
24
- - OS: [e.g. iOS]
25
- - Browser [e.g. chrome, safari]
26
- - Version [e.g. 22]
27
-
28
- **Smartphone (please complete the following information):**
29
- - Device: [e.g. iPhone6]
30
- - OS: [e.g. iOS8.1]
31
- - Browser [e.g. stock browser, safari]
32
- - Version [e.g. 22]
23
+ **Environment:**
24
+ - OS name and version
25
+ - Ruby manager name and version (if present)
26
+ - Ruby version
27
+ - Bundler version
28
+ - Jekyll version
29
+ - Jekyll Favicon version
33
30
 
34
31
  **Additional context**
35
32
  Add any other context about the problem here.
@@ -1,14 +1,16 @@
1
1
  # PR Template
2
2
 
3
- Include at least this concepts:
3
+ - Tell us...
4
+ - what you wanted to achieve
5
+ - how you did it (use Markdown and screenshots if needed)
4
6
 
5
- - Explain what you wanted to achieve
7
+ - Did you...
8
+ - [ ] update the Readme? (if needed)
9
+ - [ ] update the Changelog? (if needed)
10
+ - [ ] update the tests?
11
+ - [ ] run the tests?
12
+ - [ ] check rubocop?
6
13
 
7
- - Explain what you did
14
+ Don't forget to visit [travis-ci](https://travis-ci.org/afaundez/jekyll-favicon/pull_requests) after creating the PR.
8
15
 
9
- - use markdown
10
- - include screenshots if helps to explain
11
-
12
- - Explain how to test it
13
-
14
- Thanks for contrubuting!
16
+ Thanks for contributing!
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.0
data/.travis.yml CHANGED
@@ -1,11 +1,15 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.5.0
5
- - 2.4.3
6
- - 2.3.6
7
- - 2.2.9
4
+ - 2.6.4
5
+ - 2.5.6
6
+ - 2.4.7
7
+ - 2.3.8
8
+ - 2.2.10
8
9
  - 2.1.10
10
+ - 2.1.0
11
+ before_install:
12
+ - if ! [[ `ruby -v | cut -d' ' -f2` > "2.3" ]]; then gem install bundler -v '< 2'; fi;
9
13
  addons:
10
14
  apt:
11
15
  config:
data/CHANGELOG.md CHANGED
@@ -6,25 +6,56 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
- ## [0.2.3] - 2015-03-27
9
+ ## [0.2.8] - 2019-09-11
10
+ ### Changed
11
+ - Upgrade mini_magick 4.9.4 in gemspec for security fix
12
+ - Update gemspec to support Jekyll 4.0
13
+
14
+ ## [0.2.7] - 2019-05-27
15
+ ### Fixed
16
+ - Set default background back to none
17
+ - Restore safari-pinned-tab
18
+ ### Changed
19
+ - Update README outdated stuff
20
+ - Correct typos on README
21
+
22
+ ## [0.2.6] - 2019-03-23
23
+ ### Added
24
+ - Readme troubleshooting for librsvg2-bin package missing
25
+ ### Fixed
26
+ - ICO convert uses background config
27
+
28
+ ## [0.2.5] - 2019-01-16
29
+ ### Changed
30
+ - Strike GraphicsMagick at Readme because it's compatible a this moment
31
+ ### Fixed
32
+ - Skip safari pinned tab when source is not a SVG
33
+
34
+ ## [0.2.4] - 2018-10-05
35
+ ### Fixed
36
+ - Path for favicon.ico in classic template
37
+ - Changelog dates
38
+ ### Changed
39
+ - Drowngrade listen gem for ruby 2.1 compatibility
40
+
41
+ ## [0.2.3] - 2018-08-17
10
42
  ### Added
11
43
  - Changelog
12
44
  - Contributing guide
13
45
  - Issue and Pull Request templates
14
46
  - Improve Readme usage
15
-
16
47
  ### Fixed
17
48
  - Missing baseurl in links from `favicon` tag
18
49
 
19
- ## [0.2.2] - 2015-03-27
50
+ ## [0.2.2] - 2018-04-10
20
51
  ### Fixed
21
52
  - Missing png template
22
53
 
23
- ## [0.2.1] - 2015-03-27
54
+ ## [0.2.1] - 2018-03-27
24
55
  ### Fixed
25
56
  - Jekyll gem version dependency
26
57
 
27
- ## [0.2.0] - 2015-03-27
58
+ ## [0.2.0] - 2018-03-27
28
59
  ### Added
29
60
  - Jekyll generator with ImageMagick dependency
30
61
  - Configuration file options
@@ -33,11 +64,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
33
64
  ### Changed
34
65
  - Templates structure
35
66
 
36
- ## [0.1.2] - 2015-03-17
67
+ ## [0.1.2] - 2018-03-17
37
68
  ### Fixed
38
69
  - Fix gem version
39
70
 
40
- ## [0.1.1] - 2015-03-17
71
+ ## [0.1.1] - 2018-03-17
41
72
  ### Changed
42
73
  - Replace heredoc for ruby >=2.1 compatibility
43
74
 
data/Gemfile.lock CHANGED
@@ -1,28 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll-favicon (0.2.3)
5
- jekyll (~> 3.0)
6
- mini_magick (~> 4.5)
4
+ jekyll-favicon (0.2.8)
5
+ jekyll (>= 3.0, < 5.0)
6
+ mini_magick (>= 4.9.4)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.5.2)
12
- public_suffix (>= 2.0.2, < 4.0)
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
13
  ast (2.4.0)
14
14
  colorator (1.1.0)
15
- concurrent-ruby (1.0.5)
15
+ concurrent-ruby (1.1.5)
16
16
  em-websocket (0.5.1)
17
17
  eventmachine (>= 0.12.9)
18
18
  http_parser.rb (~> 0.6.0)
19
19
  eventmachine (1.2.7)
20
- ffi (1.9.25)
20
+ ffi (1.11.1)
21
21
  forwardable-extended (2.6.0)
22
22
  http_parser.rb (0.6.0)
23
23
  i18n (0.9.5)
24
24
  concurrent-ruby (~> 1.0)
25
- jekyll (3.8.3)
25
+ jekyll (3.8.6)
26
26
  addressable (~> 2.4)
27
27
  colorator (~> 1.0)
28
28
  em-websocket (~> 0.5)
@@ -40,29 +40,31 @@ GEM
40
40
  jekyll-watch (2.0.0)
41
41
  listen (~> 3.0)
42
42
  kramdown (1.17.0)
43
- liquid (4.0.0)
43
+ liquid (4.0.3)
44
44
  listen (3.0.8)
45
45
  rb-fsevent (~> 0.9, >= 0.9.4)
46
46
  rb-inotify (~> 0.9, >= 0.9.7)
47
47
  mercenary (0.3.6)
48
- mini_magick (4.8.0)
49
- mini_portile2 (2.3.0)
48
+ mini_magick (4.9.5)
49
+ mini_portile2 (2.4.0)
50
50
  minitest (5.11.3)
51
- nokogiri (1.8.4)
52
- mini_portile2 (~> 2.3.0)
53
- parallel (1.12.1)
54
- parser (2.5.0.5)
51
+ minitest-hooks (1.5.0)
52
+ minitest (> 5.3)
53
+ nokogiri (1.9.1)
54
+ mini_portile2 (~> 2.4.0)
55
+ parallel (1.13.0)
56
+ parser (2.6.4.0)
55
57
  ast (~> 2.4.0)
56
- pathutil (0.16.1)
58
+ pathutil (0.16.2)
57
59
  forwardable-extended (~> 2.6)
58
- powerpack (0.1.1)
59
- public_suffix (3.0.3)
60
+ powerpack (0.1.2)
61
+ public_suffix (3.1.1)
60
62
  rainbow (3.0.0)
61
63
  rake (10.5.0)
62
64
  rb-fsevent (0.10.3)
63
65
  rb-inotify (0.9.10)
64
66
  ffi (>= 0.5.0, < 2)
65
- rouge (3.2.1)
67
+ rouge (3.10.0)
66
68
  rubocop (0.54.0)
67
69
  parallel (~> 1.10)
68
70
  parser (>= 2.5)
@@ -70,25 +72,26 @@ GEM
70
72
  rainbow (>= 2.2.2, < 4.0)
71
73
  ruby-progressbar (~> 1.7)
72
74
  unicode-display_width (~> 1.0, >= 1.0.1)
73
- ruby-progressbar (1.9.0)
74
- safe_yaml (1.0.4)
75
- sass (3.5.7)
75
+ ruby-progressbar (1.10.1)
76
+ safe_yaml (1.0.5)
77
+ sass (3.7.4)
76
78
  sass-listen (~> 4.0.0)
77
79
  sass-listen (4.0.0)
78
80
  rb-fsevent (~> 0.9, >= 0.9.4)
79
81
  rb-inotify (~> 0.9, >= 0.9.7)
80
- unicode-display_width (1.3.0)
82
+ unicode-display_width (1.6.0)
81
83
 
82
84
  PLATFORMS
83
85
  ruby
84
86
 
85
87
  DEPENDENCIES
86
- bundler (~> 1.16)
88
+ bundler (~> 1.17)
87
89
  jekyll-favicon!
88
90
  minitest (~> 5.0)
91
+ minitest-hooks (~> 1.4, >= 1.4.2)
89
92
  nokogiri (~> 1.8)
90
93
  rake (~> 10.0)
91
94
  rubocop (~> 0.54.0, >= 0.54.0)
92
95
 
93
96
  BUNDLED WITH
94
- 1.16.1
97
+ 1.17.3
data/README.md CHANGED
@@ -9,21 +9,31 @@ This [Jekyll](https://jekyllrb.com) plugin adds:
9
9
  - a [browser configuration schema](https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/dn320426%28v=vs.85%29)
10
10
  - a tag to generate all the corresponding links and metadata needed in the head tag
11
11
 
12
-
13
-
14
12
  ## Prerequisites
15
13
 
16
- Before using this plugin your system must have installed [ImageMagick](http://www.imagemagick.org) (or [GraphicsMagick](http://www.graphicsmagick.org/)).
14
+ Before using this plugin your system must have installed [ImageMagick](http://www.imagemagick.org) ~~(or [GraphicsMagick](http://www.graphicsmagick.org/))~~.
17
15
 
18
16
  Check if it is already installed by running:
19
17
 
20
18
  ```sh
21
19
  $ convert --version
22
- Version: ImageMagick 7.0.7-27 Q16 x86_64 2018-03-18 http://www.imagemagick.org
23
- Copyright: © 1999-2018 ImageMagick Studio LLC
24
- License: http://www.imagemagick.org/script/license.php
25
- Features: Cipher DPC HDRI Modules
26
- Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
20
+ Version: ImageMagick 7.0.8-46 Q16 x86_64 2019-05-19 https://imagemagick.org
21
+ Copyright: © 1999-2019 ImageMagick Studio LLC
22
+ License: https://imagemagick.org/script/license.php
23
+ Features: Cipher DPC HDRI Modules OpenMP(3.1)
24
+ Delegates (built-in): bzlib freetype heic jng jp2 jpeg lcms ltdl lzma openexr png tiff webp xml zlib
25
+ ```
26
+
27
+ If you have a [problem converting SVG files](https://github.com/afaundez/jekyll-favicon/issues/9#issuecomment-473862194), you may need to install the package `librsvg2-bin`. For example, in Ubuntu/Debian systems:
28
+
29
+ ```sh
30
+ sudo apt install librsvg2-bin
31
+ ```
32
+
33
+ If you have a [problem converting SVG files](https://github.com/afaundez/jekyll-favicon/issues/9#issuecomment-473862194), you may need to install the package `librsvg2-bin`. For example, in Ubuntu/Debian systems:
34
+
35
+ ```sh
36
+ sudo apt install librsvg2-bin
27
37
  ```
28
38
 
29
39
  ## Installation
@@ -31,20 +41,20 @@ Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
31
41
  Add this line to your application's Gemfile:
32
42
 
33
43
  ```ruby
34
- gem 'jekyll-favicon', '~> 0.2.3', group: :jekyll_plugins
44
+ gem 'jekyll-favicon', '~> 0.2.8', group: :jekyll_plugins
35
45
  ```
36
46
 
37
47
  ## Usage
38
48
 
39
- If you are going to use this plugin in a hosted build/service, be sure that they include your plugins as part of the process. You can check [running example](https://afaundez.gitlab.io/jekyll-favicon-example/) hosted by [GitLab](https://about.gitlab.com/features/pages/).
49
+ If you are going to use this plugin in a hosted build/service, be sure that they include your plugins as part of the process. You can check [this running example](https://afaundez.gitlab.io/jekyll-favicon-example/) hosted by [GitLab](https://about.gitlab.com/features/pages/).
40
50
 
41
51
  As [Github Pages](https://pages.github.com) build doesn't load custom plugins, this plugin won't work. As an alternative, you can build your site and push all files (for example, build to `docs`, version it and push it, although this works only for project pages).
42
52
 
43
53
  ### Generator
44
54
 
45
- By installing the plugin, it will be automatically active. It will search for the file `/favicon.svg` and generate set of files in `/assets/images` and few more items at the site's root. It also will exclude the original sources from being copied as a regular static file.
55
+ By installing the plugin, it will be automatically activated. It will search for the file `/favicon.svg` and generate a set of files in `/assets/images` and few more items at the site's root. It also will exclude the original sources from being copied as a regular static file.
46
56
 
47
- You can override whit your sites's `_config.yml`:
57
+ You can override these settings in your sites's `_config.yml`:
48
58
 
49
59
  ```yaml
50
60
  favicon:
@@ -24,12 +24,13 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.required_ruby_version = '>= 2.1.0'
26
26
 
27
- spec.add_development_dependency 'bundler', '~> 1.16'
27
+ spec.add_development_dependency 'bundler', '~> 1.17'
28
28
  spec.add_development_dependency 'minitest', '~> 5.0'
29
+ spec.add_development_dependency 'minitest-hooks', '~> 1.4', '>= 1.4.2'
29
30
  spec.add_development_dependency 'nokogiri', '~> 1.8'
30
31
  spec.add_development_dependency 'rake', '~> 10.0'
31
32
  spec.add_development_dependency 'rubocop', '~> 0.54.0', '>= 0.54.0'
32
33
 
33
- spec.add_runtime_dependency 'jekyll', '~> 3.0'
34
- spec.add_runtime_dependency 'mini_magick', '~> 4.5'
34
+ spec.add_runtime_dependency 'jekyll', '>= 3.0', '< 5.0'
35
+ spec.add_runtime_dependency 'mini_magick', '>= 4.9.4'
35
36
  end
@@ -0,0 +1,54 @@
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 ADDED
@@ -0,0 +1,12 @@
1
+ # Extend Hash with deep find of a key return array
2
+ class Hash
3
+ def deep_find(target)
4
+ keys.collect do |key|
5
+ if key == target
6
+ self[key]
7
+ elsif self[key].is_a? Hash
8
+ self[key].deep_find(target)
9
+ end
10
+ end.compact.flatten
11
+ end
12
+ end
data/lib/image.rb ADDED
@@ -0,0 +1,33 @@
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
@@ -3,6 +3,10 @@
3
3
  require 'jekyll'
4
4
  require 'mini_magick'
5
5
  require_relative 'string'
6
+ require_relative 'hash'
7
+ require_relative 'browserconfig'
8
+ require_relative 'webmanifest'
9
+ require_relative 'image'
6
10
  require_relative 'jekyll/favicon'
7
11
  require_relative 'jekyll/favicon/version'
8
12
  require_relative 'jekyll/favicon/hooks'
@@ -1,8 +1,9 @@
1
1
  favicon:
2
2
  source: favicon.svg
3
3
  path: /assets/images
4
+ background: none
4
5
  apple-touch-icon:
5
- background: white
6
+ background: none
6
7
  sizes:
7
8
  - 57x57
8
9
  - 76x76
@@ -19,13 +20,21 @@ favicon:
19
20
  - 270x270
20
21
  - 558x270
21
22
  - 558x558
22
- browserconfig-path: /
23
+ browserconfig:
24
+ source: browserconfig.xml
25
+ target: browserconfig.xml
23
26
  chrome:
24
27
  sizes:
25
28
  - 192x192
26
29
  - 96x96
27
30
  - 48x48
28
- manifest-path: /
31
+ manifest:
32
+ source: manifest.webmanifest
33
+ target: manifest.webmanifest
34
+ sizes:
35
+ - 192x192
36
+ - 96x96
37
+ - 48x48
29
38
  classic:
30
39
  sizes:
31
40
  - 16x16
@@ -38,8 +47,8 @@ favicon:
38
47
  png:
39
48
  dimensions: 558x558
40
49
  ico:
41
- path: /
50
+ target: favicon.ico
42
51
  sizes:
43
- - 48
44
- - 32
45
- - 16
52
+ - 48x48
53
+ - 32x32
54
+ - 16x16
@@ -8,86 +8,84 @@ module Jekyll
8
8
 
9
9
  def generate(site)
10
10
  @site = site
11
- if File.exist? favicon_source
12
- @template = favicon_tempfile
13
- generate_files Favicon.config['path']
11
+ if File.file? source_path Favicon.config['source']
12
+ @template = favicon_tempfile source_path Favicon.config['source']
13
+ generate_icons && generate_metadata
14
14
  else
15
- Jekyll.logger.warn 'Jekyll::Favicon: Missing' \
16
- " #{Favicon.config['source']}, not generating" \
17
- ' favicons.'
15
+ Jekyll.logger.warn 'Jekyll::Favicon: Missing ' \
16
+ "#{Favicon.config['source']}, not generating " \
17
+ 'favicons.'
18
18
  end
19
19
  end
20
20
 
21
21
  def clean
22
- return unless @tempfile
22
+ return unless @template
23
23
  @template.close
24
24
  @template.unlink
25
25
  end
26
26
 
27
27
  private
28
28
 
29
- def generate_files(prefix)
30
- generate_ico_from @template.path
31
- generate_png_from @template.path, prefix
32
- if File.extname(favicon_source) == '.svg'
33
- generate_svg_from favicon_source, prefix,
34
- 'safari-pinned-tab.svg'
35
- end
36
- generate_metadata_from 'browserconfig.xml'
37
- generate_metadata_from 'manifest.webmanifest'
38
- end
39
-
40
- def generate_ico_from(source)
41
- ico_favicon = Icon.new(@site, '', 'favicon.ico', source)
42
- @site.static_files << ico_favicon
29
+ def source_path(path = nil)
30
+ File.join(*[@site.source, path].compact)
43
31
  end
44
32
 
45
- def generate_png_from(source, prefix)
46
- ['classic', 'ie', 'chrome', 'apple-touch-icon'].each do |template|
47
- Favicon.config[template]['sizes'].each do |size|
48
- png_favicon = Icon.new(@site, prefix, "favicon-#{size}.png", source)
49
- @site.static_files << png_favicon
50
- end
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']
51
41
  end
42
+ Image.convert source, tempfile.path, options
43
+ tempfile
52
44
  end
53
45
 
54
- def generate_metadata_from(template)
55
- metadata_page = Metadata.new(@site, @site.source, '', template)
56
- @site.pages << metadata_page
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)
57
50
  end
58
51
 
59
- def generate_svg_from(source, prefix, name)
60
- svg_favicon = Icon.new(@site, prefix, name, source)
61
- @site.static_files << svg_favicon
52
+ def ico_icon
53
+ target = Favicon.config['ico']['target']
54
+ Icon.new @site, Favicon.config['source'], @template.path, target
62
55
  end
63
56
 
64
- def favicon_source
65
- File.join(*[@site.source, Favicon.config['source']].compact)
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
66
62
  end
67
63
 
68
- def favicon_tempfile
69
- tempfile = Tempfile.new(['favicon_template', '.png'])
70
- convert favicon_source, tempfile.path, Favicon.config
71
- tempfile
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
72
71
  end
73
72
 
74
- def convert(source, output, options = {})
75
- MiniMagick::Tool::Convert.new do |convert|
76
- options_for convert, source, options
77
- convert << favicon_source
78
- convert << output
79
- end
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']
80
78
  end
81
79
 
82
- def options_for(convert, source, options)
83
- convert.flatten
84
- convert.background 'none'
85
- if source.svg?
86
- convert.density options['svg']['density']
87
- convert.resize options['svg']['dimensions']
88
- elsif source.png?
89
- convert.resize options['png']['dimensions']
90
- end
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
91
89
  end
92
90
  end
93
91
  end
@@ -1,6 +1,9 @@
1
1
  Jekyll::Hooks.register :site, :after_init do |site|
2
2
  Jekyll::Favicon.merge site.config['favicon']
3
- site.config['exclude'] << Jekyll::Favicon.config['source']
3
+ favicon_config = Jekyll::Favicon.config
4
+ site.config['exclude'] << favicon_config['source']
5
+ site.config['exclude'] << favicon_config['chrome']['manifest']['source']
6
+ site.config['exclude'] << favicon_config['ie']['browserconfig']['source']
4
7
  end
5
8
 
6
9
  Jekyll::Hooks.register :site, :post_write do |site|
@@ -2,44 +2,52 @@ module Jekyll
2
2
  module Favicon
3
3
  # Extended static file that generates multpiple favicons
4
4
  class Icon < Jekyll::StaticFile
5
- attr_accessor :source
5
+ attr_accessor :replica
6
+ attr_accessor :target
6
7
 
7
- def initialize(site, dir, name, source, collection = nil)
8
+ def initialize(site, source, replica, target, collection = nil)
8
9
  @site = site
9
10
  @base = @site.source
10
- @dir = dir
11
- @name = name
12
- @source = source
11
+ @dir = File.dirname source
12
+ @name = File.basename source
13
+ @replica = replica
14
+ @target = target
13
15
  @collection = collection
14
- @relative_path = File.join(*[@dir, name].compact)
15
- @extname = File.extname(@name)
16
- @data = { 'name' => @name, 'layout' => nil }
16
+ @relative_path = File.join(*[@dir, @name].compact)
17
+ @extname = File.extname(target)
18
+ @data = { 'name' => File.basename(target), 'layout' => nil }
17
19
  end
18
20
 
19
- def path
20
- source
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
21
28
  end
22
29
 
23
30
  private
24
31
 
25
32
  def copy_file(dest_path)
26
33
  case @extname
27
- when '.svg' then FileUtils.cp path, dest_path
28
- when '.ico' then convert path, dest_path, ico_options
29
- when '.png' then convert path, dest_path, png_options
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
30
37
  else Jekyll.logger.warn "Jekyll::Favicon: Can't generate" \
31
38
  " #{dest_path}, extension not supported supported."
32
39
  end
33
40
  end
34
41
 
35
42
  def dimensions
36
- @name[/favicon-(\d+x\d+).png/, 1].split('x').collect(&:to_i)
43
+ basename = File.basename(@target)
44
+ basename[/favicon-(\d+x\d+).png/, 1].split('x').collect(&:to_i)
37
45
  end
38
46
 
39
47
  def png_options
40
48
  options = {}
41
- options[:background] = Favicon.config['background']
42
49
  w, h = dimensions
50
+ options[:background] = background_for dimensions
43
51
  options[:odd] = w != h
44
52
  options[:resize] = dimensions.join('x')
45
53
  options
@@ -47,37 +55,18 @@ module Jekyll
47
55
 
48
56
  def ico_options
49
57
  options = {}
50
- options[:background] = Favicon.config['background']
51
- ico_sizes = Favicon.config['ico']['sizes'].join ','
58
+ sizes = Favicon.config['ico']['sizes']
59
+ options[:background] = background_for sizes.first
60
+ options[:resize] = sizes.first
61
+ ico_sizes = sizes.collect { |size| size.split('x').first }.join ','
52
62
  options[:define] = "icon:auto-resize=#{ico_sizes}"
53
63
  options
54
64
  end
55
65
 
56
- def convert(input, output, options = {})
57
- MiniMagick::Tool::Convert.new do |convert|
58
- options_for convert, options
59
- convert << input
60
- convert << output
61
- end
62
- end
63
-
64
- def options_for(convert, options)
65
- convert.flatten
66
- convert.background background_for options[:resize]
67
- convert.define options[:define] if options[:define]
68
- return unless options[:resize]
69
- convert.resize options[:resize]
70
- return unless options[:odd]
71
- convert.gravity 'center'
72
- convert.extent options[:resize]
73
- end
74
-
75
66
  def background_for(size)
76
- if Favicon.config['apple-touch-icon']['sizes'].include? size
77
- Favicon.config['apple-touch-icon']['background']
78
- else
79
- 'none'
80
- end
67
+ category = Favicon.config['apple-touch-icon']
68
+ return category['background'] if category['sizes'].include? size
69
+ Favicon.config['background']
81
70
  end
82
71
  end
83
72
  end
@@ -2,18 +2,11 @@ module Jekyll
2
2
  module Favicon
3
3
  # Extended Page that generate files from ERB templates
4
4
  class Metadata < Jekyll::Page
5
- def initialize(site, base, dir, name)
6
- @site = site
7
- @base = base
8
- @dir = dir
9
- @name = name
10
-
11
- process @name
12
- prepend_path = @site.baseurl || ''
13
- template = File.read File.join Favicon.templates, "#{name}.erb"
14
- self.content = ERB.new(template, nil, '-').result binding
15
- self.data = { 'name' => name, 'layout' => nil }
5
+ # rubocop:disable Naming/MemoizedInstanceVariableName
6
+ def read_yaml(*)
7
+ @data ||= {}
16
8
  end
9
+ # rubocop:enable Naming/MemoizedInstanceVariableName
17
10
  end
18
11
  end
19
12
  end
@@ -2,4 +2,4 @@
2
2
  <%- Favicon.config['chrome']['sizes'].each do |size| -%>
3
3
  <link rel="icon" sizes="<%= size %>" href="<%= File.join prepend_path, Favicon.config['path'], "favicon-#{size}.png" %>">
4
4
  <%- end -%>
5
- <link rel="manifest" href="<%= File.join prepend_path, Favicon.config['chrome']['manifest-path'], 'manifest.webmanifest' %>">
5
+ <link rel="manifest" href="<%= File.join prepend_path, Favicon.config['chrome']['manifest']['target'] %>">
@@ -1,7 +1,8 @@
1
1
  <!-- Classic -->
2
- <link rel="shortcut icon" href="favicon.ico">
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 %>">
3
5
  <%- favicon_path = File.join prepend_path, Favicon.config['path'] -%>
4
- <link rel="icon" sizes="<%= Favicon.config['ico']['sizes'].collect{|s| "#{s}x#{s}"}.join ' ' %>" href="<%= File.join favicon_path, 'favicon.ico' %>">
5
6
  <%- Favicon.config['classic']['sizes'].each do |size| -%>
6
7
  <link rel="icon" sizes="<%= size %>" type="image/png" href="<%= File.join favicon_path, "favicon-#{size}.png" %>">
7
8
  <%- end -%>
@@ -1,4 +1,4 @@
1
1
  <!-- IE -->
2
2
  <meta name="msapplication-TileColor" content="<%= Favicon.config['ie']['tile-color'] %>">
3
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-path'], 'browserconfig.xml' %>">
4
+ <meta name='msapplication-config' content="<%= File.join prepend_path, Favicon.config['ie']['browserconfig']['target'] %>">
@@ -3,4 +3,6 @@
3
3
  <%- Favicon.config['apple-touch-icon']['sizes'].each do |size| -%>
4
4
  <link rel="apple-touch-icon" sizes="<%= size %>" href="<%= File.join favicon_path, "favicon-#{size}.png" %>">
5
5
  <%- end -%>
6
+ <% if Favicon.config['source'].svg? %>
6
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 %>
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Favicon
3
- VERSION = '0.2.3'.freeze
3
+ VERSION = '0.2.8'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,30 @@
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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-favicon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alvaro Faundez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-17 00:00:00.000000000 Z
11
+ date: 2019-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: '1.17'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: '1.17'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,26 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest-hooks
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 1.4.2
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '1.4'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.4.2
41
61
  - !ruby/object:Gem::Dependency
42
62
  name: nokogiri
43
63
  requirement: !ruby/object:Gem::Requirement
@@ -90,30 +110,36 @@ dependencies:
90
110
  name: jekyll
91
111
  requirement: !ruby/object:Gem::Requirement
92
112
  requirements:
93
- - - "~>"
113
+ - - ">="
94
114
  - !ruby/object:Gem::Version
95
115
  version: '3.0'
116
+ - - "<"
117
+ - !ruby/object:Gem::Version
118
+ version: '5.0'
96
119
  type: :runtime
97
120
  prerelease: false
98
121
  version_requirements: !ruby/object:Gem::Requirement
99
122
  requirements:
100
- - - "~>"
123
+ - - ">="
101
124
  - !ruby/object:Gem::Version
102
125
  version: '3.0'
126
+ - - "<"
127
+ - !ruby/object:Gem::Version
128
+ version: '5.0'
103
129
  - !ruby/object:Gem::Dependency
104
130
  name: mini_magick
105
131
  requirement: !ruby/object:Gem::Requirement
106
132
  requirements:
107
- - - "~>"
133
+ - - ">="
108
134
  - !ruby/object:Gem::Version
109
- version: '4.5'
135
+ version: 4.9.4
110
136
  type: :runtime
111
137
  prerelease: false
112
138
  version_requirements: !ruby/object:Gem::Requirement
113
139
  requirements:
114
- - - "~>"
140
+ - - ">="
115
141
  - !ruby/object:Gem::Version
116
- version: '4.5'
142
+ version: 4.9.4
117
143
  description: Jekyll-favicon is a jekyll plugin that adds the tag favicon, generating
118
144
  html tags for favicon.
119
145
  email:
@@ -127,6 +153,7 @@ files:
127
153
  - ".github/PULL_REQUEST_TEMPLATE.md"
128
154
  - ".gitignore"
129
155
  - ".rubocop.yml"
156
+ - ".ruby-version"
130
157
  - ".travis.yml"
131
158
  - CHANGELOG.md
132
159
  - CODE_OF_CONDUCT.md
@@ -139,6 +166,9 @@ files:
139
166
  - bin/console
140
167
  - bin/setup
141
168
  - jekyll-favicon.gemspec
169
+ - lib/browserconfig.rb
170
+ - lib/hash.rb
171
+ - lib/image.rb
142
172
  - lib/jekyll-favicon.rb
143
173
  - lib/jekyll/favicon.rb
144
174
  - lib/jekyll/favicon/config/defaults.yml
@@ -147,14 +177,13 @@ files:
147
177
  - lib/jekyll/favicon/icon.rb
148
178
  - lib/jekyll/favicon/metadata.rb
149
179
  - lib/jekyll/favicon/tag.rb
150
- - lib/jekyll/favicon/templates/browserconfig.xml.erb
151
180
  - lib/jekyll/favicon/templates/chrome.html.erb
152
181
  - lib/jekyll/favicon/templates/classic.html.erb
153
182
  - lib/jekyll/favicon/templates/ie.html.erb
154
- - lib/jekyll/favicon/templates/manifest.webmanifest.erb
155
183
  - lib/jekyll/favicon/templates/safari.html.erb
156
184
  - lib/jekyll/favicon/version.rb
157
185
  - lib/string.rb
186
+ - lib/webmanifest.rb
158
187
  homepage: https://github.com/afaundez/jekyll-favicon
159
188
  licenses:
160
189
  - MIT
@@ -175,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
204
  version: '0'
176
205
  requirements: []
177
206
  rubyforge_project:
178
- rubygems_version: 2.7.3
207
+ rubygems_version: 2.2.0
179
208
  signing_key:
180
209
  specification_version: 4
181
210
  summary: Jekyll plugin for favicon tag generation.
@@ -1,12 +0,0 @@
1
- <browserconfig>
2
- <msapplication>
3
- <tile>
4
- <%- favicon_path = File.join prepend_path, Favicon.config['path'] -%>
5
- <square310x310logo src="<%= File.join favicon_path, 'favicon-558x558.png' %>" />
6
- <wide310x150logo src="<%= File.join favicon_path, 'favicon-558x270.png' %>" />
7
- <square150x150logo src="<%= File.join favicon_path, 'favicon-270x270.png' %>" />
8
- <square70x70logo src="<%= File.join favicon_path, 'favicon-128x128.png' %>" />
9
- <TileColor><%= Favicon.config['ie']['tile-color'] %></TileColor>
10
- </tile>
11
- </msapplication>
12
- </browserconfig>
@@ -1 +0,0 @@
1
- <%= JSON.pretty_generate icons: Favicon.config['chrome']['sizes'].collect{|size| {src: File.join(prepend_path, Favicon.config['path'], "favicon-#{size}.png"), type: 'png', sizes: size}} %>