hyde-fonts 0.2.2 → 0.3.0
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/lib/hyde_fonts/font_face.rb +1 -1
- data/lib/hyde_fonts/hyde_fonts.rb +13 -6
- data/lib/hyde_fonts/provider_google.rb +7 -0
- data/lib/hyde_fonts.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 242b3530eca6d688e79991bc825ce037cd155969a4319e17be919457427d0925
|
4
|
+
data.tar.gz: 3061ebdee76f959ae6ed5dccc9f53f03f75c1ce5b1b72bf67dbd67e87a82bd23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f6b7972b943741ed61f6d95138a727658e7572ef672d431969838fe59af071059d95a09f9f73bd68fae071d92f1f94f87e9d0a8f46cfff8c26ea8b2dc751cd5
|
7
|
+
data.tar.gz: 12b50a5ec6c82c5887cb23c6f3f0a949a96b9cde4206cda61705974d6c0697be94588d236951d7bf6dd738111e7d04348af88c7877cb25aac34eff09346eef99
|
data/lib/hyde_fonts/font_face.rb
CHANGED
@@ -20,8 +20,7 @@ module Jekyll
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def render(context)
|
23
|
-
|
24
|
-
return unless config['enable'] == true
|
23
|
+
return context.registers[:site].config['hyde_fonts']['enable'] == true
|
25
24
|
|
26
25
|
file = context.registers[:site].static_files.find { |file|
|
27
26
|
file.is_a?(Hyde::GeneratedCssFile)
|
@@ -81,18 +80,23 @@ end
|
|
81
80
|
module Hyde
|
82
81
|
class Fonts
|
83
82
|
@@config = {
|
84
|
-
"
|
83
|
+
"data_source_name" => 'fonts',
|
85
84
|
"file_output_path" => 'assets/fonts',
|
86
85
|
"css_output_name" => 'fonts.css',
|
87
86
|
"css_minify" => true,
|
88
87
|
"enable" => true,
|
89
88
|
"fetch_fonts" => true,
|
90
|
-
"keep_files" =>
|
89
|
+
"keep_files" => true
|
91
90
|
}
|
92
91
|
|
93
92
|
def initialize(site)
|
94
93
|
@site = site
|
95
|
-
@config = site.config.dig('hyde_fonts')
|
94
|
+
@config = site.config.dig('hyde_fonts')
|
95
|
+
|
96
|
+
if (@config.nil?)
|
97
|
+
@config = @@config
|
98
|
+
site.config['hyde_fonts'] = @config
|
99
|
+
end
|
96
100
|
|
97
101
|
if config('keep_files') == true
|
98
102
|
@site.config['keep_files'].push(config('file_output_path'))
|
@@ -104,11 +108,14 @@ module Hyde
|
|
104
108
|
end
|
105
109
|
|
106
110
|
def generate
|
111
|
+
return unless config('enable') == true
|
107
112
|
# get faces from jekyll data file
|
108
113
|
font_data = Hyde::FontData.new(data)
|
109
114
|
|
110
115
|
# handle font providers
|
111
116
|
for face in font_data.faces
|
117
|
+
Jekyll.logger.info('Fonts:', "Preparing #{face.name}")
|
118
|
+
|
112
119
|
case face.provider
|
113
120
|
when 'google'
|
114
121
|
Hyde::FontProviderGoogle.new(@site, @config).fetch(face)
|
@@ -133,7 +140,7 @@ module Hyde
|
|
133
140
|
end
|
134
141
|
|
135
142
|
def data
|
136
|
-
@site.data.dig(config('
|
143
|
+
@site.data.dig(config('data_source_name'), 'fonts')
|
137
144
|
end
|
138
145
|
|
139
146
|
def minify(css)
|
@@ -55,9 +55,16 @@ module Hyde
|
|
55
55
|
destination_fname = file.destination('./')
|
56
56
|
|
57
57
|
if @config['keep_files'] == true
|
58
|
+
Jekyll.logger.debug('Fonts:', "file #{filename} already exists.")
|
58
59
|
return if File.exist?(destination_fname)
|
59
60
|
end
|
60
61
|
|
62
|
+
if @config['fetch_fonts'] == false
|
63
|
+
Jekyll.logger.warn('Fonts:', "fetch disabled, no local version of #{filename} found.")
|
64
|
+
return
|
65
|
+
end
|
66
|
+
|
67
|
+
Jekyll.logger.debug('Fonts:', "downloading #{@face.name} from #{@face.provider}")
|
61
68
|
font_uri_payload = Net::HTTP.get(ruleset.uri)
|
62
69
|
file.file_contents = font_uri_payload
|
63
70
|
|
data/lib/hyde_fonts.rb
CHANGED