zerofetcher 0.0.65 → 0.0.66
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 +39 -5
- data/lib/zerofetcher.rb +43 -13
- 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: d6bd054435e240ea767588139e166b639716768e
|
4
|
+
data.tar.gz: 5c7fdf05c2169aa69631caf22c5a0b9e524a542e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13dd6ee30da416a1affb6d4c373f32ea258c132acae6ecddfc8e915bdebebcb9c5c033f5654d59e0963985b7f33401921034cdb2af1456ec1f7f4f2e0dbcccaa
|
7
|
+
data.tar.gz: 5e624f6124a49ebb4ef59beffb0fb93321dc06aed5e7c0d7e4cd4efb1f5c518b95df0819ff53cd35dcedc586659db8685333d61c22a5cf0c38bff85d11931c34
|
data/lib/code/JekyllFile.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
class JekyllFile
|
4
4
|
@file_path
|
5
|
+
@base_path
|
5
6
|
@file_exists = false
|
6
7
|
@file_contents
|
7
8
|
@yaml_section = ''
|
@@ -29,7 +30,8 @@ class JekyllFile
|
|
29
30
|
else
|
30
31
|
@file_name = file_name + '.md';
|
31
32
|
end
|
32
|
-
|
33
|
+
|
34
|
+
@base_path = path
|
33
35
|
@file_path = path + '/' + @file_name;
|
34
36
|
|
35
37
|
@yaml_parsed = {}
|
@@ -43,8 +45,14 @@ class JekyllFile
|
|
43
45
|
# }
|
44
46
|
|
45
47
|
#@content_section = '{% include pages/' + @file_data['url'] + '.md %}'
|
46
|
-
|
47
|
-
|
48
|
+
|
49
|
+
content_file = @file_data['url']
|
50
|
+
if content_file.include? "/"
|
51
|
+
content_file = content_file.gsub(/\//, "_")
|
52
|
+
end
|
53
|
+
|
54
|
+
@content_section = '{% capture ' + content_file + ' %}{% include pages/' + content_file + '.md %}{% endcapture %}
|
55
|
+
{{ ' + content_file + ' | markdownify }}'
|
48
56
|
end
|
49
57
|
end
|
50
58
|
|
@@ -147,8 +155,16 @@ class JekyllFile
|
|
147
155
|
return @file_path;
|
148
156
|
end
|
149
157
|
|
150
|
-
def saveContentFile(file_path, contents)
|
151
|
-
|
158
|
+
def saveContentFile(file_path, file_name, contents)
|
159
|
+
if file_name.include? "/"
|
160
|
+
file_name = file_name.gsub(/\//, "_")
|
161
|
+
end
|
162
|
+
|
163
|
+
#puts "Create Content File" + file_path + '/' + file_name
|
164
|
+
|
165
|
+
ZeroFetcher.writeFile(file_path + '/' + file_name, contents)
|
166
|
+
|
167
|
+
return file_path + '/' + file_name
|
152
168
|
end
|
153
169
|
|
154
170
|
def savePageFile
|
@@ -160,6 +176,24 @@ class JekyllFile
|
|
160
176
|
if @content_section.is_a? String
|
161
177
|
file_contents += @content_section
|
162
178
|
end
|
179
|
+
|
180
|
+
# create folders
|
181
|
+
if 'page' == @file_type
|
182
|
+
if @file_name.include? "/"
|
183
|
+
parsed = @file_name.split("/")
|
184
|
+
|
185
|
+
folders = parsed.first parsed.size - 1
|
186
|
+
|
187
|
+
cur_path = @base_path
|
188
|
+
|
189
|
+
folders.each do |folder|
|
190
|
+
cur_path += '/' + folder
|
191
|
+
#puts "Create Dir" + cur_path
|
192
|
+
FileUtils::mkdir_p cur_path
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
163
197
|
File.write(@file_path, file_contents)
|
164
198
|
end
|
165
199
|
end
|
data/lib/zerofetcher.rb
CHANGED
@@ -98,6 +98,7 @@ ErrorDocument 404 /404/index.html'
|
|
98
98
|
# Pages
|
99
99
|
if data.key?("pages")
|
100
100
|
pages_files_saved = Array.new
|
101
|
+
content_files_saved = Array.new
|
101
102
|
|
102
103
|
pages_folder = jekyll_path+'/_includes/pages'
|
103
104
|
|
@@ -114,10 +115,14 @@ ErrorDocument 404 /404/index.html'
|
|
114
115
|
|
115
116
|
jpage = JekyllFile.new(jekyll_path, page, 'page')
|
116
117
|
|
117
|
-
jpage.saveContentFile(pages_folder
|
118
|
+
content_file = jpage.saveContentFile(pages_folder, page['url']+'.md', page['content'])
|
119
|
+
content_files_saved.push( content_file )
|
118
120
|
jpage.savePageFile
|
121
|
+
|
119
122
|
#pages_files_saved.push(jpage.getFileName)
|
120
|
-
pages_files_saved.push( Pathname.new( jpage.getFileName ).basename.to_s )
|
123
|
+
#pages_files_saved.push( Pathname.new( jpage.getFileName ).basename.to_s )
|
124
|
+
pages_files_saved.push( jpage.getFileName )
|
125
|
+
|
121
126
|
self.log(" - Saved:"+jpage.getFileName)
|
122
127
|
|
123
128
|
# Add to pages array
|
@@ -148,17 +153,10 @@ ErrorDocument 404 /404/index.html'
|
|
148
153
|
self.log("Writing File /_data/pages.json")
|
149
154
|
|
150
155
|
# Clean Unused Pages
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
if 'README.md' != file_basename
|
156
|
-
if !pages_files_saved.include?( file_basename )
|
157
|
-
self.log(" - Deleting:"+file)
|
158
|
-
FileUtils.rm(file)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
156
|
+
self.cleanUpPages( jekyll_path, pages_files_saved )
|
157
|
+
|
158
|
+
# Clean up content files
|
159
|
+
self.cleanUpPages( pages_folder, content_files_saved )
|
162
160
|
end
|
163
161
|
|
164
162
|
# Variables
|
@@ -808,6 +806,38 @@ ErrorDocument 404 /404/index.html'
|
|
808
806
|
end
|
809
807
|
end
|
810
808
|
end
|
809
|
+
|
810
|
+
def self.cleanUpPages( path, pages )
|
811
|
+
# clean up this folder
|
812
|
+
self.cleanUpPagesFolder( path, pages )
|
813
|
+
|
814
|
+
ignore_dirs = ['assets','node_modules','nbproject']
|
815
|
+
ignore_starts = ['.','_']
|
816
|
+
dirs = Dir.entries( path ).select {|entry| File.directory? File.join(path,entry) and !(ignore_dirs.include?(entry) || ignore_starts.include?( entry[0] )) }
|
817
|
+
|
818
|
+
dirs.each do |dir|
|
819
|
+
this_dir = path + '/' + dir
|
820
|
+
if !File.exist?( this_dir + '/.keep' )
|
821
|
+
puts "Clean Dir " + dir
|
822
|
+
self.cleanUpPagesFolder( this_dir, pages )
|
823
|
+
end
|
824
|
+
end
|
825
|
+
end
|
826
|
+
|
827
|
+
def self.cleanUpPagesFolder( path, pages )
|
828
|
+
existing_pages_files = Dir.glob(File.join(path, "*.md"))
|
829
|
+
|
830
|
+
existing_pages_files.each do |file|
|
831
|
+
puts " - f " + file
|
832
|
+
file_basename = Pathname.new(file).basename.to_s
|
833
|
+
if 'README.md' != file_basename
|
834
|
+
if !pages.include?( file )
|
835
|
+
self.log(" - Deleting:"+file)
|
836
|
+
FileUtils.rm(file)
|
837
|
+
end
|
838
|
+
end
|
839
|
+
end
|
840
|
+
end
|
811
841
|
end
|
812
842
|
|
813
843
|
|
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.66
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Liccardo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Fetches content from zero
|
14
14
|
email: brian@d3corp.com
|