rails_real_favicon 0.0.13 → 0.1.0
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
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e823c3c86c744d835556fbc0747b5f9ddc4f277851a9a33259602ed721292aeb
|
4
|
+
data.tar.gz: 2c3ea182d7e86b34240a57bb861420395a179e95e2edeb1dcaeadfa514068624
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eca3d64fefdc3cd94904b6a0893e7aad3baa8891c98f488e99132676d1b94b1bf9097882b2c38851d925a247bf5bc6d20b3c8b26088673c343b52dbde8fae9c
|
7
|
+
data.tar.gz: 7131d28b49dd8497b6fc348568ed49554c8107e1d7b6dd387a504d745e2889c99df6cc95b8b1ea8c6270c4e77a4531094d4154a21cc9bbfc54770edaf35147e2
|
@@ -7,9 +7,11 @@ require 'base64'
|
|
7
7
|
|
8
8
|
class FaviconGenerator < Rails::Generators::Base
|
9
9
|
API_KEY = '04641dc33598f5463c2f1ff49dd9e4a617559f4b'
|
10
|
-
|
10
|
+
|
11
11
|
PATH_UNIQUE_KEY = '/Dfv87ZbNh2'
|
12
12
|
|
13
|
+
class_option(:timeout, type: :numeric, aliases: '-t', default: 30)
|
14
|
+
|
13
15
|
def generate_favicon
|
14
16
|
if File.exist?('config/favicon.yml') && defined?(Rails.application.config_for)
|
15
17
|
req = Rails.application.config_for(:favicon)
|
@@ -29,11 +31,16 @@ class FaviconGenerator < Rails::Generators::Base
|
|
29
31
|
req['master_picture']['content'] = Base64.encode64(File.binread(master_pic))
|
30
32
|
|
31
33
|
uri = URI.parse("https://realfavicongenerator.net/api/favicon")
|
32
|
-
|
34
|
+
timeout = options[:timeout]
|
35
|
+
resp = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https", read_timeout: timeout) do |http|
|
33
36
|
request = Net::HTTP::Post.new uri
|
34
37
|
request.body = { favicon_generation: req }.to_json
|
35
38
|
request["Content-Type"] = "application/json"
|
36
|
-
|
39
|
+
begin
|
40
|
+
JSON.parse(http.request(request).body)
|
41
|
+
rescue Net::ReadTimeout
|
42
|
+
raise RuntimeError.new("Operation timed out after #{timeout} seconds, pass a `-t` option for a longer timeout")
|
43
|
+
end
|
37
44
|
end
|
38
45
|
|
39
46
|
zip = resp['favicon_generation_result']['favicon']['package_url']
|
@@ -100,3 +107,4 @@ class FaviconGenerator < Rails::Generators::Base
|
|
100
107
|
end
|
101
108
|
|
102
109
|
end
|
110
|
+
|
@@ -6,5 +6,13 @@
|
|
6
6
|
# to asset_path in the _favicon.html.erb partial.
|
7
7
|
|
8
8
|
Rails.application.config.assets.configure do |env|
|
9
|
-
|
9
|
+
mime_type = 'application/manifest+json'
|
10
|
+
extensions = ['.webmanifest']
|
11
|
+
|
12
|
+
if Sprockets::VERSION.to_i >= 4
|
13
|
+
extensions << '.webmanifest.erb'
|
14
|
+
env.register_preprocessor(mime_type, Sprockets::ERBProcessor)
|
15
|
+
end
|
16
|
+
|
17
|
+
env.register_mime_type(mime_type, extensions: extensions)
|
10
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_real_favicon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philippe Bernard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '2'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '2'
|
61
61
|
description: Generate and install a favicon for all platforms with RealFaviconGenerator.
|
62
62
|
email:
|
63
63
|
- philippe@realfavicongenerator.net
|