zerofetcher 0.0.52 → 0.0.53
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 +157 -157
- data/lib/code/JekyllPost.rb +1 -0
- data/lib/zerofetcher.rb +729 -729
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be001929b75652e1b28f94b958f72a56cd405a4c
|
4
|
+
data.tar.gz: 25aa947d4044236c32ac6979d73d0fb8b869bad8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8ec366de567e282969b7ea8af3f27e4fac2a79d5a97f084bd3645049804f9cfd177fad5cc524d0ae37c52ba1ee97eb9b965daafab84203efc56f0f6059b60e4
|
7
|
+
data.tar.gz: faf7a44e0542bad27781eb36fb31bb96416e8d64ac2b298ba597f5a5104f6715c8cfb57af933679cafa6d28b56348cc937c7286ac638df02b97852b70dcfedc6
|
data/lib/code/JekyllFile.rb
CHANGED
@@ -1,158 +1,158 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class JekyllFile
|
4
|
-
@file_path
|
5
|
-
@file_exists = false
|
6
|
-
@file_contents
|
7
|
-
@yaml_section = ''
|
8
|
-
@yaml_parsed = {}
|
9
|
-
@content_section = ''
|
10
|
-
@file_data
|
11
|
-
@file_name
|
12
|
-
@ignore_keys = []
|
13
|
-
@content_keys = ['content']
|
14
|
-
@file_type
|
15
|
-
|
16
|
-
def initialize(path, data, file_type)
|
17
|
-
@content_keys = ['content']
|
18
|
-
|
19
|
-
@file_data = data;
|
20
|
-
@file_type = file_type
|
21
|
-
|
22
|
-
case @file_type
|
23
|
-
when 'page'
|
24
|
-
@file_name = data['url'] + '.md';
|
25
|
-
else
|
26
|
-
@file_name = data['slug'] + '.md';
|
27
|
-
end
|
28
|
-
@file_path = path + '/' + @file_name;
|
29
|
-
|
30
|
-
@yaml_parsed = {}
|
31
|
-
if Pathname.new(@file_path).file?
|
32
|
-
parseFile
|
33
|
-
else
|
34
|
-
if 'page' == @file_type
|
35
|
-
# disabled permalinks for pages
|
36
|
-
#@yaml_parsed = {
|
37
|
-
# 'permalink' => '/' + @file_data['url'] + '/'
|
38
|
-
# }
|
39
|
-
|
40
|
-
#@content_section = '{% include pages/' + @file_data['url'] + '.md %}'
|
41
|
-
@content_section = '{% capture ' + @file_data['url'] + ' %}{% include pages/' + @file_data['url'] + '.md %}{% endcapture %}
|
42
|
-
{{ ' + @file_data['url'] + ' | markdownify }}'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# set layout
|
47
|
-
if !@yaml_parsed.key?('layout') || 'page' == @file_type
|
48
|
-
@yaml_parsed['layout'] = getPageLayout
|
49
|
-
end
|
50
|
-
|
51
|
-
# do some file type specific stuff
|
52
|
-
case @file_type
|
53
|
-
when 'page'
|
54
|
-
# set page title
|
55
|
-
@yaml_parsed['title'] = @file_data['name']
|
56
|
-
if @file_data['image']
|
57
|
-
@yaml_parsed['image'] = 'images/pages/' + @file_data['image']
|
58
|
-
end
|
59
|
-
|
60
|
-
@yaml_parsed['page_id'] = @file_data['id']
|
61
|
-
@yaml_parsed['meta_title'] = (@file_data['meta_title']) ? @file_data['meta_title'] : @file_data['name']
|
62
|
-
@yaml_parsed['meta_description'] = @file_data['meta_description']
|
63
|
-
else
|
64
|
-
# add file data
|
65
|
-
@file_data.each do |key, value|
|
66
|
-
if !@content_keys.include?(key)
|
67
|
-
@yaml_parsed[key] = value
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# add content
|
72
|
-
@content_keys.each do |key|
|
73
|
-
if @file_data.key?(key)
|
74
|
-
if @file_data[key].is_a? String
|
75
|
-
@content_section = @file_data[key]
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def getPageLayout
|
83
|
-
case @file_type
|
84
|
-
when 'page'
|
85
|
-
if @file_data['layout']
|
86
|
-
layout = File.basename(@file_data['layout'],File.extname(@file_data['layout']))
|
87
|
-
else
|
88
|
-
if 'index' == @file_data['url']
|
89
|
-
layout = 'home'
|
90
|
-
else
|
91
|
-
layout = 'page'
|
92
|
-
end
|
93
|
-
end
|
94
|
-
else
|
95
|
-
layout = 'post'
|
96
|
-
end
|
97
|
-
|
98
|
-
#puts "Layout:" + layout
|
99
|
-
|
100
|
-
return layout
|
101
|
-
end
|
102
|
-
|
103
|
-
def getFileName
|
104
|
-
return @file_name
|
105
|
-
end
|
106
|
-
|
107
|
-
def parseFile
|
108
|
-
file_contents = ZeroFetcher.readFile(@file_path)
|
109
|
-
|
110
|
-
file_contents.gsub!(/\r\n?/, "\n")
|
111
|
-
|
112
|
-
area = false
|
113
|
-
@yaml_section = ''
|
114
|
-
@content_section = ''
|
115
|
-
|
116
|
-
file_contents.each_line do |line|
|
117
|
-
sline = line
|
118
|
-
|
119
|
-
if '---' == sline.strip
|
120
|
-
case area
|
121
|
-
when false
|
122
|
-
area = 'yaml'
|
123
|
-
when 'yaml'
|
124
|
-
area = 'content'
|
125
|
-
end
|
126
|
-
else
|
127
|
-
case area
|
128
|
-
when 'yaml'
|
129
|
-
@yaml_section += line
|
130
|
-
when 'content'
|
131
|
-
@content_section += line
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
@yaml_parsed = YAML.load(@yaml_section)
|
137
|
-
end
|
138
|
-
|
139
|
-
def getFileName()
|
140
|
-
return @file_path;
|
141
|
-
end
|
142
|
-
|
143
|
-
def saveContentFile(file_path, contents)
|
144
|
-
File.write(file_path, contents)
|
145
|
-
end
|
146
|
-
|
147
|
-
def savePageFile
|
148
|
-
#file_contents = '---A'+"\n"
|
149
|
-
#file_contents += YAML.generate(@yaml_parsed)+"\n"
|
150
|
-
file_contents = @yaml_parsed.to_yaml
|
151
|
-
file_contents += '---'+"\n"
|
152
|
-
|
153
|
-
if @content_section.is_a? String
|
154
|
-
file_contents += @content_section
|
155
|
-
end
|
156
|
-
File.write(@file_path, file_contents)
|
157
|
-
end
|
1
|
+
|
2
|
+
|
3
|
+
class JekyllFile
|
4
|
+
@file_path
|
5
|
+
@file_exists = false
|
6
|
+
@file_contents
|
7
|
+
@yaml_section = ''
|
8
|
+
@yaml_parsed = {}
|
9
|
+
@content_section = ''
|
10
|
+
@file_data
|
11
|
+
@file_name
|
12
|
+
@ignore_keys = []
|
13
|
+
@content_keys = ['content']
|
14
|
+
@file_type
|
15
|
+
|
16
|
+
def initialize(path, data, file_type)
|
17
|
+
@content_keys = ['content']
|
18
|
+
|
19
|
+
@file_data = data;
|
20
|
+
@file_type = file_type
|
21
|
+
|
22
|
+
case @file_type
|
23
|
+
when 'page'
|
24
|
+
@file_name = data['url'] + '.md';
|
25
|
+
else
|
26
|
+
@file_name = data['slug'] + '.md';
|
27
|
+
end
|
28
|
+
@file_path = path + '/' + @file_name;
|
29
|
+
|
30
|
+
@yaml_parsed = {}
|
31
|
+
if Pathname.new(@file_path).file?
|
32
|
+
parseFile
|
33
|
+
else
|
34
|
+
if 'page' == @file_type
|
35
|
+
# disabled permalinks for pages
|
36
|
+
#@yaml_parsed = {
|
37
|
+
# 'permalink' => '/' + @file_data['url'] + '/'
|
38
|
+
# }
|
39
|
+
|
40
|
+
#@content_section = '{% include pages/' + @file_data['url'] + '.md %}'
|
41
|
+
@content_section = '{% capture ' + @file_data['url'] + ' %}{% include pages/' + @file_data['url'] + '.md %}{% endcapture %}
|
42
|
+
{{ ' + @file_data['url'] + ' | markdownify }}'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# set layout
|
47
|
+
if !@yaml_parsed.key?('layout') || 'page' == @file_type
|
48
|
+
@yaml_parsed['layout'] = getPageLayout
|
49
|
+
end
|
50
|
+
|
51
|
+
# do some file type specific stuff
|
52
|
+
case @file_type
|
53
|
+
when 'page'
|
54
|
+
# set page title
|
55
|
+
@yaml_parsed['title'] = @file_data['name']
|
56
|
+
if @file_data['image']
|
57
|
+
@yaml_parsed['image'] = 'images/pages/' + @file_data['image']
|
58
|
+
end
|
59
|
+
|
60
|
+
@yaml_parsed['page_id'] = @file_data['id']
|
61
|
+
@yaml_parsed['meta_title'] = (@file_data['meta_title']) ? @file_data['meta_title'] : @file_data['name']
|
62
|
+
@yaml_parsed['meta_description'] = @file_data['meta_description']
|
63
|
+
else
|
64
|
+
# add file data
|
65
|
+
@file_data.each do |key, value|
|
66
|
+
if !@content_keys.include?(key)
|
67
|
+
@yaml_parsed[key] = value
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# add content
|
72
|
+
@content_keys.each do |key|
|
73
|
+
if @file_data.key?(key)
|
74
|
+
if @file_data[key].is_a? String
|
75
|
+
@content_section = @file_data[key]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def getPageLayout
|
83
|
+
case @file_type
|
84
|
+
when 'page'
|
85
|
+
if @file_data['layout']
|
86
|
+
layout = File.basename(@file_data['layout'],File.extname(@file_data['layout']))
|
87
|
+
else
|
88
|
+
if 'index' == @file_data['url']
|
89
|
+
layout = 'home'
|
90
|
+
else
|
91
|
+
layout = 'page'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
else
|
95
|
+
layout = 'post'
|
96
|
+
end
|
97
|
+
|
98
|
+
#puts "Layout:" + layout
|
99
|
+
|
100
|
+
return layout
|
101
|
+
end
|
102
|
+
|
103
|
+
def getFileName
|
104
|
+
return @file_name
|
105
|
+
end
|
106
|
+
|
107
|
+
def parseFile
|
108
|
+
file_contents = ZeroFetcher.readFile(@file_path)
|
109
|
+
|
110
|
+
file_contents.gsub!(/\r\n?/, "\n")
|
111
|
+
|
112
|
+
area = false
|
113
|
+
@yaml_section = ''
|
114
|
+
@content_section = ''
|
115
|
+
|
116
|
+
file_contents.each_line do |line|
|
117
|
+
sline = line
|
118
|
+
|
119
|
+
if '---' == sline.strip
|
120
|
+
case area
|
121
|
+
when false
|
122
|
+
area = 'yaml'
|
123
|
+
when 'yaml'
|
124
|
+
area = 'content'
|
125
|
+
end
|
126
|
+
else
|
127
|
+
case area
|
128
|
+
when 'yaml'
|
129
|
+
@yaml_section += line
|
130
|
+
when 'content'
|
131
|
+
@content_section += line
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
@yaml_parsed = YAML.load(@yaml_section)
|
137
|
+
end
|
138
|
+
|
139
|
+
def getFileName()
|
140
|
+
return @file_path;
|
141
|
+
end
|
142
|
+
|
143
|
+
def saveContentFile(file_path, contents)
|
144
|
+
File.write(file_path, contents)
|
145
|
+
end
|
146
|
+
|
147
|
+
def savePageFile
|
148
|
+
#file_contents = '---A'+"\n"
|
149
|
+
#file_contents += YAML.generate(@yaml_parsed)+"\n"
|
150
|
+
file_contents = @yaml_parsed.to_yaml
|
151
|
+
file_contents += '---'+"\n"
|
152
|
+
|
153
|
+
if @content_section.is_a? String
|
154
|
+
file_contents += @content_section
|
155
|
+
end
|
156
|
+
File.write(@file_path, file_contents)
|
157
|
+
end
|
158
158
|
end
|