livefyre 1.0.0 → 1.1.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 +8 -8
- data/README.md +29 -27
- data/lib/livefyre/core.rb +24 -11
- data/lib/livefyre/version.rb +1 -1
- data/spec/livefyre/core_spec.rb +7 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWNjYjgzNjFhMWJlNjc4YWY1MjQ5OTcwYzlkNTBjMjdlMjc0ZjM5OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGNhN2I5NjY5NjVjMTczYWNiNjEwNmViOWZhOGIxMjNhNDkzNGQzMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTk5NDRmYzE2NzhmMTkzZTZlZTlmMTIzYzdhZDUxZTllZTFhZGM1ZDVjZWZj
|
10
|
+
MzhmYmI2ODZmNzA5YWRlYzQ3ZWZhZGYyZWQ4YmY1Njk3MmNkOWFjMThkM2Uw
|
11
|
+
YWJmMGFhOTY3NGUxNzYxZWMyYTRjYjRiMGY1ZDJiYmJhMzY5M2Q=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmRhNDlhN2UwNDc2MDI4MjFjYjRhZGNiM2UzYmFlMWIzOTNkZmEyMGE3Yjkw
|
14
|
+
Njc1MGYwNGZkZjQ1NThkZjg2OWViNTFlYmU3NzgwNjI1ZWU5OGM4ZjExYjg3
|
15
|
+
Y2NmYTgxYzZmM2JlM2E4ZjljMDY0MzE0ZTE0MTdmYjhmMTRlOGY=
|
data/README.md
CHANGED
@@ -9,69 +9,71 @@ Add this line to your application's Gemfile:
|
|
9
9
|
|
10
10
|
gem 'livefyre'
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
$ bundle
|
15
|
-
|
16
|
-
Or install it yourself as:
|
12
|
+
Or install it yourself:
|
17
13
|
|
18
14
|
$ gem install livefyre
|
19
15
|
|
20
16
|
## Usage
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
**Livefyre token:**
|
18
|
+
Instantiating a network object:
|
25
19
|
|
26
20
|
```ruby
|
27
|
-
network = Livefyre.get_network(network_name, network_key)
|
28
|
-
network.build_lf_token
|
21
|
+
network = Livefyre.get_network('network_name', 'network_key')
|
29
22
|
```
|
30
23
|
|
31
|
-
|
24
|
+
Building a Livefyre token:
|
32
25
|
|
33
26
|
```ruby
|
34
|
-
network
|
35
|
-
network.build_user_auth_token(user_id, display_name, expires)
|
27
|
+
network.build_livefyre_token
|
36
28
|
```
|
37
29
|
|
38
|
-
|
30
|
+
Building a user auth token:
|
39
31
|
|
40
32
|
```ruby
|
41
|
-
network
|
42
|
-
|
43
|
-
site = network.get_site(site_id, site_key)
|
44
|
-
site.build_collection_meta_token(title, article_id, url, tags)
|
33
|
+
network.build_user_auth_token('user_id', 'display_name', expires)
|
45
34
|
```
|
46
35
|
|
47
36
|
To validate a Livefyre token:
|
48
37
|
|
49
38
|
```ruby
|
50
|
-
network
|
51
|
-
network.validate_livefyre_token(token)
|
39
|
+
network.validate_livefyre_token('lf_token')
|
52
40
|
```
|
53
41
|
|
54
42
|
To send Livefyre a user sync url and then have Livefyre pull user data from that url:
|
55
43
|
|
56
44
|
```ruby
|
57
|
-
network
|
45
|
+
network.set_user_sync_url('url_template')
|
46
|
+
network.sync_user('user_id')
|
47
|
+
```
|
48
|
+
|
49
|
+
Instantiating a site object:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
site = network.get_site('site_id', 'site_key')
|
53
|
+
```
|
58
54
|
|
59
|
-
|
60
|
-
|
55
|
+
Building a collection meta token:
|
56
|
+
*The 'tags' and stream' arguments are optional.*
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
site.build_collection_meta_token('title', 'article_id', 'url', 'tags', 'stream')
|
61
60
|
```
|
62
61
|
|
63
62
|
To retrieve content collection data:
|
64
63
|
|
65
64
|
```ruby
|
66
|
-
|
65
|
+
site.get_collection_content('article_id')
|
66
|
+
```
|
67
|
+
|
68
|
+
To get a content collection's id:
|
67
69
|
|
68
|
-
|
69
|
-
site.
|
70
|
+
```ruby
|
71
|
+
site.get_collection_id('article_id')
|
70
72
|
```
|
71
73
|
|
72
74
|
## Documentation
|
73
75
|
|
74
|
-
Located [here](answers.livefyre.com/libraries).
|
76
|
+
Located [here](http://answers.livefyre.com/developers/libraries).
|
75
77
|
|
76
78
|
## Contributing
|
77
79
|
|
data/lib/livefyre/core.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'base64'
|
2
|
+
require 'digest'
|
2
3
|
require 'json'
|
3
4
|
require 'jwt'
|
4
5
|
require 'rest-client'
|
@@ -20,7 +21,7 @@ module Livefyre
|
|
20
21
|
response =
|
21
22
|
RestClient.post(
|
22
23
|
"http://#{@network_name}",
|
23
|
-
{ actor_token:
|
24
|
+
{ actor_token: build_livefyre_token, pull_profile_url: url_template }
|
24
25
|
)
|
25
26
|
response.code == 204
|
26
27
|
end
|
@@ -29,12 +30,12 @@ module Livefyre
|
|
29
30
|
response =
|
30
31
|
RestClient.post(
|
31
32
|
"http://#{@network_name}/api/v3_0/user/#{user_id}/refresh",
|
32
|
-
{ lftoken:
|
33
|
+
{ lftoken: build_livefyre_token }
|
33
34
|
)
|
34
35
|
response.code == 200
|
35
36
|
end
|
36
37
|
|
37
|
-
def
|
38
|
+
def build_livefyre_token
|
38
39
|
build_user_auth_token(DEFAULT_USER, DEFAULT_USER, DEFAULT_EXPIRES)
|
39
40
|
end
|
40
41
|
|
@@ -68,16 +69,21 @@ module Livefyre
|
|
68
69
|
@site_key = site_key
|
69
70
|
end
|
70
71
|
|
71
|
-
def build_collection_meta_token(title, article_id, url, tags, stream=
|
72
|
+
def build_collection_meta_token(title, article_id, url, tags='', stream=nil)
|
72
73
|
raise ArgumentError, 'provided url is not a valid url' if !uri?(url)
|
73
74
|
raise ArgumentError, 'title length should be under 255 char' if title.length > 255
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
75
|
+
|
76
|
+
collection_meta = { url: url, tags: tags, title: title }
|
77
|
+
checksum = Digest::MD5.new.update(collection_meta.to_json).hexdigest
|
78
|
+
|
79
|
+
collection_meta[:articleId] = article_id
|
80
|
+
collection_meta[:checksum] = checksum
|
81
|
+
|
82
|
+
if stream
|
83
|
+
collection_meta[:type] = stream
|
84
|
+
end
|
85
|
+
|
86
|
+
JWT.encode(collection_meta, @site_key)
|
81
87
|
end
|
82
88
|
|
83
89
|
def get_collection_content(article_id)
|
@@ -89,6 +95,13 @@ module Livefyre
|
|
89
95
|
response.code == 200 ? JSON.parse(response) : nil
|
90
96
|
end
|
91
97
|
|
98
|
+
def get_collection_id(article_id)
|
99
|
+
content = get_collection_content(article_id)
|
100
|
+
if content
|
101
|
+
content['collectionSettings']['collectionId']
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
92
105
|
def uri?(string)
|
93
106
|
uri = URI.parse(string)
|
94
107
|
%w( http https ).include?(uri.scheme)
|
data/lib/livefyre/version.rb
CHANGED
data/spec/livefyre/core_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'livefyre'
|
|
2
2
|
|
3
3
|
describe Livefyre::Network do
|
4
4
|
before(:each) do
|
5
|
-
@network = Livefyre.get_network('
|
5
|
+
@network = Livefyre.get_network('networkName', 'networkKey')
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'should raise ArgumentError if url_template does not contain {id}' do
|
@@ -14,13 +14,13 @@ describe Livefyre::Network do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should validate a livefyre token' do
|
17
|
-
@network.validate_livefyre_token(@network.
|
17
|
+
@network.validate_livefyre_token(@network.build_livefyre_token).should == true
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe Livefyre::Network::Site do
|
22
22
|
before(:each) do
|
23
|
-
@site = Livefyre.get_network('
|
23
|
+
@site = Livefyre.get_network('networkName', 'networkKey').get_site('siteId', "siteKey")
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'should raise ArgumentError if url is not a valid url' do
|
@@ -30,4 +30,8 @@ describe Livefyre::Network::Site do
|
|
30
30
|
it 'should raise ArgumentError if title is more than 255 characters' do
|
31
31
|
expect{ @site.build_collection_meta_token('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456', 'test', 'http://test.com', 'test') }.to raise_error(ArgumentError)
|
32
32
|
end
|
33
|
+
|
34
|
+
it 'should return a collection meta token' do
|
35
|
+
expect{ @site.build_collection_meta_token('title', 'article_id', 'https://www.url.com', 'tags') }.to be_true
|
36
|
+
end
|
33
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: livefyre
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Livefyre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|