jekyll-fridge 0.0.8 → 0.1.0
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/lib/jekyll-fridge/version.rb +1 -1
- data/lib/jekyll-fridge.rb +35 -12
- 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: 81f6909ad7b58d27eddb11bec7371d63319a28a3
|
4
|
+
data.tar.gz: d0ce811768e014f6e948a2c5138d1debc8536637
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f15ac1806475945017cbda46420ea126dcf07a4cec6fa069e0dcbc840186c68a7b26f8862923e436a328e11a4da5d8892e80ef61ba290e12473b741f9580d37
|
7
|
+
data.tar.gz: b3022125a424b8b30ba9e47ee02a84373256388aa86fda754585ca5c91974078a34fd3a110395dede55a78e46ed923c5beb22b385d5c9c4f46053ba637aef694
|
data/lib/jekyll-fridge.rb
CHANGED
@@ -32,9 +32,15 @@ module Jekyll
|
|
32
32
|
|
33
33
|
class Fridge < Generator
|
34
34
|
safe true
|
35
|
-
priority :
|
35
|
+
priority :high
|
36
36
|
|
37
37
|
def generate(site)
|
38
|
+
# Reset cache if client already exists
|
39
|
+
if site.config['fridge'].kind_of?(Client)
|
40
|
+
site.config['fridge'].reset!()
|
41
|
+
return
|
42
|
+
end
|
43
|
+
|
38
44
|
# get api configuration from _config.yml
|
39
45
|
#
|
40
46
|
# fridge:
|
@@ -58,22 +64,32 @@ module Jekyll
|
|
58
64
|
:client_secret => config['client_secret']
|
59
65
|
})
|
60
66
|
@config = config.delete_if { |k, v| k.to_s.match(/client/) }
|
67
|
+
reset!()
|
68
|
+
end
|
69
|
+
|
70
|
+
def get(path)
|
71
|
+
return @cache[path] if @cache.has_key?(path)
|
72
|
+
@cache[path] = @client.get(path)
|
73
|
+
end
|
74
|
+
|
75
|
+
def reset!
|
76
|
+
@cache = Hash.new
|
61
77
|
end
|
62
78
|
|
63
79
|
def before_method(method)
|
64
80
|
# try content type
|
65
|
-
type =
|
81
|
+
type = get("types/#{method}")
|
66
82
|
if type && type.kind_of?(FridgeApi::Model)
|
67
83
|
return Jekyll.stringify_keys_deep(type.attrs.merge({
|
68
|
-
'content' => ContentDrop.new(
|
84
|
+
'content' => ContentDrop.new(self, "content", "type=#{type.slug}")
|
69
85
|
}))
|
70
86
|
end
|
71
87
|
|
72
88
|
# try user role
|
73
|
-
role =
|
89
|
+
role = get("roles/#{method}")
|
74
90
|
if role && role.kind_of?(FridgeApi::Model)
|
75
91
|
return Jekyll.stringify_keys_deep(role.attrs.merge({
|
76
|
-
'users' => ContentDrop.new(
|
92
|
+
'users' => ContentDrop.new(self, "users", "role=#{role.slug}")
|
77
93
|
}))
|
78
94
|
end
|
79
95
|
|
@@ -81,23 +97,23 @@ module Jekyll
|
|
81
97
|
end
|
82
98
|
|
83
99
|
def content
|
84
|
-
ContentDrop.new(
|
100
|
+
ContentDrop.new(self, "content")
|
85
101
|
end
|
86
102
|
|
87
103
|
def collections
|
88
|
-
ContentDrop.new(
|
104
|
+
ContentDrop.new(self, "collections")
|
89
105
|
end
|
90
106
|
|
91
107
|
def settings
|
92
|
-
ContentDrop.new(
|
108
|
+
ContentDrop.new(self, "settings")
|
93
109
|
end
|
94
110
|
|
95
111
|
def types
|
96
|
-
ContentDrop.new(
|
112
|
+
ContentDrop.new(self, "types")
|
97
113
|
end
|
98
114
|
|
99
115
|
def users
|
100
|
-
ContentDrop.new(
|
116
|
+
ContentDrop.new(self, "users")
|
101
117
|
end
|
102
118
|
|
103
119
|
end
|
@@ -165,15 +181,22 @@ module Jekyll
|
|
165
181
|
# Writes static file to asset_dir and returns absolute file path
|
166
182
|
def fridge_asset(input)
|
167
183
|
return input unless input
|
168
|
-
|
184
|
+
if input.respond_to?("first")
|
185
|
+
input = input.first.name
|
186
|
+
end
|
169
187
|
site = @context.registers[:site]
|
170
188
|
asset_dir = site.config['fridge'].config['asset_dir']
|
171
189
|
dest_path = File.join(site.dest, asset_dir, input)
|
190
|
+
path = File.join(asset_dir, input)
|
191
|
+
|
192
|
+
# Check if file already exists
|
193
|
+
if site.keep_files.index(path) != nil
|
194
|
+
return "/#{path}"
|
195
|
+
end
|
172
196
|
|
173
197
|
asset = site.config['fridge'].client.get("content/upload/#{input}")
|
174
198
|
return input unless asset
|
175
199
|
|
176
|
-
path = File.join(asset_dir, input)
|
177
200
|
# play for keeps
|
178
201
|
# this is so jekyll won't clean up the file
|
179
202
|
site.keep_files << path
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-fridge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Kruk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|