webfontloader 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v1.1.2 (January 21, 2013)
2
+ * Added parameter to Google module to do character based subsetting.
3
+ * Made WebKit useragent check less strict about capitalization for LG L160 phones that apparently use 'AppleWebkit' instead of 'AppleWebKit' in their useragent strings.
4
+
1
5
  v1.1.1 (December 12, 2012)
2
6
  * Added the ability to recognize BlackBerry devices, which have web font support (WOFF) in platform version 10+
3
7
  * Added a new browser name "BuiltinBrowser" to recognize built-in browsers on mobile platforms which we previously called "Safari" (applies to Android's "Browser" app and BlackBerry's built-in browser)
data/lib/webfontloader.rb CHANGED
@@ -3,7 +3,7 @@ require 'yaml'
3
3
  require 'webfontloader/modules'
4
4
 
5
5
  module WebFontLoader
6
- VERSION = '1.1.1'
6
+ VERSION = '1.1.2'
7
7
 
8
8
  ProjectRoot = File.expand_path(File.dirname(__FILE__) + "/..")
9
9
 
@@ -717,3 +717,19 @@ UserAgentTest.prototype.testBrowserBBNotSupportWebfont = function() {
717
717
  assertEquals(undefined, userAgent.getDocumentMode());
718
718
  assertFalse(userAgent.isSupportingWebFont());
719
719
  };
720
+
721
+ UserAgentTest.prototype.testBrowserWebKitVSWebkit = function() {
722
+ var userAgentParser = new webfont.UserAgentParser(
723
+ "Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML like Gecko) Version/4.0 Mobile Safari/534.30",
724
+ this.defaultDocument_);
725
+ var userAgent = userAgentParser.parse();
726
+
727
+ assertEquals("BuiltinBrowser", userAgent.getName());
728
+ assertEquals("Unknown", userAgent.getVersion());
729
+ assertEquals("Android", userAgent.getPlatform());
730
+ assertEquals("4.0.3", userAgent.getPlatformVersion());
731
+ assertEquals("AppleWebKit", userAgent.getEngine());
732
+ assertEquals("534.30", userAgent.getEngineVersion());
733
+ assertEquals(undefined, userAgent.getDocumentMode());
734
+ assertTrue(userAgent.isSupportingWebFont());
735
+ };
@@ -48,3 +48,24 @@ FontApiUrlBuilderTest.prototype.testBuildProperUrlWithSubsetsNoVariations =
48
48
  '?family=Font1:bold,italic%7CFont2:italic%7CFont3' +
49
49
  '&subset=greek,cyrillic,latin', fontApiUrlBuilder.build());
50
50
  };
51
+
52
+
53
+ FontApiUrlBuilderTest.prototype.testBuildProperUrlWithText = function() {
54
+ var fontApiUrlBuilder = new webfont.FontApiUrlBuilder(undefined, "http:", "lorem ipsum");
55
+
56
+ fontApiUrlBuilder.setFontFamilies([ 'Font1', 'Font2' ]);
57
+ assertEquals("http:" + webfont.FontApiUrlBuilder.DEFAULT_API_URL +
58
+ '?family=Font1%7CFont2' +
59
+ '&text=lorem%20ipsum', fontApiUrlBuilder.build());
60
+ };
61
+
62
+
63
+ FontApiUrlBuilderTest.prototype.testBuildProperUrlWithEmptyText = function() {
64
+ var fontApiUrlBuilder = new webfont.FontApiUrlBuilder(undefined, "http:", "");
65
+
66
+ fontApiUrlBuilder.setFontFamilies([ 'Font1:bold:greek,cyrillic',
67
+ 'Font2:italic', 'Font3' ]);
68
+ assertEquals("http:" + webfont.FontApiUrlBuilder.DEFAULT_API_URL +
69
+ '?family=Font1:bold%7CFont2:italic%7CFont3' +
70
+ '&subset=greek,cyrillic', fontApiUrlBuilder.build());
71
+ };
@@ -223,7 +223,7 @@ webfont.UserAgentParser.prototype.parseOperaUserAgentString_ = function() {
223
223
  * @private
224
224
  */
225
225
  webfont.UserAgentParser.prototype.isWebKit_ = function() {
226
- return this.userAgent_.indexOf("AppleWebKit") != -1;
226
+ return /AppleWeb(K|k)it/.test(this.userAgent_);
227
227
  };
228
228
 
229
229
  /**
@@ -233,7 +233,7 @@ webfont.UserAgentParser.prototype.parseWebKitUserAgentString_ = function() {
233
233
  var platform = this.getPlatform_();
234
234
  var platformVersion = this.getPlatformVersion_();
235
235
  var webKitVersion = this.getMatchingGroup_(this.userAgent_,
236
- /AppleWebKit\/([\d\.\+]+)/, 1);
236
+ /AppleWeb(?:K|k)it\/([\d\.\+]+)/, 1);
237
237
 
238
238
  if (webKitVersion == "") {
239
239
  webKitVersion = webfont.UserAgentParser.UNKNOWN;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @constructor
3
3
  */
4
- webfont.FontApiUrlBuilder = function(apiUrl, protocol) {
4
+ webfont.FontApiUrlBuilder = function(apiUrl, protocol, text) {
5
5
  if (apiUrl) {
6
6
  this.apiUrl_ = apiUrl;
7
7
  } else {
@@ -9,6 +9,7 @@ webfont.FontApiUrlBuilder = function(apiUrl, protocol) {
9
9
  }
10
10
  this.fontFamilies_ = [];
11
11
  this.subsets_ = [];
12
+ this.text_ = text || '';
12
13
  };
13
14
 
14
15
 
@@ -63,5 +64,9 @@ webfont.FontApiUrlBuilder.prototype.build = function() {
63
64
  url += '&subset=' + this.subsets_.join(',');
64
65
  }
65
66
 
67
+ if (this.text_.length > 0) {
68
+ url += '&text=' + encodeURIComponent(this.text_);
69
+ }
70
+
66
71
  return url;
67
72
  };
@@ -35,7 +35,7 @@ webfont.GoogleFontApi.prototype.load = function(onReady) {
35
35
  webfont.GoogleFontApi.prototype.insertLink_ = function(onReady) {
36
36
  var domHelper = this.domHelper_;
37
37
  var fontApiUrlBuilder = new webfont.FontApiUrlBuilder(
38
- this.configuration_['api'], domHelper.getProtocol());
38
+ this.configuration_['api'], domHelper.getProtocol(), this.configuration_['text']);
39
39
  var fontFamilies = this.configuration_['families'];
40
40
  fontApiUrlBuilder.setFontFamilies(fontFamilies);
41
41
 
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'webfontloader'
16
- s.version = '1.1.1'
17
- s.date = '2012-12-12'
16
+ s.version = '1.1.2'
17
+ s.date = '2013-01-21'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
20
20
  ## as you like.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webfontloader
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 1
10
- version: 1.1.1
9
+ - 2
10
+ version: 1.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Carver
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-12-12 00:00:00 Z
19
+ date: 2013-01-21 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  prerelease: false