jekyll-gdrive 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -8
- data/lib/jekyll/commands/gdrive.rb +4 -11
- data/lib/jekyll/gdrive/generator.rb +14 -4
- data/lib/jekyll/gdrive/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 719bbba214913cefb73468b8aa6542ea6b7b4202
|
4
|
+
data.tar.gz: 82de8b6c9547bdc7d6904c1481da2c0eb1e379a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea474057a9e558379f6e6ada345ef0d363d58b977e031f49ff44857ec2d08a7cdf1ee6b7a5b6ca6ff7e705bd3299b822e0a284e6cbb56110ee3e3c268666877a
|
7
|
+
data.tar.gz: c94eddbb04990a5b7edb090e7310df7c4f1d82785dc49edefc52317eb7fb833d7298c0a30c7a4f44f055adb505e4e9e3c33c48c69eedb7ad5a16cf3270d2669f
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Jekyll Gdrive Plugin
|
2
2
|
|
3
|
-
Access data from a Google
|
3
|
+
Access data from a Google Drive Spreadsheet in your Jekyll sites
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,15 +18,15 @@ And then execute:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
Before you can access any data from GDrive you need to
|
21
|
+
Before you can access any data from GDrive you need to configure your GDrive API credentials. After installing the plugin, run:
|
22
22
|
|
23
23
|
$ bundle exec jekyll gdrive
|
24
24
|
|
25
|
-
And follow the instructions to create an application in Google's developer console and generate
|
25
|
+
And follow the instructions to create an application in Google's developer console and generate a refresh token.
|
26
26
|
|
27
|
-
Once you have
|
27
|
+
Once you have the token, you need to set it up as an environment variable before running `jekyll build`. The GDrive plugin will give you an export statement you can use to setup your environment:
|
28
28
|
|
29
|
-
$ export
|
29
|
+
$ export GDRIVE=<client_id>:<client_secret>:<your gdrive token>
|
30
30
|
|
31
31
|
You'll also need to configure the plugin to use the right spreadsheet.
|
32
32
|
|
@@ -34,7 +34,7 @@ Add this to your `_config.yml`:
|
|
34
34
|
|
35
35
|
```yaml
|
36
36
|
gdrive:
|
37
|
-
sheet: "title of my
|
37
|
+
sheet: "title of my spreadsheet"
|
38
38
|
```
|
39
39
|
|
40
40
|
## Accessing your Google Sheet data
|
@@ -46,14 +46,14 @@ Example:
|
|
46
46
|
```html
|
47
47
|
<table>
|
48
48
|
<thead>
|
49
|
-
{% for row in site.data.google_sheet limit:
|
49
|
+
{% for row in site.data.google_sheet limit:1 %}
|
50
50
|
<tr>
|
51
51
|
{% for col in row %}<th>{{col}}</th>{% endfor %}
|
52
52
|
</tr>
|
53
53
|
{% endfor %}
|
54
54
|
</thead>
|
55
55
|
<tbody>
|
56
|
-
{% for row in site.data.google_sheet offset:
|
56
|
+
{% for row in site.data.google_sheet offset:1 %}
|
57
57
|
<tr>
|
58
58
|
{% for col in row %}<td>{{col}}</td>{% endfor %}
|
59
59
|
</tr>
|
@@ -43,19 +43,12 @@ module Jekyll
|
|
43
43
|
end
|
44
44
|
auth.code = ask "Enter he authorization code shown in the page: "
|
45
45
|
auth.fetch_access_token!
|
46
|
-
access_token = auth.access_token
|
47
46
|
|
47
|
+
puts "OAuth credentials generated"
|
48
|
+
puts "To access Google Drive data from your Jekyll site"
|
49
|
+
puts "Set a GDRIVE environment variable"
|
48
50
|
puts
|
49
|
-
puts "
|
50
|
-
puts
|
51
|
-
puts access_token
|
52
|
-
puts
|
53
|
-
puts "Remember, this token gives access to all the files in your drive"
|
54
|
-
puts "So keep it safe"
|
55
|
-
puts "To use with the Jekyll GDrive plugin:"
|
56
|
-
puts "Set a GDRIVE_TOKEN environment variable"
|
57
|
-
puts
|
58
|
-
puts "export GDRIVE_TOKEN=#{access_token}"
|
51
|
+
puts "export GDRIVE=#{auth.client_id}:#{auth.client_secret}:#{auth.refresh_token}"
|
59
52
|
end
|
60
53
|
end
|
61
54
|
end
|
@@ -3,12 +3,22 @@ module Jekyll
|
|
3
3
|
class Generator < Jekyll::Generator
|
4
4
|
def generate(site)
|
5
5
|
sheet_name = site.config['gdrive'] && site.config['gdrive']['sheet']
|
6
|
-
|
6
|
+
credentials = ENV['GDRIVE'] && ENV['GDRIVE'].split(":")
|
7
7
|
|
8
8
|
raise "No sheet specified for the GDrive Data Plugin\nSet 'gdrive.sheet' in your '_config.yml'" unless sheet_name
|
9
|
-
raise "No
|
10
|
-
|
11
|
-
|
9
|
+
raise "No credentials specified for the GDrive Data Plugin\nSet it in a GRDIVE environment variable\nEg.: export GDRIVE_TOKEN=<client_id>:<client_secret>:<refresh_token>\nRun 'jekyll gdrive' to get an export statement you can cut and past" unless credentials
|
10
|
+
|
11
|
+
client = Google::APIClient.new(
|
12
|
+
:application_name => "Jekyll GDrive Plugin",
|
13
|
+
:application_version => Jekyll::Gdrive::VERSION
|
14
|
+
)
|
15
|
+
auth = client.authorization
|
16
|
+
auth.client_id = credentials[0]
|
17
|
+
auth.client_secret = credentials[1]
|
18
|
+
auth.refresh_token = credentials[2]
|
19
|
+
auth.fetch_access_token!()
|
20
|
+
|
21
|
+
session = GoogleDrive.login_with_oauth(auth.access_token)
|
12
22
|
|
13
23
|
sheet = session.file_by_title(sheet_name).worksheets.first
|
14
24
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-gdrive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Biilmann Christensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|