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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3210e18667ce331087550114aff0247b8db366e
4
- data.tar.gz: 968b0236483f3690e74f80b96c8268c845181d95
3
+ metadata.gz: be001929b75652e1b28f94b958f72a56cd405a4c
4
+ data.tar.gz: 25aa947d4044236c32ac6979d73d0fb8b869bad8
5
5
  SHA512:
6
- metadata.gz: eb7f9246eae24fda75e40facb75be48f006d175c2398f446f19bbdfe29d40b3973bc78b8ef0b5a271c5b915c9bf87b8ec8781bff7f616a4f21f33fcb79e3dec8
7
- data.tar.gz: 892e54ddeafe125d18f27528d3f550946aaabb75085a952310a1cc72d08cd9c8a2789977f581965f9b3467e906f883c2364f9c1bfadbc64227bec95df2ab3aa2
6
+ metadata.gz: b8ec366de567e282969b7ea8af3f27e4fac2a79d5a97f084bd3645049804f9cfd177fad5cc524d0ae37c52ba1ee97eb9b965daafab84203efc56f0f6059b60e4
7
+ data.tar.gz: faf7a44e0542bad27781eb36fb31bb96416e8d64ac2b298ba597f5a5104f6715c8cfb57af933679cafa6d28b56348cc937c7286ac638df02b97852b70dcfedc6
@@ -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
@@ -27,6 +27,7 @@ class JekyllPost
27
27
  'date' => post['date'],
28
28
  'excerpt' => post['excerpt'],
29
29
  'categories' => post['categories'],
30
+ 'source' => post['source'],
30
31
  }
31
32
 
32
33
  if post.key?("taxonomy")