googleplus-reader 0.0.1 → 0.0.2
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/README.md +31 -18
- data/Rakefile +4 -0
- data/lib/assets/javascripts/googleplus.photo.js.coffee +4 -3
- data/lib/assets/javascripts/googleplus.photoreader.js.coffee +1 -2
- data/lib/assets/javascripts/googleplus.reader.js.coffee +5 -0
- data/lib/googleplus/reader/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50eeb4fc675c4ede7d46f9e480745bc1913da460
|
4
|
+
data.tar.gz: e401e69d7dc5e650dc0de14b2ca9f179389843f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f95cfea62a921aed6e9c7d4e5ae4711ec36d12428c27657b78f90c6e03df82ea5dbf614080f3b4157c9f3e1624ef1a12de0ad6106864f7815e186788d6a8dda3
|
7
|
+
data.tar.gz: 1d93e2ed023f68e28a235771d394afbb25487de0e0445f44412c5ce78e170dc0177fefdb8bce29009d697f8699d7ba9c54b105c4f45c708183cd3e3351d54272
|
data/README.md
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
-
# GooglePlus Reader
|
1
|
+
# GooglePlus Reader [](http://badge.fury.io/rb/googleplus-reader)
|
2
2
|
|
3
|
-
A [jQuery](http://jquery.com)-based library for reading public posts
|
4
|
-
|
5
|
-
[here](http://ivanukhov.com)
|
3
|
+
A [jQuery](http://jquery.com)-based library for reading public posts of a
|
4
|
+
[Google+](https://plus.google.com) user. A life demo can be found
|
5
|
+
[here](http://ivanukhov.com) and its source code
|
6
|
+
[here](https://github.com/IvanUkhov/photography). Best enjoyed responsibly.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
```bash
|
11
|
+
$ echo "gem 'googleplus-reader'" >> Gemfile
|
12
|
+
$ bundle install
|
13
|
+
```
|
11
14
|
|
12
15
|
The code is written in [CoffeeScript](http://coffeescript.org); however,
|
13
16
|
any dependencies in this regard are purposely omitted. So make sure you
|
@@ -18,17 +21,21 @@ have CoffeeScript installed.
|
|
18
21
|
Here is an example in the context of a [Rails](http://rubyonrails.org)
|
19
22
|
application. First, we need CoffeeScript as it was noted earlier:
|
20
23
|
|
21
|
-
|
22
|
-
|
24
|
+
```bash
|
25
|
+
$ echo "gem 'coffee-rails'" >> Gemfile
|
26
|
+
$ bundle install
|
27
|
+
```
|
23
28
|
|
24
29
|
In your `app/views/layouts/application.html.haml`:
|
25
|
-
|
30
|
+
|
31
|
+
```haml
|
26
32
|
= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js'
|
27
33
|
= javascript_include_tag :application
|
28
34
|
```
|
29
35
|
|
30
36
|
In your `app/assets/javascripts/application.js.coffee`:
|
31
|
-
|
37
|
+
|
38
|
+
```coffee
|
32
39
|
//= require googleplus.reader
|
33
40
|
|
34
41
|
reader = new GooglePlus.Reader \
|
@@ -37,6 +44,7 @@ reader = new GooglePlus.Reader \
|
|
37
44
|
reader.next 5, (posts) ->
|
38
45
|
console.log post for post in posts
|
39
46
|
```
|
47
|
+
|
40
48
|
Here `user_id` is the identifier of a Google+ user, and `api_key` is your
|
41
49
|
[Google+ API key](https://developers.google.com/+/api/oauth).
|
42
50
|
`post` is exactly what Google has to say about each post without any
|
@@ -44,7 +52,8 @@ additional preprocessing. You might want to inspect it and fetch what is
|
|
44
52
|
needed for your application.
|
45
53
|
|
46
54
|
A more interesting example with photos that a user publishes:
|
47
|
-
|
55
|
+
|
56
|
+
```coffee
|
48
57
|
//= require googleplus.photoreader
|
49
58
|
|
50
59
|
reader = new GooglePlus.PhotoReader \
|
@@ -53,11 +62,13 @@ reader = new GooglePlus.PhotoReader \
|
|
53
62
|
reader.next 5, (photos) ->
|
54
63
|
console.log photo.attributes for photo in photos
|
55
64
|
```
|
65
|
+
|
56
66
|
`photo` is an instance of `GooglePlus.Photo`. Right now, `attributes`
|
57
67
|
contain only `url`, `date`, and `width` (if available), but other parameters
|
58
68
|
can be easily added via a pull request >:)~ The only method that `photo`
|
59
69
|
has is `load`, which can be used as follows:
|
60
|
-
|
70
|
+
|
71
|
+
```coffee
|
61
72
|
photo.load {}, (element) ->
|
62
73
|
$('#original').append element
|
63
74
|
|
@@ -71,15 +82,17 @@ element = photo.load width: 2000
|
|
71
82
|
console.log element.attr('href')
|
72
83
|
$('#huge').append element
|
73
84
|
```
|
85
|
+
|
74
86
|
`load` constructs an URL referencing the photo of the desired size and
|
75
87
|
preloads it using an `img` element, which it returns right away and also
|
76
88
|
passes to the callback function once the photo has been loaded.
|
77
89
|
|
78
|
-
|
79
90
|
## Contributing
|
80
91
|
|
81
|
-
1. Fork
|
82
|
-
2. Create your feature
|
83
|
-
3.
|
84
|
-
4.
|
85
|
-
5.
|
92
|
+
1. [Fork](https://help.github.com/articles/fork-a-repo) the project.
|
93
|
+
2. Create a branch for your feature (`git checkout -b awesome-feature`).
|
94
|
+
3. Implement your feature (`vim`).
|
95
|
+
4. Commit your changes (`git commit -am 'Implemented an awesome feature'`).
|
96
|
+
5. Push to the branch (`git push origin awesome-feature`).
|
97
|
+
6. [Create](https://help.github.com/articles/creating-a-pull-request)
|
98
|
+
a new Pull Request.
|
data/Rakefile
CHANGED
@@ -7,8 +7,7 @@ class PhotoReader extends GooglePlus.Reader
|
|
7
7
|
continue unless item.verb?
|
8
8
|
continue unless item.verb is 'post'
|
9
9
|
|
10
|
-
date = null
|
11
|
-
date = new Date item.published if item.published?
|
10
|
+
date = if item.published? then new Date(item.published) else null
|
12
11
|
|
13
12
|
continue unless item.object?
|
14
13
|
|
@@ -18,6 +18,7 @@ class Reader
|
|
18
18
|
nextPosition = Math.min nextPosition, @collection.length
|
19
19
|
callback @collection.slice(@position, nextPosition) if callback?
|
20
20
|
@position = nextPosition
|
21
|
+
return
|
21
22
|
|
22
23
|
return
|
23
24
|
|
@@ -29,9 +30,13 @@ class Reader
|
|
29
30
|
@append result.items
|
30
31
|
@token = result.nextPageToken
|
31
32
|
callback() if callback?
|
33
|
+
return
|
34
|
+
|
35
|
+
return
|
32
36
|
|
33
37
|
append: (items) ->
|
34
38
|
@collection.push item for item in items
|
39
|
+
return
|
35
40
|
|
36
41
|
window.GooglePlus ||= {}
|
37
42
|
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.2
|
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-
|
11
|
+
date: 2014-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
78
|
rubyforge_project:
|
79
|
-
rubygems_version: 2.2.
|
79
|
+
rubygems_version: 2.2.2
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: A jQuery-based library for reading public posts of a Google+ user
|