googleplus-reader 0.0.4 → 0.0.5
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 +4 -4
- data/CHANGELOG.md +6 -2
- data/README.md +21 -7
- data/lib/assets/javascripts/googleplus.photo.js.coffee +32 -30
- data/lib/assets/javascripts/googleplus.photoreader.js.coffee +37 -37
- data/lib/assets/javascripts/googleplus.reader.js.coffee +50 -49
- data/lib/googleplus/reader/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7be44f0159805b65d7933c87b18f492cf3def380
|
4
|
+
data.tar.gz: 858d27889d93276aff2dbb0261e5fb61ba8fee17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7de3bce12c30b1694edfa0687cbfde4e85ac227a2ddb0374ecff6a2dcfc1936053b8f07e264e8ecc1168946b1edb6989f725d8a33058011856d074a3b3ae6449
|
7
|
+
data.tar.gz: 206f17d40101ee0f35bf813ce05fe12ef5108095d42721a69c3a9ebf3eeb2fc973937d6ce086f412413d8ef510e9302f09a423c3ba272afcf900269a706e757a
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
## GooglePlus Reader 0.0.5 (August 4, 2014)
|
2
|
+
|
3
|
+
* Added support for [RequireJS](http://requirejs.org/).
|
4
|
+
|
1
5
|
## GooglePlus Reader 0.0.4 (August 2, 2014)
|
2
6
|
|
3
|
-
* Changed the API to rely on
|
7
|
+
* Changed the API to rely on promises instead of callbacks.
|
4
8
|
|
5
9
|
## GooglePlus Reader 0.0.3 (August 1, 2014)
|
6
10
|
|
@@ -8,7 +12,7 @@
|
|
8
12
|
|
9
13
|
## GooglePlus Reader 0.0.2 (July 15, 2014)
|
10
14
|
|
11
|
-
* Adjusted README to make YARD happy.
|
15
|
+
* Adjusted README to make [YARD](http://yardoc.org/) happy.
|
12
16
|
|
13
17
|
## GooglePlus Reader 0.0.1 (May 10, 2014)
|
14
18
|
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# GooglePlus Reader [](http://badge.fury.io/rb/googleplus-reader)
|
2
2
|
|
3
|
-
A
|
4
|
-
|
5
|
-
[here](
|
6
|
-
|
3
|
+
A library for reading public posts of a [Google+](https://plus.google.com)
|
4
|
+
user. A life demo can be found [here](http://photography.ivanukhov.com) and
|
5
|
+
its source code [here](https://github.com/IvanUkhov/photography). Best enjoyed
|
6
|
+
responsibly.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
@@ -13,9 +13,15 @@ In `Gemfile`:
|
|
13
13
|
gem 'googleplus-reader'
|
14
14
|
```
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
In terminal:
|
17
|
+
|
18
|
+
```bash
|
19
|
+
$ bundle
|
20
|
+
```
|
21
|
+
|
22
|
+
The code is written in [CoffeeScript](http://coffeescript.org) and relies on
|
23
|
+
[jQuery](http://jquery.com); however, all dependencies in this regard are
|
24
|
+
purposely omitted. So make sure you have a proper setup (see below).
|
19
25
|
|
20
26
|
## Usage
|
21
27
|
|
@@ -28,6 +34,12 @@ In `Gemfile`:
|
|
28
34
|
gem 'coffee-rails'
|
29
35
|
```
|
30
36
|
|
37
|
+
In terminal:
|
38
|
+
|
39
|
+
```bash
|
40
|
+
$ bundle
|
41
|
+
```
|
42
|
+
|
31
43
|
In `app/views/layouts/application.html.haml`:
|
32
44
|
|
33
45
|
```haml
|
@@ -55,6 +67,8 @@ needed for your application.
|
|
55
67
|
A more interesting example with photos that a user publishes:
|
56
68
|
|
57
69
|
```coffee
|
70
|
+
//= require googleplus.photo
|
71
|
+
//= require googleplus.reader
|
58
72
|
//= require googleplus.photoreader
|
59
73
|
|
60
74
|
reader = new GooglePlus.PhotoReader(id: 'user_id', key: 'api_key')
|
@@ -1,40 +1,42 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
unless typeof define is 'function' and define.amd
|
2
|
+
module = @GooglePlus ||= {}
|
3
|
+
@define = (name, deps, callback) ->
|
4
|
+
module.Photo = callback(jQuery)
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
define 'googleplus.photo', ['jquery'], ($) ->
|
7
|
+
class
|
8
|
+
constructor: (@attributes) ->
|
7
9
|
|
8
|
-
|
10
|
+
load: (options = {}) ->
|
11
|
+
deferred = $.Deferred()
|
9
12
|
|
10
|
-
|
11
|
-
if width?
|
12
|
-
width = Math.min(width, @attributes.width)
|
13
|
-
else
|
14
|
-
width = @attributes.width
|
13
|
+
width = options.width if options.width?
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
if @attributes.width?
|
16
|
+
if width?
|
17
|
+
width = Math.min(width, @attributes.width)
|
18
|
+
else
|
19
|
+
width = @attributes.width
|
21
20
|
|
22
|
-
|
21
|
+
if width?
|
22
|
+
width = Math.round(width)
|
23
|
+
url = @attributes.url.replace(/w\d+-h\d+(-p)?/, "w#{width}")
|
24
|
+
else
|
25
|
+
url = @attributes.url
|
23
26
|
|
24
|
-
|
25
|
-
.on 'load', ->
|
26
|
-
element.off('load error')
|
27
|
-
deferred.resolve(element)
|
28
|
-
return
|
27
|
+
element = $('<img/>')
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
element
|
30
|
+
.on 'load', ->
|
31
|
+
element.off('load error')
|
32
|
+
deferred.resolve(element)
|
33
|
+
return
|
34
34
|
|
35
|
-
|
35
|
+
.on 'error', (details...) ->
|
36
|
+
element.off('load error')
|
37
|
+
deferred.reject(details...)
|
38
|
+
return
|
36
39
|
|
37
|
-
|
40
|
+
element.attr(src: url)
|
38
41
|
|
39
|
-
|
40
|
-
window.GooglePlus.Photo = Photo
|
42
|
+
deferred.promise()
|
@@ -1,49 +1,49 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
unless typeof define is 'function' and define.amd
|
2
|
+
module = @GooglePlus ||= {}
|
3
|
+
@define = (name, deps, callback) ->
|
4
|
+
module.PhotoReader = callback(module.Reader, module.Photo)
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
define 'googleplus.photoreader', ['googleplus.reader', 'googleplus.photo'], (Reader, Photo) ->
|
7
|
+
class extends Reader
|
8
|
+
append: (items) ->
|
9
|
+
for item in items
|
10
|
+
continue unless item.verb?
|
11
|
+
continue unless item.verb is 'post'
|
9
12
|
|
10
|
-
|
13
|
+
date = if item.published? then new Date(item.published) else null
|
11
14
|
|
12
|
-
|
15
|
+
continue unless item.object?
|
13
16
|
|
14
|
-
|
17
|
+
post = item.object
|
15
18
|
|
16
|
-
|
19
|
+
continue unless post.attachments?
|
17
20
|
|
18
|
-
|
19
|
-
|
21
|
+
for attachment in post.attachments
|
22
|
+
continue unless attachment.objectType?
|
20
23
|
|
21
|
-
|
22
|
-
|
24
|
+
if attachment.objectType is 'photo'
|
25
|
+
continue unless attachment.image?
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
if attachment.fullImage?
|
28
|
+
@collection.push new Photo
|
29
|
+
url: attachment.image.url,
|
30
|
+
width: attachment.fullImage.width,
|
31
|
+
date: date
|
32
|
+
else
|
33
|
+
@collection.push new Photo
|
34
|
+
url: attachment.image.url,
|
35
|
+
width: null,
|
36
|
+
date: date
|
34
37
|
|
35
|
-
|
36
|
-
|
38
|
+
else if attachment.objectType is 'album'
|
39
|
+
continue unless attachment.thumbnails?
|
37
40
|
|
38
|
-
|
39
|
-
|
41
|
+
for thumbnail in attachment.thumbnails
|
42
|
+
continue unless thumbnail.image?
|
40
43
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
44
|
+
@collection.push new Photo
|
45
|
+
url: thumbnail.image.url,
|
46
|
+
width: null,
|
47
|
+
date: date
|
45
48
|
|
46
|
-
|
47
|
-
|
48
|
-
window.GooglePlus ||= {}
|
49
|
-
window.GooglePlus.PhotoReader = PhotoReader
|
49
|
+
return
|
@@ -1,50 +1,51 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@position
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
.
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@
|
42
|
-
@token
|
1
|
+
unless typeof define is 'function' and define.amd
|
2
|
+
module = @GooglePlus ||= {}
|
3
|
+
@define = (name, deps, callback) ->
|
4
|
+
module.Reader = callback(jQuery)
|
5
|
+
|
6
|
+
define 'googleplus.reader', ['jquery'], ($) ->
|
7
|
+
class
|
8
|
+
constructor: (options) ->
|
9
|
+
@id = options.id
|
10
|
+
@key = options.key
|
11
|
+
@token = null
|
12
|
+
@collection = []
|
13
|
+
@position = 0
|
14
|
+
|
15
|
+
next: (count) ->
|
16
|
+
deferred = $.Deferred()
|
17
|
+
|
18
|
+
nextPosition = @position + count
|
19
|
+
|
20
|
+
if nextPosition <= @collection.length
|
21
|
+
elements = @collection.slice(@position, nextPosition)
|
22
|
+
@position = nextPosition
|
23
|
+
deferred.resolve(elements)
|
24
|
+
|
25
|
+
else
|
26
|
+
@load()
|
27
|
+
.done =>
|
28
|
+
nextPosition = Math.min(nextPosition, @collection.length)
|
29
|
+
elements = @collection.slice(@position, nextPosition)
|
30
|
+
@position = nextPosition
|
31
|
+
deferred.resolve(elements)
|
32
|
+
return
|
33
|
+
|
34
|
+
.fail (details...) =>
|
35
|
+
deferred.reject(details...)
|
36
|
+
return
|
37
|
+
|
38
|
+
deferred.promise()
|
39
|
+
|
40
|
+
load: ->
|
41
|
+
url = "https://www.googleapis.com/plus/v1/people/#{@id}/activities/public?key=#{@key}"
|
42
|
+
url = "#{url}&pageToken=#{@token}" if @token
|
43
|
+
|
44
|
+
$.ajax(url: url, crossDomain: true, dataType: 'jsonp').done (result) =>
|
45
|
+
@append(result.items)
|
46
|
+
@token = result.nextPageToken
|
47
|
+
return
|
48
|
+
|
49
|
+
append: (items) ->
|
50
|
+
@collection.push(item) for item in items
|
43
51
|
return
|
44
|
-
|
45
|
-
append: (items) ->
|
46
|
-
@collection.push(item) for item in items
|
47
|
-
return
|
48
|
-
|
49
|
-
window.GooglePlus ||= {}
|
50
|
-
window.GooglePlus.Reader = Reader
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: googleplus-reader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Ukhov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,3 +82,4 @@ signing_key:
|
|
82
82
|
specification_version: 4
|
83
83
|
summary: A jQuery-based library for reading public posts of a Google+ user
|
84
84
|
test_files: []
|
85
|
+
has_rdoc:
|