jekyll_patternbot 0.17.0 → 0.18.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5b1b48946d4900088590b0f4918e67e8ca2c9416cd3ff1f113e88bb85f3e32a
4
- data.tar.gz: 9eea4a3a6c4b2f9d544d4eb8ea0d07a5aad159b68f48939dd91633d36618bf2d
3
+ metadata.gz: aa65836ead9a4a5429088df4b6ecec97521302b347903d133b43529c05954758
4
+ data.tar.gz: a0be48612dc4d7c05d781b5a4c6f2eae713b00fc8a1f5986bcace2b92d3e157f
5
5
  SHA512:
6
- metadata.gz: 319b5d729cf3bd8e1cdd2479a2296d366ef2fae0bd2e142f1e604df64b41ffeefc9c5b2547a7a965221b45a098a050905f98a62984436f1426f4c8d94907f1d1
7
- data.tar.gz: 0f4ac5c853d28a81550f98056ec792653b38b5440d370d8fb7eb195f6e829845854efbcfcdcd492df9f9f1931532f07ad8c64e383b5cd82d0909ef4a70e6fbdc
6
+ metadata.gz: a5acc6c78b4ca5a88c79844a1c0766a0e5544c115e77dbb97d0f07370fb1a8e6a307985875200c73b83581f731ce0e31fcfc352bf1fa95a90618d550a1bdb241
7
+ data.tar.gz: 5ed8fbf0107ff130aaea3ed90773fdf48ef000ee1ab92e9592f9f36dc0741ecaa4b5b91101df7a68c68ff7fc64f58688ca793d6179ea5e7dd3b44c07663037c1
data/CHANGELOG.md CHANGED
@@ -5,6 +5,20 @@ Jekyll Patternbot adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  ---
7
7
 
8
+ ## [0.18.0] — 2019-01-16
9
+
10
+ ### Changed
11
+
12
+ - Fonts now display default weights and styles, for situations where they are default system fonts.
13
+
14
+ ### Fixed
15
+
16
+ - Fixed the font caching to only cache when downloading remote fonts, and only cache the weight information.
17
+ - Fixed the brand pattern display to hide & show “Colors” and “Typefaces” more reliably.
18
+ - Fixed the italic pattern to properly show the typeface’s italic style.
19
+
20
+ ---
21
+
8
22
  ## [0.17.0] — 2019-01-16
9
23
 
10
24
  ### Fixed
@@ -2,7 +2,7 @@
2
2
  <li><code>font-weight: {{include.weight.weight}};</code></li>
3
3
  <li><code>font-style: {{include.style}};</code></li>
4
4
  </ul>
5
- <div class="grid grid-middle" style="font-weight:{{include.weight.weight}};">
5
+ <div class="grid grid-middle" style="font-weight:{{include.weight.weight}}; font-style:{{include.style}};">
6
6
  <div class="patternbot-type-sample-large unit [ xs-1 m-1-5 ]">
7
7
  <p class="yotta push-0" style="font-family:var({{include.font_var}});">Aa Gg<br>Ss Zz</p>
8
8
  </div>
@@ -55,6 +55,19 @@ module JekyllPatternbot
55
55
  weights
56
56
  end
57
57
 
58
+ def self.default_weights(font)
59
+ weights = {
60
+ 'normal' => self.font_weight.clone,
61
+ 'bold' => self.font_weight.clone,
62
+ }
63
+ weights['normal'][:css_name] = font[:css_name]
64
+ weights['normal'][:has_normal] = true
65
+ weights['normal'][:has_italic] = true
66
+ weights['bold'][:css_name] = font[:css_name]
67
+ weights['bold'][:has_normal] = true
68
+ weights
69
+ end
70
+
58
71
  def self.parse_font_file(font_url)
59
72
  if font_url
60
73
  parser = CssParser::Parser.new
@@ -75,34 +88,39 @@ module JekyllPatternbot
75
88
  font[:name_pretty] = font_family
76
89
  font[:raw] = val
77
90
  font[:var] = dec
91
+ font[:css_name] = font_family
78
92
  if available_weights and available_weights.key? font_family_slug
79
93
  font[:weights] = available_weights[font_family_slug]
80
94
  font[:css_name] = available_weights[font_family_slug].values[0][:css_name]
81
95
  end
96
+ font[:weights] = self.default_weights(font) unless font[:weights]
82
97
  font
83
98
  end
84
99
 
85
- def self.parse(font_url, data)
86
- unless PatternbotCache.key?(font_url)
87
- if font_url != false
88
- PatternbotLogger.warn("Patternbot downloaded CSS for fonts from the remote URL: #{font_url}")
100
+ def self.parse_fonts(data, available_weights=false)
101
+ fonts = self.base.clone
102
+ data.each do |dec, val|
103
+ if self.is_font? dec
104
+ fonts[:primary] = self.parse_font(dec, val, available_weights) if dec.match(/^\-\-font\-primary/)
105
+ fonts[:secondary] = self.parse_font(dec, val, available_weights) if dec.match(/^\-\-font\-secondary/)
106
+ fonts[:accent].push self.parse_font(dec, val, available_weights) unless dec.match(/^\-\-font\-(primary|secondary)/)
89
107
  end
90
- fonts = self.base.clone
91
- available_weights = self.parse_font_file(font_url)
92
- data.each do |dec, val|
93
- if self.is_font? dec
94
- fonts[:primary] = self.parse_font(dec, val, available_weights) if dec.match(/\-\-font\-primary/)
95
- fonts[:secondary] = self.parse_font(dec, val, available_weights) if dec.match(/\-\-font\-secondary/)
96
- fonts[:accent].push self.parse_font(dec, val, available_weights) unless dec.match(/\-\-font\-(primary|secondary)/)
97
- end
98
- end
99
- PatternbotCache[font_url] = fonts
108
+ end
109
+ fonts
110
+ end
111
+
112
+ def self.parse(font_url, data)
113
+ unless font_url
114
+ return self.parse_fonts data
100
115
  else
101
- if font_url != false
116
+ unless PatternbotCache.key?(font_url)
117
+ PatternbotCache[font_url] = self.parse_font_file(font_url)
118
+ PatternbotLogger.warn("Patternbot downloaded CSS for fonts from the remote URL: #{font_url}")
119
+ else
102
120
  PatternbotLogger.info("Patternbot used a cached version of the font CSS originally located at: #{font_url}")
103
121
  end
122
+ return self.parse_fonts data, PatternbotCache[font_url]
104
123
  end
105
- PatternbotCache[font_url]
106
124
  end
107
125
 
108
126
  end
@@ -2,13 +2,21 @@ module JekyllPatternbot
2
2
  class BrandProcessor
3
3
 
4
4
  def remove_colors
5
- unless PatternbotData[:css].key? :theme and PatternbotData[:css][:theme].key? :colors and PatternbotData[:css][:theme][:colors] and PatternbotData[:css][:theme][:colors].key? :primary and PatternbotData[:css][:theme][:colors][:primary].length > 0
5
+ begin PatternbotData.dig(:css, :theme, :colors, :primary)
6
+ unless PatternbotData[:css][:theme][:colors][:primary].length > 0
7
+ PatternbotData[:patterns][:internal]['brand'][:config]['patterns'].delete 'colors'
8
+ end
9
+ rescue
6
10
  PatternbotData[:patterns][:internal]['brand'][:config]['patterns'].delete 'colors'
7
11
  end
8
12
  end
9
13
 
10
14
  def remove_typefaces
11
- unless PatternbotData[:css].key? :theme and PatternbotData[:css][:theme].key? :fonts and PatternbotData[:css][:theme][:fonts].key? :primary
15
+ begin PatternbotData.dig(:css, :theme, :fonts, :primary)
16
+ unless PatternbotData.dig(:css, :theme, :fonts, :primary)
17
+ PatternbotData[:patterns][:internal]['brand'][:config]['patterns'].delete 'typefaces'
18
+ end
19
+ rescue
12
20
  PatternbotData[:patterns][:internal]['brand'][:config]['patterns'].delete 'typefaces'
13
21
  end
14
22
  end
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module JekyllPatternbot
2
- VERSION = '0.17.0'
2
+ VERSION = '0.18.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_patternbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas J Bradley