zerofetcher 0.0.22 → 0.0.23

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c57767a0284f41f45d5820e0b7a1d7c19ca46dab
4
- data.tar.gz: 2fc1ba2047b9da8d480067fa401ff497f6a267dc
3
+ metadata.gz: 04578fdad2da7078a2012e446950ab564223b4cc
4
+ data.tar.gz: 131afdc5d3ec8d45b8b80fa91a5d45c7d459743b
5
5
  SHA512:
6
- metadata.gz: 27a32aac9dd2c1a97175996a366009b38f878deaab74e4030825230b9fe97361d49f01f25b3ea77276f6bccf73bef6d96a04fd812303f4617fcfae1c1f215031
7
- data.tar.gz: b33a341a676f7cb1726a02f540a78c0bc99e4357e7d335f8ba975c61be997a19a5975c61d76aeb43697b2ac4590985abcb8792fc1d3dc005289f38cdcc040d3a
6
+ metadata.gz: b737fb1db91bda1a6384abafd30f208a4028a9f5526aa4305a4a49d74de0b19e8009bc97c8fce8dd979ca65860953b3957edf864f9390b61628b64af620ae31a
7
+ data.tar.gz: 802a8543dd8181853d67755912350a8f7fc56ba0132b67f692fab7a4ef055af35889a3886818e342b61428ee6b6b4ebab65a8f8558a4f12ec6c07b30b6dafea0
@@ -21,7 +21,7 @@ class JekyllPost
21
21
  }
22
22
 
23
23
  if post['image']
24
- @yaml_parsed['image'] = 'images/posts/' + post['image']
24
+ @yaml_parsed['image'] = 'images/posts/' + post['image']['original']
25
25
  end
26
26
 
27
27
  @content_section = post['content']
data/lib/zerofetcher.rb CHANGED
@@ -117,7 +117,7 @@ class ZeroFetcher
117
117
 
118
118
  # save image
119
119
  if page['image']
120
- self.getAndSaveImages(end_point + '/media/images/pages/'+site_id+'/' + page['image'], jekyll_path+'/assets/images/pages/' + page['image'])
120
+ page['image'] = self.getAndSaveImages(end_point + '/media/images/pages/'+site_id+'/' + page['image'], jekyll_path+'/assets/images/pages/' + page['image'])
121
121
  end
122
122
  end
123
123
 
@@ -178,14 +178,15 @@ class ZeroFetcher
178
178
 
179
179
  puts "Posts - " + data['posts'].length.to_s
180
180
  data['posts'].each do |post|
181
- jpost = JekyllPost.new(jekyll_path+'/_posts', post)
182
- jpost.savePageFile
183
181
  self.log('Saving Post File ' + post['date']+'-'+post['slug']+'.md')
184
182
 
185
183
  # save image
186
184
  if post['image']
187
- self.getAndSaveImages(end_point + '/media/images/posts/'+site_id+'/' + post['image'], jekyll_path+'/assets/images/posts/' + post['image'])
185
+ post['image'] = self.getAndSaveImages(end_point + '/media/images/posts/'+site_id+'/' + post['image'], jekyll_path+'/assets/images/posts/' + post['image'])
188
186
  end
187
+
188
+ jpost = JekyllPost.new(jekyll_path+'/_posts', post)
189
+ jpost.savePageFile
189
190
  end
190
191
  end
191
192
 
@@ -197,21 +198,21 @@ class ZeroFetcher
197
198
  puts "Galleries - " + data['galleries'].length.to_s
198
199
  self.log("Galleries - " + data['galleries'].length.to_s)
199
200
 
200
- # Save Json Data
201
- File.write(jekyll_path+'/_data/galleries.json', JSON.pretty_generate(data['galleries']))
202
- self.log('Writing file /_data/galleries.json')
203
-
204
201
  # Save Photos
205
- data['galleries'].each do |gallery|
202
+ data['galleries'].each_with_index do |gallery,idx|
206
203
  FileUtils::mkdir_p jekyll_path+'/assets/images/galleries/' + gallery['id']
207
204
 
208
205
  puts " - " + gallery['name'] + ' has ' + gallery['photos'].length.to_s + ' photos'
209
206
  self.log(" - " + gallery['name'] + ' has ' + gallery['photos'].length.to_s + ' photos')
210
207
 
211
- gallery['photos'].each do |photo|
212
- self.getAndSaveImages(end_point + '/media/images/galleries/photos/' + gallery['id'] + '/' + photo['image'], jekyll_path+'/assets/images/galleries/' + gallery['id'] + '/' + photo['image'])
208
+ gallery['photos'].each_with_index do |photo,pidx|
209
+ data['galleries'][idx]['photos'][pidx] = self.getAndSaveImages(end_point + '/media/images/galleries/photos/' + gallery['id'] + '/' + photo['image'], jekyll_path+'/assets/images/galleries/' + gallery['id'] + '/' + photo['image'])
213
210
  end
214
211
  end
212
+
213
+ # Save Json Data
214
+ File.write(jekyll_path+'/_data/galleries.json', JSON.pretty_generate(data['galleries']))
215
+ self.log('Writing file /_data/galleries.json')
215
216
  end
216
217
 
217
218
  # Calendar
@@ -228,9 +229,9 @@ class ZeroFetcher
228
229
 
229
230
  # Save Photos / Files
230
231
  if data['calendar'].key?("events")
231
- data['calendar']['events'].each do |event|
232
+ data['calendar']['events'].each_with_index do |event,idx|
232
233
  if event['image']
233
- self.getAndSaveImages(end_point + '/media/images/calendar/'+site_id+'/' + event['image'], jekyll_path+'/assets/images/calendar/' + event['image'])
234
+ data['calendar']['events'][idx]['image'] = self.getAndSaveImages(end_point + '/media/images/calendar/'+site_id+'/' + event['image'], jekyll_path+'/assets/images/calendar/' + event['image'])
234
235
  end
235
236
 
236
237
  if event['file']
@@ -252,13 +253,13 @@ class ZeroFetcher
252
253
  FileUtils::mkdir_p jekyll_path+'/assets/images/menus'
253
254
  FileUtils::mkdir_p jekyll_path+'/assets/images/menus/items'
254
255
 
255
- data['menus'].each do |menu|
256
+ data['menus'].each_with_index do |menu,idx|
256
257
  if menu['image']
257
258
  menu_image_path = jekyll_path+'/assets/images/menus'
258
259
 
259
260
  src_image = end_point + '/media/images/menus/' + site_id + '/' + menu['image']
260
261
 
261
- self.getAndSaveImages(src_image, menu_image_path + '/' + menu['image'])
262
+ data['menus'][idx]['image'] = self.getAndSaveImages(src_image, menu_image_path + '/' + menu['image'])
262
263
  end
263
264
  if menu['download']
264
265
  menu_download_path = jekyll_path+'/assets/files/menus'
@@ -268,14 +269,14 @@ class ZeroFetcher
268
269
  self.getAndSaveFile(src_image, menu_download_path + '/' + menu['download'])
269
270
  end
270
271
 
271
- menu['items'].each do |item|
272
+ menu['items'].each_with_index do |item,iidx|
272
273
  if item['image']
273
274
  image_path = jekyll_path+'/assets/images/menus/items/'+menu['id']
274
275
  FileUtils::mkdir_p image_path
275
276
 
276
277
  src_image = end_point + '/media/images/menu_items/'+menu['id']+'/' + item['image']
277
278
 
278
- self.getAndSaveImages(src_image, image_path+'/' + item['image'])
279
+ data['menus'][idx]['items'][iidx] = self.getAndSaveImages(src_image, image_path+'/' + item['image'])
279
280
  end
280
281
  end
281
282
  end
@@ -305,39 +306,9 @@ class ZeroFetcher
305
306
  puts "Collection - " + collection_type + ' - ' + collection_data.length.to_s
306
307
  self.log("Collection - " + collection_type + ' - ' + collection_data.length.to_s)
307
308
 
308
- # Save Json Data
309
- File.write(jekyll_path+'/_data/'+collection_type+'.json', JSON.pretty_generate(collection_data['data']))
310
- self.log('Writing File /_data/'+collection_type+'.json')
311
-
312
- # Loop through the collection data
313
- case collection_data['settings']['type']
314
- when 'collection'
315
- # Add to collection hash
316
- collection_config[ collection_type ] = {'output' => true}
317
-
318
- # Directory Check
319
- collection_path = jekyll_path+'/_' + collection_type
320
- FileUtils::mkdir_p collection_path
321
-
322
- # Create files saved array
323
- files_saved = Array.new
324
-
325
- # Save Individual Collection Files
326
- collection_data['data'].each do |row|
327
- jfile = JekyllFile.new(collection_path, row, 'collection')
328
- jfile.savePageFile
329
-
330
- files_saved.push( Pathname.new( jfile.getFileName ).basename.to_s )
331
-
332
- self.log('Saving Collection File ' + jfile.getFileName)
333
- end
334
-
335
- # Clean up unused collection files
336
- self.cleanUpFolder(collection_path, files_saved)
337
- end
338
309
 
339
310
  # Save Images / Files
340
- collection_data['data'].each do |row|
311
+ collection_data['data'].each_with_index do |row,cidx|
341
312
  collection_data['fields'].each do |fld_key,fld_info|
342
313
  row.each do |key,val|
343
314
  #puts 'Row ['+key+']:['+val.to_s+']'
@@ -350,7 +321,7 @@ class ZeroFetcher
350
321
 
351
322
  src_image = end_point + '/media/images/'+collection_type+'/'+site_id+'/' + val
352
323
 
353
- self.getAndSaveImages(src_image, image_path+'/' + val)
324
+ collection_data['data'][cidx][fld_key] = self.getAndSaveImages(src_image, image_path+'/' + val)
354
325
  when 'file'
355
326
  # Directory Check
356
327
  file_path = jekyll_path+'/assets/files/'+collection_type
@@ -369,7 +340,7 @@ class ZeroFetcher
369
340
  row['hasmany_data'].each do |hasmany_type,hasmany_data|
370
341
  puts " - hasmany : " + hasmany_type + " - " + hasmany_data['data'].length.to_s
371
342
  hasmany_data['fields'].each do |fld_key,fld_info|
372
- hasmany_data['data'].each do |hsrow|
343
+ hasmany_data['data'].each_with_index do |hsrow,hsidx|
373
344
  hsrow.each do |key,val|
374
345
  if fld_key == key
375
346
  case fld_info['type']
@@ -380,7 +351,7 @@ class ZeroFetcher
380
351
 
381
352
  src_image = end_point + '/media/images/'+collection_type+'/'+site_id+'/'+row['id']+'/' + val
382
353
 
383
- self.getAndSaveImages(src_image, image_path+'/' + val)
354
+ collection_data['data'][cidx]['hasmany_data'][hasmany_type]['data'][hsidx][fld_key] = self.getAndSaveImages(src_image, image_path+'/' + val)
384
355
  when 'file'
385
356
  # Directory Check
386
357
  file_path = jekyll_path+'/assets/files/'+collection_type+'/'+hasmany_type+'/'+row['id']
@@ -396,9 +367,39 @@ class ZeroFetcher
396
367
  end
397
368
  end # has many data each
398
369
  end
399
-
400
370
  end
401
371
 
372
+ # Loop through the collection data
373
+ case collection_data['settings']['type']
374
+ when 'collection'
375
+ # Add to collection hash
376
+ collection_config[ collection_type ] = {'output' => true}
377
+
378
+ # Directory Check
379
+ collection_path = jekyll_path+'/_' + collection_type
380
+ FileUtils::mkdir_p collection_path
381
+
382
+ # Create files saved array
383
+ files_saved = Array.new
384
+
385
+ # Save Individual Collection Files
386
+ collection_data['data'].each do |row|
387
+ jfile = JekyllFile.new(collection_path, row, 'collection')
388
+ jfile.savePageFile
389
+
390
+ files_saved.push( Pathname.new( jfile.getFileName ).basename.to_s )
391
+
392
+ self.log('Saving Collection File ' + jfile.getFileName)
393
+ end
394
+
395
+ # Clean up unused collection files
396
+ self.cleanUpFolder(collection_path, files_saved)
397
+ end
398
+
399
+ # Save Json Data
400
+ File.write(jekyll_path+'/_data/'+collection_type+'.json', JSON.pretty_generate(collection_data['data']))
401
+ self.log('Writing File /_data/'+collection_type+'.json')
402
+
402
403
  end
403
404
 
404
405
  # Add Collections to _config.tml
@@ -448,6 +449,10 @@ class ZeroFetcher
448
449
  end
449
450
 
450
451
  def self.getAndSaveImages(source, dest)
452
+ images = {
453
+ 'original' => File.basename( dest )
454
+ }
455
+
451
456
  # Save Original
452
457
  self.getAndSaveFile(source, dest)
453
458
 
@@ -457,8 +462,12 @@ class ZeroFetcher
457
462
  v_source = self.getImageVariantSource(source, variant)
458
463
  v_dest = self.getImageVariantDestination(dest, variant)
459
464
  self.getAndSaveFile( v_source, v_dest )
465
+
466
+ images[ variant['key'] ] = File.basename( v_dest )
460
467
  end
461
468
  end
469
+
470
+ return images
462
471
  end
463
472
 
464
473
  def self.getImageVariantSource(source, variant)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zerofetcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Liccardo