social_rails 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/social_rails/templates/social_rails_config.rb +8 -0
- data/lib/social_rails.rb +1 -0
- data/lib/social_rails/apis/base.rb +1 -0
- data/lib/social_rails/apis/facebook.rb +4 -1
- data/lib/social_rails/apis/twitter.rb +5 -2
- data/lib/social_rails/language.rb +36 -0
- data/lib/social_rails/version.rb +1 -1
- metadata +25 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22fd6874e0d38d4c4380ce718741ee84c2c6f110
|
4
|
+
data.tar.gz: 571c06a9d05d13b2601719ba260e3a8e36a358a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1061f7fe504630d83f30bd375e23dd95f8bac0c30b7350983160cc6ab42c1f74372bf81ce9b3e682be7cc4bd5f3358a7bd87433a79a87f306b9b65d074c4d179
|
7
|
+
data.tar.gz: 5276b47d0c692bb0df24d73bdd2a5f96ab63f5befec7ff01058800a892c21b818bc3e298d165ea64c83e09d80671b68f98a2330eddfc6093b527dbfda5c746b5
|
@@ -25,3 +25,11 @@ SocialRails::API::Twitter.configure do |config|
|
|
25
25
|
#config.access_token_secret = ""
|
26
26
|
#config.twitter_name = ""
|
27
27
|
end
|
28
|
+
|
29
|
+
DetectLanguage.configure do |config|
|
30
|
+
# https://detectlanguage.com/
|
31
|
+
config.api_key = "YOUR API KEY"
|
32
|
+
|
33
|
+
# enable secure mode (SSL) if you are passing sensitive data
|
34
|
+
# config.secure = true
|
35
|
+
end
|
data/lib/social_rails.rb
CHANGED
@@ -32,7 +32,10 @@ module SocialRails
|
|
32
32
|
items = []
|
33
33
|
while items.count < self.config.public[:post_count] || feed.size == 0
|
34
34
|
feed.each do |item|
|
35
|
-
|
35
|
+
next unless item.has_key?("message")
|
36
|
+
next unless lang_is_detected?(item["message"])
|
37
|
+
|
38
|
+
items.push(item)
|
36
39
|
return items if items.count == self.config.public[:post_count]
|
37
40
|
end
|
38
41
|
feed = feed.next_page
|
@@ -27,8 +27,11 @@ module SocialRails
|
|
27
27
|
access_token_secret: self.config.access_token_secret
|
28
28
|
})
|
29
29
|
|
30
|
-
latest_tweets = client.user_timeline(self.config.twitter_name, { exclude_replies: true, include_rts: false })
|
31
|
-
|
30
|
+
latest_tweets = client.user_timeline(self.config.twitter_name, { exclude_replies: true, include_rts: false, count: 20 })
|
31
|
+
|
32
|
+
latest_tweets.select!{ |t| languages.include? t.lang } if localized?
|
33
|
+
|
34
|
+
latest_tweets.map!{ |t| client.oembed(t.id, {lang: default_lang}) }
|
32
35
|
end
|
33
36
|
|
34
37
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'detect_language'
|
2
|
+
|
3
|
+
module SocialRails
|
4
|
+
module Language
|
5
|
+
|
6
|
+
def self.included base
|
7
|
+
base.extend LanguageMethods
|
8
|
+
end
|
9
|
+
|
10
|
+
module LanguageMethods
|
11
|
+
|
12
|
+
def localized?
|
13
|
+
return self.config.public.has_key?(:lang) && self.config.public[:lang].is_a?(Array)
|
14
|
+
end
|
15
|
+
|
16
|
+
def languages
|
17
|
+
return self.config.public[:lang]
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_lang
|
21
|
+
self.config.public[:lang] ? self.config.public[:lang].first : 'fr'
|
22
|
+
end
|
23
|
+
|
24
|
+
def lang_is_detected? text
|
25
|
+
return true unless localized?
|
26
|
+
DetectLanguage.detect(text).each do |result|
|
27
|
+
return true if self.config.public[:lang].include? result["language"]
|
28
|
+
end
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/social_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francis G
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '4
|
19
|
+
version: '4'
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '4
|
29
|
+
version: '4'
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: koala
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,6 +78,20 @@ dependencies:
|
|
72
78
|
- - "~>"
|
73
79
|
- !ruby/object:Gem::Version
|
74
80
|
version: '6.0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: detect_language
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '1.1'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '1.1'
|
75
95
|
description: Includes a configurable cache to keep your app from tipping over api
|
76
96
|
limits.
|
77
97
|
email:
|
@@ -117,6 +137,7 @@ files:
|
|
117
137
|
- lib/social_rails/helpers/instagram.rb
|
118
138
|
- lib/social_rails/helpers/tag.rb
|
119
139
|
- lib/social_rails/helpers/twitter.rb
|
140
|
+
- lib/social_rails/language.rb
|
120
141
|
- lib/social_rails/version.rb
|
121
142
|
homepage: https://github.com/ixmedia/social_rails
|
122
143
|
licenses:
|