twitter-text-js-rails 1.6.1 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0a1d5e77cc40c74c82b726c4b91adcb110c067cf
4
+ data.tar.gz: 08afb9ff103c60b1bfb3157a29bc4414e4c1ca5b
5
+ SHA512:
6
+ metadata.gz: 0fdd70d2e199f69de20c7bf222884ccc5d8a82cb57b791e637e577f117ba78949e89c223c450266b33316a0f5012cc5fb324a9508da56f0f8af4d792d3b09532
7
+ data.tar.gz: 99aad5f186867a6a8f362e02616f4a299939215713e268f391b6740c2541ad4bd5b8790fe42c2730c44f2eb41ad5beeca433075407a08f83f26a2cec4f0ca2ef
data/README.md CHANGED
@@ -11,7 +11,7 @@ Add the following to your gemfile:
11
11
 
12
12
  Add the following directive to your Javascript manifest file (application.js):
13
13
 
14
- //= require twitter-text-js
14
+ //= require twitter-text
15
15
 
16
16
  ## Versioning
17
17
  We will attempt to mirror the versioning of twitter-text-js to the best
@@ -1,5 +1,5 @@
1
1
  module TwitterTextJS
2
2
  module Rails
3
- VERSION = "1.6.1"
3
+ VERSION = "1.9.1"
4
4
  end
5
5
  end
@@ -211,7 +211,7 @@
211
211
  twttr.txt.regexen.validHashtag = regexSupplant(/(#{hashtagBoundary})(#{hashSigns})(#{hashtagAlphaNumeric}*#{hashtagAlpha}#{hashtagAlphaNumeric}*)/gi);
212
212
 
213
213
  // Mention related regex collection
214
- twttr.txt.regexen.validMentionPrecedingChars = /(?:^|[^a-zA-Z0-9_!#$%&*@@]|RT:?)/;
214
+ twttr.txt.regexen.validMentionPrecedingChars = /(?:^|[^a-zA-Z0-9_!#$%&*@@]|(?:rt|RT|rT|Rt):?)/;
215
215
  twttr.txt.regexen.atSigns = /[@@]/;
216
216
  twttr.txt.regexen.validMentionOrList = regexSupplant(
217
217
  '(#{validMentionPrecedingChars})' + // $1: Preceding character
@@ -229,27 +229,59 @@
229
229
  twttr.txt.regexen.validDomainChars = regexSupplant(/[^#{invalidDomainChars}]/);
230
230
  twttr.txt.regexen.validSubdomain = regexSupplant(/(?:(?:#{validDomainChars}(?:[_-]|#{validDomainChars})*)?#{validDomainChars}\.)/);
231
231
  twttr.txt.regexen.validDomainName = regexSupplant(/(?:(?:#{validDomainChars}(?:-|#{validDomainChars})*)?#{validDomainChars}\.)/);
232
- twttr.txt.regexen.validGTLD = regexSupplant(/(?:(?:aero|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel|xxx)(?=[^0-9a-zA-Z]|$))/);
232
+ twttr.txt.regexen.validGTLD = regexSupplant(RegExp(
233
+ '(?:(?:academy|actor|aero|agency|arpa|asia|bar|bargains|berlin|best|bid|bike|biz|blue|boutique|build|builders|' +
234
+ 'buzz|cab|camera|camp|cards|careers|cat|catering|center|ceo|cheap|christmas|cleaning|clothing|club|codes|' +
235
+ 'coffee|com|community|company|computer|construction|contractors|cool|coop|cruises|dance|dating|democrat|' +
236
+ 'diamonds|directory|domains|edu|education|email|enterprises|equipment|estate|events|expert|exposed|farm|fish|' +
237
+ 'flights|florist|foundation|futbol|gallery|gift|glass|gov|graphics|guitars|guru|holdings|holiday|house|' +
238
+ 'immobilien|industries|info|institute|int|international|jobs|kaufen|kim|kitchen|kiwi|koeln|kred|land|lighting|' +
239
+ 'limo|link|luxury|management|mango|marketing|menu|mil|mobi|moda|monash|museum|nagoya|name|net|neustar|ninja|' +
240
+ 'okinawa|onl|org|partners|parts|photo|photography|photos|pics|pink|plumbing|post|pro|productions|properties|' +
241
+ 'pub|qpon|recipes|red|rentals|repair|report|reviews|rich|ruhr|sexy|shiksha|shoes|singles|social|solar|' +
242
+ 'solutions|supplies|supply|support|systems|tattoo|technology|tel|tienda|tips|today|tokyo|tools|training|' +
243
+ 'travel|uno|vacations|ventures|viajes|villas|vision|vote|voting|voto|voyage|wang|watch|wed|wien|wiki|works|' +
244
+ 'xxx|xyz|zone|дети|онлайн|орг|сайт|بازار|شبكة|みんな|中信|中文网|公司|公益|在线|我爱你|政务|游戏|移动|网络|集团|삼성)' +
245
+ '(?=[^0-9a-zA-Z@]|$))'));
233
246
  twttr.txt.regexen.validCCTLD = regexSupplant(RegExp(
234
- "(?:(?:ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|" +
235
- "ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|" +
236
- "ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|" +
237
- "ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|" +
238
- "na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|" +
239
- "sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|" +
240
- "ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)(?=[^0-9a-zA-Z]|$))"));
247
+ '(?:(?:ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bl|bm|bn|bo|bq|br|bs|' +
248
+ 'bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|' +
249
+ 'et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|' +
250
+ 'im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|' +
251
+ 'me|mf|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|' +
252
+ 'pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|' +
253
+ 'sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|' +
254
+ 'ye|yt|za|zm|zw|мон|рф|срб|укр|қаз|الاردن|الجزائر|السعودية|المغرب|امارات|ایران|بھارت|تونس|سودان|سورية|عمان|فلسطين|قطر|مصر|مليسيا|پاکستان|' +
255
+ 'भारत|বাংলা|ভারত|ਭਾਰਤ|ભારત|இந்தியா|இலங்கை|சிங்கப்பூர்|భారత్|ලංකා|ไทย|გე|中国|中國|台湾|台灣|新加坡|' +
256
+ '香港|한국)(?=[^0-9a-zA-Z@]|$))'));
241
257
  twttr.txt.regexen.validPunycode = regexSupplant(/(?:xn--[0-9a-z]+)/);
242
258
  twttr.txt.regexen.validDomain = regexSupplant(/(?:#{validSubdomain}*#{validDomainName}(?:#{validGTLD}|#{validCCTLD}|#{validPunycode}))/);
243
259
  twttr.txt.regexen.validAsciiDomain = regexSupplant(/(?:(?:[\-a-z0-9#{latinAccentChars}]+)\.)+(?:#{validGTLD}|#{validCCTLD}|#{validPunycode})/gi);
244
- twttr.txt.regexen.invalidShortDomain = regexSupplant(/^#{validDomainName}#{validCCTLD}$/);
260
+ twttr.txt.regexen.invalidShortDomain = regexSupplant(/^#{validDomainName}#{validCCTLD}$/i);
245
261
 
246
262
  twttr.txt.regexen.validPortNumber = regexSupplant(/[0-9]+/);
247
263
 
248
264
  twttr.txt.regexen.validGeneralUrlPathChars = regexSupplant(/[a-z0-9!\*';:=\+,\.\$\/%#\[\]\-_~@|&#{latinAccentChars}]/i);
249
- // Allow URL paths to contain balanced parens
265
+ // Allow URL paths to contain up to two nested levels of balanced parens
250
266
  // 1. Used in Wikipedia URLs like /Primer_(film)
251
267
  // 2. Used in IIS sessions like /S(dfd346)/
252
- twttr.txt.regexen.validUrlBalancedParens = regexSupplant(/\(#{validGeneralUrlPathChars}+\)/i);
268
+ // 3. Used in Rdio URLs like /track/We_Up_(Album_Version_(Edited))/
269
+ twttr.txt.regexen.validUrlBalancedParens = regexSupplant(
270
+ '\\(' +
271
+ '(?:' +
272
+ '#{validGeneralUrlPathChars}+' +
273
+ '|' +
274
+ // allow one nested level of balanced parentheses
275
+ '(?:' +
276
+ '#{validGeneralUrlPathChars}*' +
277
+ '\\(' +
278
+ '#{validGeneralUrlPathChars}+' +
279
+ '\\)' +
280
+ '#{validGeneralUrlPathChars}*' +
281
+ ')' +
282
+ ')' +
283
+ '\\)'
284
+ , 'i');
253
285
  // Valid end-of-path chracters (so /foo. does not gobble the period).
254
286
  // 1. Allow =&# for empty URL parameters and other URL-join artifacts
255
287
  twttr.txt.regexen.validUrlPathEndingChars = regexSupplant(/[\+\-a-z0-9=_#\/#{latinAccentChars}]|(?:#{validUrlBalancedParens})/i);
@@ -455,7 +487,7 @@
455
487
  attrs.href = options.hashtagUrlBase + hashtag;
456
488
  attrs.title = "#" + hashtag;
457
489
  attrs["class"] = options.hashtagClass;
458
- if (hashtag[0].match(twttr.txt.regexen.rtl_chars)){
490
+ if (hashtag.charAt(0).match(twttr.txt.regexen.rtl_chars)){
459
491
  attrs["class"] += " rtl";
460
492
  }
461
493
  if (options.targetBlank) {
@@ -660,22 +692,34 @@
660
692
  };
661
693
 
662
694
  twttr.txt.autoLinkWithJSON = function(text, json, options) {
695
+ // map JSON entity to twitter-text entity
696
+ if (json.user_mentions) {
697
+ for (var i = 0; i < json.user_mentions.length; i++) {
698
+ // this is a @mention
699
+ json.user_mentions[i].screenName = json.user_mentions[i].screen_name;
700
+ }
701
+ }
702
+
703
+ if (json.hashtags) {
704
+ for (var i = 0; i < json.hashtags.length; i++) {
705
+ // this is a #hashtag
706
+ json.hashtags[i].hashtag = json.hashtags[i].text;
707
+ }
708
+ }
709
+
710
+ if (json.symbols) {
711
+ for (var i = 0; i < json.symbols.length; i++) {
712
+ // this is a $CASH tag
713
+ json.symbols[i].cashtag = json.symbols[i].text;
714
+ }
715
+ }
716
+
663
717
  // concatenate all entities
664
718
  var entities = [];
665
719
  for (var key in json) {
666
720
  entities = entities.concat(json[key]);
667
721
  }
668
- // map JSON entity to twitter-text entity
669
- for (var i = 0; i < entities.length; i++) {
670
- entity = entities[i];
671
- if (entity.screen_name) {
672
- // this is @mention
673
- entity.screenName = entity.screen_name;
674
- } else if (entity.text) {
675
- // this is #hashtag
676
- entity.hashtag = entity.text;
677
- }
678
- }
722
+
679
723
  // modify indices to UTF-16
680
724
  twttr.txt.modifyIndicesFromUnicodeToUTF16(text, entities);
681
725
 
@@ -1185,7 +1229,7 @@
1185
1229
  twttr.txt.modifyIndicesFromUTF16ToUnicode(text, urlsWithIndices);
1186
1230
 
1187
1231
  for (var i = 0; i < urlsWithIndices.length; i++) {
1188
- // Subtract the length of the original URL
1232
+ // Subtract the length of the original URL
1189
1233
  textLength += urlsWithIndices[i].indices[0] - urlsWithIndices[i].indices[1];
1190
1234
 
1191
1235
  // Add 23 characters for URL starting with https://
@@ -1325,4 +1369,4 @@
1325
1369
  window.twttr = twttr;
1326
1370
  }
1327
1371
  }
1328
- })();
1372
+ })();
metadata CHANGED
@@ -1,50 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter-text-js-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
5
- prerelease:
4
+ version: 1.9.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Einar Jonsson
8
+ - Chris Downey
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-08 00:00:00.000000000 Z
12
+ date: 2014-05-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Injects twitter-text-js into your asset pipeline.
15
- email: einar@codelette.com
15
+ email:
16
+ - einar@codelette.com
17
+ - cdowney@gmail.com
16
18
  executables: []
17
19
  extensions: []
18
20
  extra_rdoc_files: []
19
21
  files:
20
- - lib/twitter-text-js-rails/version.rb
21
- - lib/twitter-text-js-rails.rb
22
- - vendor/assets/javascripts/twitter-text.js
23
22
  - MIT-LICENSE
24
23
  - README.md
25
- homepage: https://github.com/einarj/twitter-rails-js-rails/
26
- licenses: []
24
+ - lib/twitter-text-js-rails.rb
25
+ - lib/twitter-text-js-rails/version.rb
26
+ - vendor/assets/javascripts/twitter-text.js
27
+ homepage: https://github.com/einarj/twitter-text-js-rails/
28
+ licenses:
29
+ - MIT
30
+ metadata: {}
27
31
  post_install_message:
28
32
  rdoc_options: []
29
33
  require_paths:
30
34
  - lib
31
35
  required_ruby_version: !ruby/object:Gem::Requirement
32
- none: false
33
36
  requirements:
34
- - - ! '>='
37
+ - - ">="
35
38
  - !ruby/object:Gem::Version
36
39
  version: '0'
37
40
  required_rubygems_version: !ruby/object:Gem::Requirement
38
- none: false
39
41
  requirements:
40
- - - ! '>='
42
+ - - ">="
41
43
  - !ruby/object:Gem::Version
42
44
  version: '0'
43
45
  requirements: []
44
46
  rubyforge_project:
45
- rubygems_version: 1.8.24
47
+ rubygems_version: 2.2.2
46
48
  signing_key:
47
- specification_version: 3
49
+ specification_version: 4
48
50
  summary: twitter-text-js on Rails
49
51
  test_files: []
50
- has_rdoc: