middleman-google_drive 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -3
- data/lib/middleman-google_drive/extension.rb +5 -5
- data/lib/middleman-google_drive/version.rb +1 -1
- data/middleman-google_drive.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb9ae8521afbbeae9275df2d64c183a5e0bf21cc
|
4
|
+
data.tar.gz: 28eb1a3c4624f1856b96f8cbd1e1fbd535e12b57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e50d4b456bad5d489f9e6e6a008aca3d5f8bea940d6e1c5e8f94030c21bea9ce9c22694072a3ada0da08c6c41bb3031ae63ed1ebb500979d242f00cad437285
|
7
|
+
data.tar.gz: 0b8e2fba1ea328fdf141285b2521de79b80d3e572211b959829c6a9870d369176982a0e8db51306fb50bf2110c37ba1534f946f79085e41a04274a685f0cebf5
|
data/README.md
CHANGED
@@ -19,7 +19,43 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
-
The extension will get loaded
|
22
|
+
The extension will get loaded automatically, you just need to activate it.
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
activate :google_drive
|
26
|
+
```
|
27
|
+
|
28
|
+
There are two ways to load and use spreadsheets. Most the time you just need a
|
29
|
+
single document with multiple worksheets. If you only need a single document...
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
activate :google_drive, load_sheets: 'mygoogledocumentkey'
|
33
|
+
```
|
34
|
+
|
35
|
+
------
|
36
|
+
|
37
|
+
### WARNING!!!!
|
38
|
+
|
39
|
+
You can only reliably load old-style google spreadsheets. These spreadsheets have URLs that look like this: `https://docs.google.com/a/spreadsheet/ccc?key=mygoogledocumentkey#gid=4`. If you create a brand new google spreadsheet, it will load without crashing but the worksheet names and data will be all mixed up.
|
40
|
+
|
41
|
+
Click this link to create a new old-style google spreadsheet: [g.co/oldsheets](http://g.co/oldsheets)
|
42
|
+
|
43
|
+
------
|
44
|
+
|
45
|
+
You can then use the worksheets in your templates (make sure your worksheets
|
46
|
+
have names that only contain alpha-numeric characters; no spaces or strange things).
|
47
|
+
|
48
|
+
```erb
|
49
|
+
<h1>My spreadsheet is called: <%= data.mysheet['title'] %></h1>
|
50
|
+
<% data.Sheet1.each do [row] %>
|
51
|
+
Column one header: <%= row['Column one header'] %>
|
52
|
+
Column two header: <%= row['Column two header'] %>
|
53
|
+
My column name: <%= row['My column name'] %>
|
54
|
+
<% end %>
|
55
|
+
```
|
56
|
+
|
57
|
+
If you would like to load multiple documents from google, you can use a hash when
|
58
|
+
activating the extension:
|
23
59
|
|
24
60
|
```ruby
|
25
61
|
activate :google_drive, load_sheets: {
|
@@ -28,7 +64,7 @@ activate :google_drive, load_sheets: {
|
|
28
64
|
}
|
29
65
|
```
|
30
66
|
|
31
|
-
Then you can use the data in your templates:
|
67
|
+
Then you can use the data from any of the loaded documents in your templates:
|
32
68
|
|
33
69
|
```erb
|
34
70
|
<h1>My spreadsheet is called: <%= data.mysheet['title'] %></h1>
|
@@ -37,12 +73,21 @@ Then you can use the data in your templates:
|
|
37
73
|
Column two header: <%= row['Column two header'] %>
|
38
74
|
My column name: <%= row['My column name'] %>
|
39
75
|
<% end %>
|
76
|
+
<% data.moresheet['Sheet1'].each do [row] %>
|
77
|
+
Column one header: <%= row['Column one header'] %>
|
78
|
+
Column two header: <%= row['Column two header'] %>
|
79
|
+
My column name: <%= row['My column name'] %>
|
80
|
+
<% end %>
|
40
81
|
```
|
41
82
|
|
42
83
|
You can also use a simplified Google Drive interface from inside your project, via the `drive`
|
43
|
-
variable.
|
84
|
+
variable. In order to use this functionality, you only have to activate the extension; you do
|
85
|
+
not have to provide a google docs key:
|
44
86
|
|
45
87
|
```ruby
|
88
|
+
# Activate the extension
|
89
|
+
activate :google_drive
|
90
|
+
|
46
91
|
# get metadata for a document
|
47
92
|
doc_info = drive.find('google_document_key')
|
48
93
|
|
@@ -14,13 +14,13 @@ module Middleman
|
|
14
14
|
|
15
15
|
app = klass.inst
|
16
16
|
app.set :drive, @drive # so you can access the drive api directly
|
17
|
-
if options.load_sheets.is_a?
|
18
|
-
|
19
|
-
app.data.store(name,
|
17
|
+
if options.load_sheets.is_a? Hash
|
18
|
+
options.load_sheets.each do |name, key|
|
19
|
+
app.data.store(name, load_doc(key.to_s))
|
20
20
|
end
|
21
21
|
else
|
22
|
-
options.load_sheets.each do |name,
|
23
|
-
app.data.store(name,
|
22
|
+
load_doc(options.load_sheets.to_s).each do |name, sheet|
|
23
|
+
app.data.store(name, sheet)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
spec.add_runtime_dependency 'middleman-core', '>= 3.0.0'
|
23
|
-
spec.add_runtime_dependency 'google-api-client', '
|
23
|
+
spec.add_runtime_dependency 'google-api-client', '< 0.8'
|
24
24
|
spec.add_runtime_dependency 'roo', '~> 1.13.2'
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
26
26
|
spec.add_development_dependency 'rake'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-google_drive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Mark
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: middleman-core
|
@@ -29,16 +29,16 @@ dependencies:
|
|
29
29
|
name: google-api-client
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - <
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.
|
34
|
+
version: '0.8'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - <
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0.
|
41
|
+
version: '0.8'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: roo
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|