zerofetcher 0.0.39 → 0.0.40
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 +1 -1
- data/lib/code/JekyllPost.rb +4 -0
- data/lib/zerofetcher.rb +52 -8
- 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: 8ad98b66ac1d0daa89686aefd7caf814e535a907
|
4
|
+
data.tar.gz: 228c46b0b6c65d863a4b65c3b08f1a38a87be9b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf16694aeea22492508fd1247034f373b2b1abafe990d03e5439c23ec539d7a4b3329b6829594a1c89dbb0ab5d037e7458f52ec72de1eac7edee37b96492399f
|
7
|
+
data.tar.gz: d2058f6ed22db446e672a63fd0f7090e115141b8eb839110858e53d1cad4befda68805d5995f7d7c1b45b5c855bb3be660213b0a74759b61302402adeaa81884
|
data/lib/code/JekyllFile.rb
CHANGED
data/lib/code/JekyllPost.rb
CHANGED
data/lib/zerofetcher.rb
CHANGED
@@ -15,6 +15,7 @@ class ZeroFetcher
|
|
15
15
|
@@logger
|
16
16
|
@@jekyll_path
|
17
17
|
@@image_variants
|
18
|
+
@@end_point
|
18
19
|
|
19
20
|
def self.run
|
20
21
|
# Paths
|
@@ -37,6 +38,7 @@ class ZeroFetcher
|
|
37
38
|
FileUtils::mkdir_p jekyll_path+'/assets/images'
|
38
39
|
FileUtils::mkdir_p jekyll_path+'/assets/images/pages'
|
39
40
|
FileUtils::mkdir_p jekyll_path+'/assets/files'
|
41
|
+
FileUtils::mkdir_p jekyll_path+'/assets/images/tax-images'
|
40
42
|
FileUtils::mkdir_p jekyll_path+'/_includes'
|
41
43
|
FileUtils::mkdir_p jekyll_path+'/_includes/pages'
|
42
44
|
FileUtils::mkdir_p jekyll_path+'/_includes/content_blocks'
|
@@ -57,6 +59,7 @@ class ZeroFetcher
|
|
57
59
|
end
|
58
60
|
|
59
61
|
end_point = config['fetcher']['end_point']
|
62
|
+
@@end_point = end_point
|
60
63
|
site_id = config['fetcher']['site_id'].to_s
|
61
64
|
|
62
65
|
# Load data from API
|
@@ -103,7 +106,7 @@ ErrorDocument 404 /404/index.html'
|
|
103
106
|
|
104
107
|
# Loop through each page
|
105
108
|
data['pages'].each do |page|
|
106
|
-
puts page['name']
|
109
|
+
puts ' - ' + page['name']
|
107
110
|
self.log(' - ' + page['name'])
|
108
111
|
|
109
112
|
jpage = JekyllFile.new(jekyll_path, page, 'page')
|
@@ -172,6 +175,17 @@ ErrorDocument 404 /404/index.html'
|
|
172
175
|
end
|
173
176
|
end
|
174
177
|
|
178
|
+
# Taxonomy
|
179
|
+
if data.key?("taxonomy")
|
180
|
+
data['taxonomy'].each do |taxonomy_data_type|
|
181
|
+
taxonomy_data_type['taxonomies'].each do |taxonomy|
|
182
|
+
if '1' == taxonomy['enable_images']
|
183
|
+
FileUtils::mkdir_p jekyll_path+'/assets/images/tax-images/' + taxonomy['id']
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
175
189
|
# Nav Menus
|
176
190
|
if data.key?("nav_menus")
|
177
191
|
puts 'Nav menus - ' + data['nav_menus'].length.to_s
|
@@ -196,6 +210,9 @@ ErrorDocument 404 /404/index.html'
|
|
196
210
|
data['posts'].each do |post|
|
197
211
|
self.log('Saving Post File ' + post['date']+'-'+post['slug']+'.md')
|
198
212
|
|
213
|
+
# Do Tax
|
214
|
+
self.taxonomyImages(post)
|
215
|
+
|
199
216
|
# save image
|
200
217
|
if post['image']
|
201
218
|
post['image'] = self.getAndSaveImages(end_point + '/media/images/posts/'+site_id+'/' + post['image'], jekyll_path+'/assets/images/posts/' + post['image'])
|
@@ -308,6 +325,8 @@ ErrorDocument 404 /404/index.html'
|
|
308
325
|
|
309
326
|
# Download Files
|
310
327
|
data['downloads'].each do |download|
|
328
|
+
self.taxonomyImages(download)
|
329
|
+
|
311
330
|
download_path = jekyll_path+'/assets/files/downloads'
|
312
331
|
|
313
332
|
src_file = end_point + '/media/files/downloads/' + site_id + '/' + download['file']
|
@@ -344,7 +363,9 @@ ErrorDocument 404 /404/index.html'
|
|
344
363
|
row_data.delete('id')
|
345
364
|
id_key = 'property_id'
|
346
365
|
row_data[ id_key ] = row['id']
|
347
|
-
|
366
|
+
|
367
|
+
# process taxonomies
|
368
|
+
self.taxonomyImages(data['properties']['data'][pidx])
|
348
369
|
|
349
370
|
# Save Images
|
350
371
|
if row.key?("galleries")
|
@@ -356,7 +377,6 @@ ErrorDocument 404 /404/index.html'
|
|
356
377
|
if gallery.key?("images")
|
357
378
|
# save images
|
358
379
|
gallery['images'].each_with_index do |image,idx|
|
359
|
-
|
360
380
|
src_image = end_point + '/media/images/properties/'+row['id']+'/' + image['image']
|
361
381
|
|
362
382
|
data['properties']['data'][pidx]['galleries'][gidx]['images'][idx]['image'] = self.getAndSaveImages(src_image, image_path+'/' + image['image'])
|
@@ -526,6 +546,26 @@ ErrorDocument 404 /404/index.html'
|
|
526
546
|
@@logger.close
|
527
547
|
end
|
528
548
|
|
549
|
+
def self.taxonomyImages(row)
|
550
|
+
if row.key?("taxonomy")
|
551
|
+
##puts ' - Found taxonomy key ['+row['id']+']'
|
552
|
+
row['taxonomy'].each_with_index do |tax_row,idx|
|
553
|
+
if tax_row.key?("image")
|
554
|
+
if tax_row["image"]
|
555
|
+
##puts ' - ' + idx.to_s + ' saving tax image'
|
556
|
+
##puts ' - - ['+tax_row["image"]+']'
|
557
|
+
image_path = @@jekyll_path+'/assets/images/tax-images/' + tax_row['taxonomy_id']
|
558
|
+
src_image = @@end_point + '/media/images/taxonomies/' + tax_row['taxonomy_id'] + '/' + tax_row["image"]
|
559
|
+
|
560
|
+
row['taxonomy'][idx]['image'] = self.getAndSaveImages(src_image, image_path + '/' + tax_row["image"])
|
561
|
+
end
|
562
|
+
end
|
563
|
+
end
|
564
|
+
end
|
565
|
+
|
566
|
+
#return row
|
567
|
+
end
|
568
|
+
|
529
569
|
def self.log(data)
|
530
570
|
@@logger.debug { data }
|
531
571
|
end
|
@@ -584,10 +624,12 @@ ErrorDocument 404 /404/index.html'
|
|
584
624
|
images = {
|
585
625
|
'original' => File.basename( dest )
|
586
626
|
}
|
587
|
-
|
627
|
+
|
588
628
|
# Save Original
|
589
|
-
if
|
590
|
-
self.
|
629
|
+
if !File.file?( dest )
|
630
|
+
if self.getAndSaveFile( source, dest )
|
631
|
+
self.optimizeImage( dest )
|
632
|
+
end
|
591
633
|
end
|
592
634
|
|
593
635
|
# Save Variants
|
@@ -596,8 +638,10 @@ ErrorDocument 404 /404/index.html'
|
|
596
638
|
v_source = self.getImageVariantSource(source, variant)
|
597
639
|
v_dest = self.getImageVariantDestination(dest, variant)
|
598
640
|
|
599
|
-
if
|
600
|
-
self.
|
641
|
+
if !File.file?( v_dest )
|
642
|
+
if self.getAndSaveFile( v_source, v_dest )
|
643
|
+
self.optimizeImage( v_dest )
|
644
|
+
end
|
601
645
|
end
|
602
646
|
|
603
647
|
images[ variant['key'] ] = File.basename( v_dest )
|
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.
|
4
|
+
version: 0.0.40
|
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-
|
11
|
+
date: 2017-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: image_optimizer
|