zerofetcher 0.0.50 → 0.0.51

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/zerofetcher.rb +35 -30
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b25b01dc66028a61f7765caf82f9056cbb35e923
4
- data.tar.gz: b242f5aee5eb9b67d5763c7e520bb82cd12dc6b6
3
+ metadata.gz: 81a2792ed24af1a74026a094347ad88fed70f821
4
+ data.tar.gz: 6f1404e8960b9d5dfc432b011261a03b267e17e4
5
5
  SHA512:
6
- metadata.gz: e07b115c425ac1c710d3a6ed507ae2d80702f69f68b0f30f313cf418ca89b0686d5a5863a45e4c9beb06df8b409a52ed8ad6cb65fcb6a7cd730ac60c4cfa02cf
7
- data.tar.gz: 495d5486183286bba28373432ab6371a0202e305f3bd492866b829cdeee4aff35ab321fa6a52da4be7c4d1cc0bde0faf98106e66b2385c720c0163c0558ba133
6
+ metadata.gz: e919d47dabdbde86ad90f5e0294a5dbc7a09abe5c7cc68c5d4bb8022c0fdcb4f241198c9f96e98ae83c44e277f98b8b4a06f22b4c1e8dd03901d40e9985c9569
7
+ data.tar.gz: 5c3fd501d7228f0a8050eb79e6d759eaa50ab2d7f8198a8a2a2f7ea1aed5a8ff7507d07c5fd2a960fe50d47304ef4b57fd5eafe272c1cb8a047f1ab4f6a645a8
data/lib/zerofetcher.rb CHANGED
@@ -16,6 +16,7 @@ class ZeroFetcher
16
16
  @@jekyll_path
17
17
  @@image_variants
18
18
  @@end_point
19
+ @@site_id
19
20
 
20
21
  def self.run
21
22
  # Paths
@@ -61,6 +62,7 @@ class ZeroFetcher
61
62
  end_point = config['fetcher']['end_point']
62
63
  @@end_point = end_point
63
64
  site_id = config['fetcher']['site_id'].to_s
65
+ @@site_id = site_id;
64
66
 
65
67
  # Load data from API
66
68
  data = self.loadDataFromApi(end_point, config['fetcher']['api_key'], site_id)
@@ -136,7 +138,7 @@ ErrorDocument 404 /404/index.html'
136
138
 
137
139
  # save image
138
140
  if page['image']
139
- page['image'] = self.getAndSaveImages(end_point + '/media/images/pages/'+site_id+'/' + page['image'], jekyll_path+'/assets/images/pages/' + page['image'])
141
+ page['image'] = self.getAndSaveImages(end_point + '/media/images/'+site_id+'/pages/' + page['image'], jekyll_path+'/assets/images/pages/' + page['image'])
140
142
  end
141
143
  end
142
144
 
@@ -194,18 +196,20 @@ ErrorDocument 404 /404/index.html'
194
196
  data['taxonomy'].each do |taxonomy_data_type|
195
197
  taxonomy_data_type['taxonomies'].each do |taxonomy|
196
198
  if '1' == taxonomy['enable_images']
197
- FileUtils::mkdir_p jekyll_path+'/assets/images/tax-images/' + taxonomy['id']
198
-
199
- if taxonomy.key?("terms")
200
- taxonomy['terms'].each do |term|
201
- if term['image']
202
- image_path = jekyll_path+'/assets/images/tax-images/' + term['taxonomy_id']
203
- src_image = end_point + '/media/images/taxonomies/' + term['taxonomy_id'] + '/' + term["image"]
204
-
205
- term['image'] = self.getAndSaveImages(src_image, image_path + '/' + term["image"])
206
- end
207
- end
208
- end
199
+ FileUtils::mkdir_p jekyll_path+'/assets/images/tax-images/' + taxonomy['id']
200
+
201
+ if taxonomy.key?("terms")
202
+ taxonomy['terms'].each do |term|
203
+ if term['image']
204
+ image_path = jekyll_path+'/assets/images/tax-images/' + term['taxonomy_id']
205
+ src_image = end_point + '/media/images/'+site_id+'/taxonomies/' + term["image"]
206
+
207
+ #puts 'A: ' + src_image + ' -> ' + image_path + '/' + term["image"]
208
+
209
+ term['image'] = self.getAndSaveImages(src_image, image_path + '/' + term["image"])
210
+ end
211
+ end
212
+ end
209
213
  end
210
214
  end
211
215
  end
@@ -243,7 +247,7 @@ ErrorDocument 404 /404/index.html'
243
247
 
244
248
  # save image
245
249
  if post['image']
246
- post['image'] = self.getAndSaveImages(end_point + '/media/images/posts/'+site_id+'/' + post['image'], jekyll_path+'/assets/images/posts/' + post['image'])
250
+ post['image'] = self.getAndSaveImages(end_point + '/media/images/'+site_id+'/posts/' + post['image'], jekyll_path+'/assets/images/posts/' + post['image'])
247
251
  end
248
252
 
249
253
  jpost = JekyllPost.new(jekyll_path+'/_posts', post)
@@ -267,7 +271,7 @@ ErrorDocument 404 /404/index.html'
267
271
  self.log(" - " + gallery['name'] + ' has ' + gallery['photos'].length.to_s + ' photos')
268
272
 
269
273
  gallery['photos'].each_with_index do |photo,pidx|
270
- photo['image'] = self.getAndSaveImages(end_point + '/media/images/galleries/photos/' + gallery['id'] + '/' + photo['image'], jekyll_path+'/assets/images/galleries/' + gallery['id'] + '/' + photo['image'])
274
+ photo['image'] = self.getAndSaveImages(end_point + '/media/images/'+site_id+'/galleries/photos/' + gallery['id'] + '/' + photo['image'], jekyll_path+'/assets/images/galleries/' + gallery['id'] + '/' + photo['image'])
271
275
  end
272
276
  end
273
277
 
@@ -288,11 +292,11 @@ ErrorDocument 404 /404/index.html'
288
292
  if data['calendar'].key?("events")
289
293
  data['calendar']['events'].each do |event|
290
294
  if event['image']
291
- event['image'] = self.getAndSaveImages(end_point + '/media/images/calendar/'+site_id+'/' + event['image'], jekyll_path+'/assets/images/calendar/' + event['image'])
295
+ event['image'] = self.getAndSaveImages(end_point + '/media/images/'+site_id+'/calendar/' + event['image'], jekyll_path+'/assets/images/calendar/' + event['image'])
292
296
  end
293
297
 
294
298
  if event['file']
295
- self.getAndSaveFile(end_point + '/media/files/calendar/'+site_id+'/' + event['file'], jekyll_path+'/assets/files/calendar/' + event['file'])
299
+ self.getAndSaveFile(end_point + '/media/files/'+site_id+'/calendar/' + event['file'], jekyll_path+'/assets/files/calendar/' + event['file'])
296
300
  end
297
301
  end
298
302
  end
@@ -314,14 +318,14 @@ ErrorDocument 404 /404/index.html'
314
318
  if menu['image']
315
319
  menu_image_path = jekyll_path+'/assets/images/menus'
316
320
 
317
- src_image = end_point + '/media/images/menus/' + site_id + '/' + menu['image']
321
+ src_image = end_point + '/media/images/'+site_id+'/menus/' + menu['image']
318
322
 
319
323
  menu['image'] = self.getAndSaveImages(src_image, menu_image_path + '/' + menu['image'])
320
324
  end
321
325
  if menu['download']
322
326
  menu_download_path = jekyll_path+'/assets/files/menus'
323
327
 
324
- src_image = end_point + '/media/files/menu_downloads/' + site_id + '/' + menu['download']
328
+ src_image = end_point + '/media/files/'+site_id+'/menu_downloads/' + menu['download']
325
329
 
326
330
  self.getAndSaveFile(src_image, menu_download_path + '/' + menu['download'])
327
331
  end
@@ -331,7 +335,7 @@ ErrorDocument 404 /404/index.html'
331
335
  image_path = jekyll_path+'/assets/images/menus/items/'+menu['id']
332
336
  FileUtils::mkdir_p image_path
333
337
 
334
- src_image = end_point + '/media/images/menu_items/'+menu['id']+'/' + item['image']
338
+ src_image = end_point + '/media/images/'+site_id+'/menus/items/' + item['image']
335
339
 
336
340
  item['image'] = self.getAndSaveImages(src_image, image_path+'/' + item['image'])
337
341
  end
@@ -357,7 +361,7 @@ ErrorDocument 404 /404/index.html'
357
361
 
358
362
  download_path = jekyll_path+'/assets/files/downloads'
359
363
 
360
- src_file = end_point + '/media/files/downloads/' + site_id + '/' + download['file']
364
+ src_file = end_point + '/media/files/'+site_id+'/downloads/' + download['file']
361
365
 
362
366
  self.getAndSaveFile(src_file, download_path + '/' + download['file'])
363
367
  end
@@ -405,7 +409,7 @@ ErrorDocument 404 /404/index.html'
405
409
  if gallery.key?("images")
406
410
  # save images
407
411
  gallery['images'].each_with_index do |image,idx|
408
- src_image = end_point + '/media/images/properties/'+row['id']+'/' + image['image']
412
+ src_image = end_point + '/media/images/'+site_id+'/properties/'+row['id']+'/' + image['image']
409
413
 
410
414
  data['properties']['data'][pidx]['galleries'][gidx]['images'][idx]['image'] = self.getAndSaveImages(src_image, image_path+'/' + image['image'])
411
415
  end
@@ -421,7 +425,7 @@ ErrorDocument 404 /404/index.html'
421
425
  # save images
422
426
  row['images'].each_with_index do |image,idx|
423
427
 
424
- src_image = end_point + '/media/images/properties/'+row['id']+'/' + image['image']
428
+ src_image = end_point + '/media/images/'+site_id+'/properties/'+row['id']+'/' + image['image']
425
429
 
426
430
  data['properties']['data'][pidx]['images'][idx]['image'] = self.getAndSaveImages(src_image, image_path+'/' + image['image'])
427
431
  end
@@ -432,11 +436,11 @@ ErrorDocument 404 /404/index.html'
432
436
  if row[ option['key'] ]
433
437
  case option['input_type']
434
438
  when 'file'
435
- src_file = end_point + '/media/files/property_files/'+site_id+'/' + row[ option['key'] ]
439
+ src_file = end_point + '/media/files/'+site_id+'/property_files/' + row[ option['key'] ]
436
440
 
437
441
  self.getAndSaveFile(src_file, option_file_path+'/' + row[ option['key'] ])
438
442
  when 'image'
439
- src_image = end_point + '/media/images/property_images/' + site_id + '/' + row[ option['key'] ]
443
+ src_image = end_point + '/media/images/'+site_id+'/property_images/' + row[ option['key'] ]
440
444
 
441
445
 
442
446
  data['properties']['data'][pidx][ option['key'] ] = self.getAndSaveImages(src_image, option_image_path+'/' + row[ option['key'] ])
@@ -478,7 +482,7 @@ ErrorDocument 404 /404/index.html'
478
482
  image_path = jekyll_path+'/assets/images/'+collection_type
479
483
  FileUtils::mkdir_p image_path
480
484
 
481
- src_image = end_point + '/media/images/'+collection_type+'/'+site_id+'/' + val
485
+ src_image = end_point + '/media/images/'+site_id+'/'+collection_type+'/' + val
482
486
 
483
487
  collection_data['data'][cidx][fld_key] = self.getAndSaveImages(src_image, image_path+'/' + val)
484
488
  when 'file'
@@ -486,7 +490,7 @@ ErrorDocument 404 /404/index.html'
486
490
  file_path = jekyll_path+'/assets/files/'+collection_type
487
491
  FileUtils::mkdir_p file_path
488
492
 
489
- src_file = end_point + '/media/files/'+collection_type+'/'+site_id+'/' + val
493
+ src_file = end_point + '/media/files/'+site_id+'/'+collection_type+'/' + val
490
494
 
491
495
  self.getAndSaveFile(src_file, file_path+'/' + val)
492
496
  end
@@ -508,7 +512,7 @@ ErrorDocument 404 /404/index.html'
508
512
  image_path = jekyll_path+'/assets/images/'+collection_type+'/'+hasmany_type+'/'+row['id']
509
513
  FileUtils::mkdir_p image_path
510
514
 
511
- src_image = end_point + '/media/images/'+collection_type+'/'+site_id+'/'+row['id']+'/' + val
515
+ src_image = end_point + '/media/images/'+site_id+'/'+collection_type+'/'+row['id']+'/' + val
512
516
 
513
517
  collection_data['data'][cidx]['hasmany_data'][hasmany_type]['data'][hsidx][fld_key] = self.getAndSaveImages(src_image, image_path+'/' + val)
514
518
  when 'file'
@@ -516,7 +520,7 @@ ErrorDocument 404 /404/index.html'
516
520
  file_path = jekyll_path+'/assets/files/'+collection_type+'/'+hasmany_type+'/'+row['id']
517
521
  FileUtils::mkdir_p file_path
518
522
 
519
- src_file = end_point + '/media/files/'+collection_type+'/'+site_id+'/'+row['id']+'/' + val
523
+ src_file = end_point + '/media/files/'+site_id+'/'+collection_type+'/'+row['id']+'/' + val
520
524
 
521
525
  self.getAndSaveFile(src_file, file_path+'/' + val)
522
526
  end
@@ -583,7 +587,8 @@ ErrorDocument 404 /404/index.html'
583
587
  ##puts ' - ' + idx.to_s + ' saving tax image'
584
588
  ##puts ' - - ['+tax_row["image"]+']'
585
589
  image_path = @@jekyll_path+'/assets/images/tax-images/' + tax_row['taxonomy_id']
586
- src_image = @@end_point + '/media/images/taxonomies/' + tax_row['taxonomy_id'] + '/' + tax_row["image"]
590
+ src_image = @@end_point + '/media/images/'+@@site_id+'/taxonomies/' + tax_row["image"]
591
+ #puts 'F: ' + src_image + ' -> ' + image_path + '/' + tax_row["image"]
587
592
 
588
593
  row['taxonomy'][idx]['image'] = self.getAndSaveImages(src_image, image_path + '/' + tax_row["image"])
589
594
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zerofetcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.50
4
+ version: 0.0.51
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Liccardo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-17 00:00:00.000000000 Z
11
+ date: 2017-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: image_optimizer