zerofetcher 0.0.9 → 0.0.10
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/code/JekyllFile.rb +3 -0
- data/lib/zerofetcher.rb +52 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2397f0029eb9fe03e645701d73e8c9ddce02b25
|
4
|
+
data.tar.gz: 34e374c9e2501b5d8683313cd7a3301b2414d6a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1692ce637e1dfc48e349fc5347e0382cf79818f892560c1f7a8757f77281700cea8c3810e2ee93b5cb4c43db1e72448fc136ea73e88cc40960cb278228c32dcb
|
7
|
+
data.tar.gz: 023ee3b5072234232facd95d57a098692e71910b8bffa457f8fabfb06630f2d791296060c02c72d0447a057f8c7e7465ac1f97f5468774e71c3e5f8684ad94f5
|
data/lib/code/JekyllFile.rb
CHANGED
data/lib/zerofetcher.rb
CHANGED
@@ -26,7 +26,7 @@ class ZeroFetcher
|
|
26
26
|
FileUtils::mkdir_p jekyll_path+'/_posts'
|
27
27
|
FileUtils::mkdir_p jekyll_path+'/assets'
|
28
28
|
FileUtils::mkdir_p jekyll_path+'/assets/images'
|
29
|
-
FileUtils::mkdir_p jekyll_path+'/assets/images/
|
29
|
+
FileUtils::mkdir_p jekyll_path+'/assets/images/pages'
|
30
30
|
FileUtils::mkdir_p jekyll_path+'/assets/files'
|
31
31
|
FileUtils::mkdir_p jekyll_path+'/_includes'
|
32
32
|
FileUtils::mkdir_p jekyll_path+'/_includes/pages'
|
@@ -50,11 +50,15 @@ class ZeroFetcher
|
|
50
50
|
end_point = config['fetcher']['end_point']
|
51
51
|
site_id = config['fetcher']['site_id'].to_s
|
52
52
|
|
53
|
+
# Load data from API
|
53
54
|
data = self.loadDataFromApi(end_point, config['fetcher']['api_key'], site_id)
|
55
|
+
|
56
|
+
# Create empty collection hash
|
57
|
+
collection_config = {};
|
54
58
|
|
55
59
|
# Site Info
|
56
60
|
if data.key?("site")
|
57
|
-
File.write(jekyll_path+'/_data/site.json', data['site']
|
61
|
+
File.write(jekyll_path+'/_data/site.json', JSON.pretty_generate(data['site']))
|
58
62
|
self.log('Writing File /_data/site.json')
|
59
63
|
end
|
60
64
|
|
@@ -84,17 +88,26 @@ class ZeroFetcher
|
|
84
88
|
self.log(" - Saved:"+jpage.getFileName)
|
85
89
|
|
86
90
|
# Add to pages array
|
87
|
-
|
91
|
+
page_info = {
|
88
92
|
'name' => page['name'],
|
89
93
|
'slug' => page['slug'],
|
90
94
|
'url' => page['url'],
|
91
95
|
'meta_title' => (page['meta_title']) ? page['meta_title'] : page['name'],
|
92
96
|
'meta_description' => page['meta_description'],
|
93
97
|
'short_description' => page['short_description'],
|
94
|
-
}
|
98
|
+
}
|
99
|
+
if page['image']
|
100
|
+
page_info['image'] = 'images/pages/' + page['image']
|
101
|
+
end
|
102
|
+
pages.push(page_info)
|
103
|
+
|
104
|
+
# save image
|
105
|
+
if page['image']
|
106
|
+
self.getAndSaveFile(end_point + '/media/images/pages/'+site_id+'/' + page['image'], jekyll_path+'/assets/images/pages/' + page['image'])
|
107
|
+
end
|
95
108
|
end
|
96
109
|
|
97
|
-
File.write(jekyll_path+'/_data/pages.json', pages
|
110
|
+
File.write(jekyll_path+'/_data/pages.json', JSON.pretty_generate(pages))
|
98
111
|
self.log("Writing File /_data/pages.json")
|
99
112
|
|
100
113
|
# Clean Unused Pages
|
@@ -113,7 +126,7 @@ class ZeroFetcher
|
|
113
126
|
|
114
127
|
# Variables
|
115
128
|
if data.key?("variables")
|
116
|
-
File.write(jekyll_path+'/_data/vars.json', data['variables']
|
129
|
+
File.write(jekyll_path+'/_data/vars.json', JSON.pretty_generate(data['variables']))
|
117
130
|
self.log("Writing File /_data/vars.json")
|
118
131
|
end
|
119
132
|
|
@@ -141,6 +154,8 @@ class ZeroFetcher
|
|
141
154
|
|
142
155
|
# Post files
|
143
156
|
if data.key?("posts")
|
157
|
+
FileUtils::mkdir_p jekyll_path+'/assets/images/posts'
|
158
|
+
|
144
159
|
puts "Posts - " + data['posts'].length.to_s
|
145
160
|
data['posts'].each do |post|
|
146
161
|
jpost = JekyllPost.new(jekyll_path+'/_posts', post)
|
@@ -163,7 +178,7 @@ class ZeroFetcher
|
|
163
178
|
self.log("Galleries - " + data['galleries'].length.to_s)
|
164
179
|
|
165
180
|
# Save Json Data
|
166
|
-
File.write(jekyll_path+'/_data/galleries.json', data['galleries']
|
181
|
+
File.write(jekyll_path+'/_data/galleries.json', JSON.pretty_generate(data['galleries']))
|
167
182
|
self.log('Writing file /_data/galleries.json')
|
168
183
|
|
169
184
|
# Save Photos
|
@@ -188,7 +203,7 @@ class ZeroFetcher
|
|
188
203
|
self.log("Calendar - " + data['calendar'].length.to_s)
|
189
204
|
|
190
205
|
# Save Json Data
|
191
|
-
File.write(jekyll_path+'/_data/calendar.json', data['calendar']
|
206
|
+
File.write(jekyll_path+'/_data/calendar.json', JSON.pretty_generate(data['calendar']))
|
192
207
|
self.log('Writing File /_data/calendar.json')
|
193
208
|
|
194
209
|
# Save Photos / Files
|
@@ -204,26 +219,48 @@ class ZeroFetcher
|
|
204
219
|
end
|
205
220
|
end
|
206
221
|
end
|
207
|
-
|
208
|
-
|
222
|
+
|
223
|
+
# Menus (as json data and images)
|
224
|
+
if data.key?("menus")
|
225
|
+
# Save Json Data
|
226
|
+
#File.write(jekyll_path+'/_data/menus.json', data['menus'].to_json)
|
227
|
+
File.write(jekyll_path+'/_data/menus.json', JSON.pretty_generate(data['menus']))
|
228
|
+
|
229
|
+
self.log('Writing File /_data/menus.json')
|
230
|
+
|
231
|
+
# Save Images
|
232
|
+
FileUtils::mkdir_p jekyll_path+'/assets/images/menus'
|
233
|
+
FileUtils::mkdir_p jekyll_path+'/assets/images/menus/items'
|
234
|
+
|
235
|
+
data['menus'].each do |menu|
|
236
|
+
menu['items'].each do |item|
|
237
|
+
if item['image']
|
238
|
+
image_path = jekyll_path+'/assets/images/menus/items/'+menu['id']
|
239
|
+
FileUtils::mkdir_p image_path
|
240
|
+
|
241
|
+
src_image = end_point + '/media/images/menu_items/'+menu['id']+'/' + item['image']
|
242
|
+
|
243
|
+
self.getAndSaveFile(src_image, image_path+'/' + item['image'])
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
209
249
|
# Custom Collections
|
210
250
|
if data.key?("collections")
|
211
|
-
# Create empty collection hash
|
212
|
-
collection_config = {};
|
213
|
-
|
214
251
|
data['collections'].each do |collection_type,collection_data|
|
215
252
|
puts "Collection - " + collection_type + ' - ' + collection_data.length.to_s
|
216
253
|
self.log("Collection - " + collection_type + ' - ' + collection_data.length.to_s)
|
217
254
|
|
218
255
|
# Save Json Data
|
219
|
-
File.write(jekyll_path+'/_data/'+collection_type+'.json', collection_data['data']
|
256
|
+
File.write(jekyll_path+'/_data/'+collection_type+'.json', JSON.pretty_generate(collection_data['data']))
|
220
257
|
self.log('Writing File /_data/'+collection_type+'.json')
|
221
258
|
|
222
259
|
# Loop through the collection data
|
223
260
|
case collection_data['settings']['type']
|
224
261
|
when 'collection'
|
225
262
|
# Add to collection hash
|
226
|
-
collection_config[ collection_type ] =
|
263
|
+
collection_config[ collection_type ] = {'output' => true}
|
227
264
|
|
228
265
|
# Directory Check
|
229
266
|
collection_path = jekyll_path+'/_' + collection_type
|