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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f1017a6e52a15259bd35f142d8cbe0efd0547c3
4
- data.tar.gz: 1e8ea2c9a0e9809b16ced3a082fa77b4f316673e
3
+ metadata.gz: 719bbba214913cefb73468b8aa6542ea6b7b4202
4
+ data.tar.gz: 82de8b6c9547bdc7d6904c1481da2c0eb1e379a8
5
5
  SHA512:
6
- metadata.gz: 59d34f4e30f694a0db9e92854153accd6b38ddc1eb1a1c880a0e17424b1fa2489a6fe90533a332de2ba7bf52dd0cdeb709e7b24932c4d0d50078d52d7d86eeb5
7
- data.tar.gz: 74e32fef80068e5eda3a613683cee6d85133629ff3e264b1f873232420495ed2c0d74ae6c50ef3372b151d4a7d718fc1d54d8e203d1f3abc925b04c34d41a0c7
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 Drvie Spreadsheet in your Jekyll sites
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 get an access token. After installing the plugin, run:
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 an access token.
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 to token, you need to set it up as an environment variable before running `jekyll build`.
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 GDRIVE_TOKEN=<your ned gdrive token>
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 spreadsheey"
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: 1 %}
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: 1 %}
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 "You now have a Google Drive Access token:"
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
- access_token = ENV['GDRIVE_TOKEN']
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 access token specified for the GDrive Data Plugin\nSet it in a GRDIVE_TOKEN environment variable\nEg.: export GDRIVE_TOKEN=my-long-token\nRun 'jekyll gdrive' to get an access token" unless access_token
10
-
11
- session = GoogleDrive.login_with_oauth(access_token)
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
 
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Gdrive
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
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.1.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 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler