middleman-google_drive 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/lib/middleman-google_drive/extension.rb +20 -25
- data/lib/middleman-google_drive/version.rb +1 -1
- data/middleman-google_drive.gemspec +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db9609d6202f67290e821eaef30d6a8f725bf755
|
4
|
+
data.tar.gz: 8194a550336602c7b2ec7da8f41c57f999052ffd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06bc7722edc97543391b8852e23096af25849ee00bb5c2843a983053c8e55b57ca8576b7ec0b23085607a6315cef3a68f3d29f4ef559e6e5c715e278c80c906a
|
7
|
+
data.tar.gz: 7842e26e597c2faef5eb2eb203ca826334eaadd0b1a901ed925bfc77bcfceb498a45f4a132dd786cedd9d6c2fc223232e68856ae140b55ada8e76b511bd6177a
|
data/README.md
CHANGED
@@ -84,8 +84,8 @@ Then you can use the data from any of the loaded documents in your templates:
|
|
84
84
|
|
85
85
|
### Documents
|
86
86
|
|
87
|
-
You can load documents similarly to spreadsheets. With documents, you have
|
88
|
-
options: plain text or
|
87
|
+
You can load documents similarly to spreadsheets. With documents, you have
|
88
|
+
options: plain text, HTML or [ArchieML](http://archieml.org/).
|
89
89
|
|
90
90
|
To load a single document as text:
|
91
91
|
|
@@ -103,7 +103,9 @@ activate :google_drive, load_docs: {
|
|
103
103
|
}
|
104
104
|
```
|
105
105
|
|
106
|
-
|
106
|
+
- To load HTML, use `load_docs_html` instead of `load_docs`.
|
107
|
+
- For [ArchieML](http://archieml.org/), use `load_docs_archieml`.
|
108
|
+
|
107
109
|
The HTML version of a Google doc will be a complete HTML document that includes
|
108
110
|
`<html>`, `<head>` and `<body>` tags. You'll probably wanna use the sanitize gem
|
109
111
|
to clean things up.
|
@@ -1,47 +1,40 @@
|
|
1
1
|
require 'middleman-core'
|
2
2
|
require 'google_drive'
|
3
|
+
require 'archieml'
|
3
4
|
|
4
5
|
module Middleman
|
5
6
|
module GoogleDrive
|
6
7
|
# Middle man extension that loads the google doc data
|
7
8
|
class Extension < Middleman::Extension
|
8
9
|
option :load_sheets, {}, 'Key for a google spreadsheet or a hash of google spreadsheets to load. Hash value is the id or slug of the spreadsheet to load, hash key is the data attribute to load the sheet data into.'
|
9
|
-
option :load_docs, {}, 'Key for a google doc or a hash of google docs to load as text. Hash value is the Google key of the spreadsheet to load, hash key is the data attribute to load the
|
10
|
-
option :load_docs_html, {}, 'Key for a google doc or a hash of google docs to load as HTML. Hash value is the Google key of the spreadsheet to load, hash key is the data attribute to load the
|
10
|
+
option :load_docs, {}, 'Key for a google doc or a hash of google docs to load as text. Hash value is the Google key of the spreadsheet to load, hash key is the data attribute to load the content into.'
|
11
|
+
option :load_docs_html, {}, 'Key for a google doc or a hash of google docs to load as HTML. Hash value is the Google key of the spreadsheet to load, hash key is the data attribute to load the content into.'
|
12
|
+
option :load_docs_archieml, {}, 'Key for a google doc or a hash of google docs to load and parse as ArchieML. Hash value is the Google key of the spreadsheet to load, hash key is the data attribute to load the content into.'
|
11
13
|
|
12
14
|
def initialize(klass, options_hash = {}, &block)
|
13
15
|
super
|
14
16
|
|
15
17
|
@drive = ::GoogleDrive.new
|
16
18
|
|
17
|
-
app = klass.inst
|
19
|
+
@app = klass.inst
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
load_doc(options.load_sheets.to_s, 'spreadsheet').each do |name, sheet|
|
25
|
-
app.data.store(name, sheet)
|
26
|
-
end
|
27
|
-
end
|
21
|
+
handle_option(options.load_sheets, 'spreadsheet')
|
22
|
+
handle_option(options.load_docs, 'text')
|
23
|
+
handle_option(options.load_docs_html, 'html')
|
24
|
+
handle_option(options.load_docs_archieml, 'archieml')
|
25
|
+
end
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
def handle_option(option, type)
|
28
|
+
if option.is_a? Hash
|
29
|
+
option.each do |name, key|
|
30
|
+
@app.data.store(name, load_doc(key.to_s, type))
|
32
31
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
if options.load_docs_html.is_a? Hash
|
39
|
-
options.load_docs_html.each do |name, key|
|
40
|
-
app.data.store(name, load_doc(key.to_s, 'html'))
|
32
|
+
elsif type == 'spreadsheet'
|
33
|
+
load_doc(option.to_s, type).each do |name, sheet|
|
34
|
+
@app.data.store(name, sheet)
|
41
35
|
end
|
42
36
|
else
|
43
|
-
app.data.store(
|
44
|
-
'doc', load_doc(options.load_docs_html.to_s, 'html'))
|
37
|
+
@app.data.store('doc', load_doc(option.to_s, type))
|
45
38
|
end
|
46
39
|
end
|
47
40
|
|
@@ -51,6 +44,8 @@ module Middleman
|
|
51
44
|
data = @drive.prepared_spreadsheet(key)
|
52
45
|
when 'html'
|
53
46
|
data = @drive.doc(key, 'html')
|
47
|
+
when 'archieml'
|
48
|
+
data = Archieml.load(@drive.doc(key, 'text'))
|
54
49
|
else
|
55
50
|
data = @drive.doc(key, 'text')
|
56
51
|
end
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_runtime_dependency 'retriable', '~> 1.4'
|
24
24
|
spec.add_runtime_dependency 'google-api-client', '< 0.8'
|
25
25
|
spec.add_runtime_dependency 'roo'
|
26
|
+
spec.add_runtime_dependency 'archieml'
|
26
27
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
27
28
|
spec.add_development_dependency 'rake'
|
28
29
|
spec.add_development_dependency 'minitest'
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Mark
|
@@ -67,6 +67,20 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: archieml
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: bundler
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|