wikisys 0.4.2 → 0.4.3

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
  SHA256:
3
- metadata.gz: 7df49481e6dd9b98d651456392c9dc2bdc74ccd65565a7a5a73818415c3ebb24
4
- data.tar.gz: 615021b76e6869b19f2b0885970778da4885b459bdc9d90adca8b159c5a756a7
3
+ metadata.gz: efc308c07d4ba81540d515d9e0ea02f7c60c74aedeea31e771a228af9c29b436
4
+ data.tar.gz: fccd8271b207195f628a8f0bd7aea544545b02aead003bfd401cb51b1b589ac2
5
5
  SHA512:
6
- metadata.gz: e6b9139472aa18dc3c7d76eed52a5d5f0ee5956f7ba061fde200989c605f7238d2c51779550f3f0f47da718694230e11c197853dd9a2949f38c4ed475249c536
7
- data.tar.gz: 5a7532e004d33a95f6802fe912cc6d791dccf0c7fe9f815330e59b91488a33067897af8d41d2332633705c9e6f6b82b42dae8ba4c3bad0beab074114dc8b2c52
6
+ metadata.gz: 25bfc39f238a76d18e37d62b104abb495adb83739a1cb2122c03078b92d1b6b353b5331f7bd483aeb6760ac580fa7823b82c9f1d9bfe2ae59f68b5b7718bd46a
7
+ data.tar.gz: 0b0e0335c7e15496b52b8f09bd14442f1bf9877671de04e46f47d7e73f610711052896c967f0fe05569322ed2b3d11377449731cbbafca593fcb957e47fa3c13
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -104,16 +104,24 @@ module Wikisys
104
104
 
105
105
  def modify_build(filename)
106
106
 
107
+ puts 'inside modify_buld' if @debug
108
+
107
109
  @title, @content, @tags = read_md(filename)
108
110
 
109
111
  # find the entry
110
112
  # modify the tags if necessary
113
+ puts '@title: ' + @title.inspect if @debug
114
+ puts '_ @content: ' + @content.inspect if @debug
111
115
 
112
116
  r = @entries.find_by_title @title
113
117
  puts 'r: ' + r.inspect if @debug
114
- return unless r
115
118
 
116
- write_xml(@title, build_xml(@title, @content, @tags))
119
+ if r.nil? then
120
+ r = @entries.create title: @title, tags: @tags.join(' ')
121
+ end
122
+
123
+ xmlfile = filename.sub(/\.md$/,'.xml')
124
+ write_xml(xmlfile, build_xml(@title, @content, @tags))
117
125
 
118
126
  r.tags = @tags.join(' ') if r.tags != @tags
119
127
 
@@ -156,15 +164,18 @@ module Wikisys
156
164
  def read_md(filename)
157
165
 
158
166
  filepath = File.join(@filepath, 'md', filename)
167
+ puts 'filepath : ' + filepath.inspect if @debug
159
168
  return unless File.exists? filepath
160
169
 
161
- s = read_file(filepath).strip
170
+ s = read_file(filepath).strip.gsub(/\r/,'')
171
+ puts 's: ' + s.inspect if @debug
162
172
 
163
173
  # read the title
164
174
  title = s.lines.first.chomp.sub(/^# +/,'')
165
175
 
166
176
  # read the hashtags if there is any
167
177
  tagsline = s.lines.last[/^ *\+ +(.*)/,1]
178
+ puts 'tagsline: ' + tagsline.inspect if @debug
168
179
 
169
180
  if tagsline then
170
181
 
@@ -172,13 +183,13 @@ module Wikisys
172
183
 
173
184
  else
174
185
 
175
- [title, s.lines[1..--1].join, []]
186
+ [title, s.lines[1..-1].join, []]
176
187
 
177
188
  end
178
189
 
179
190
  end
180
191
 
181
- def build_xml(title, content, tags)
192
+ def build_xml(title, content, rawtags)
182
193
 
183
194
  puts 'content: ' + content.inspect if @debug
184
195
  s = content.gsub(/\[\[[^\]]+\]\]/) do |raw_link|
@@ -207,7 +218,7 @@ module Wikisys
207
218
 
208
219
  heading = "<heading>%s</heading>" % title
209
220
 
210
- if tags.any? then
221
+ if rawtags.any? then
211
222
 
212
223
  list = tags.map {|tag| " <tag>%s</tag>" % tag}
213
224
  tags = "<tags>\n%s\n </tags>" % list.join("\n")
@@ -218,11 +229,12 @@ module Wikisys
218
229
  else
219
230
 
220
231
  body = "<body>%s</body>" % Martile.new(s.lines[1..-1].join.strip).to_html
232
+ tags = ''
221
233
 
222
234
  end
223
235
 
224
236
  "<article id='%s'>\n %s\n %s\n %s\n</article>" % \
225
- [title.downcase.gsub(/ +/,'-'), heading, body, tags]
237
+ [title.gsub(/ +/,'-'), heading, body, tags]
226
238
 
227
239
 
228
240
  end
@@ -237,10 +249,10 @@ module Wikisys
237
249
 
238
250
  end
239
251
 
240
- def write_xml(title, content)
252
+ def write_xml(s, content)
241
253
 
242
- filepath = File.join(File.absolute_path(@filepath), 'xml',
243
- title.downcase.gsub(/ +/,'_') + '.xml')
254
+ filename = s =~ /\.xml$/ ? s : s.gsub(/ +/,'_') + '.xml'
255
+ filepath = File.join(File.absolute_path(@filepath), 'xml', filename)
244
256
  FileUtils.mkdir_p File.dirname(filepath)
245
257
  #File.write filepath, content
246
258
  write_file filepath, content
@@ -276,8 +288,9 @@ module Wikisys
276
288
 
277
289
  def write_md(title, content)
278
290
 
279
- filepath = File.join(File.absolute_path(@filepath), 'md',
280
- title.gsub(/ +/,'_') + '.md')
291
+ puts 'inside write_md' if @debug
292
+ filename = s =~ /\.md$/ ? s : s.gsub(/ +/,'_') + '.md'
293
+ filepath = File.join(File.absolute_path(@filepath), 'md', filename)
281
294
  FileUtils.mkdir_p File.dirname(filepath)
282
295
  File.write filepath, content
283
296
 
@@ -312,10 +325,26 @@ module Wikisys
312
325
  @mw.filepath = mindwords_file
313
326
  end
314
327
 
315
- scan_md_files()
328
+ @pg = Wiki.new @filepath, entries: @entries, debug: @debug
329
+
330
+ #scan_md_files()
316
331
 
317
332
  end
318
333
 
334
+ def new_pg(filename)
335
+
336
+ @pg.new_build(filename)
337
+ update_mw(@pg.title, @pg.tags)
338
+
339
+ end
340
+
341
+ def update_pg(filename)
342
+
343
+ @pg.modify_build(filename)
344
+ update_mw(@pg.title, @pg.tags)
345
+
346
+ end
347
+
319
348
  private
320
349
 
321
350
 
@@ -331,22 +360,8 @@ module Wikisys
331
360
 
332
361
  return if (h[:new] + h[:modified]).empty?
333
362
 
334
- pg = Wiki.new @filepath, entries: @entries, debug: @debug
335
-
336
-
337
- h[:new].each do |filename|
338
-
339
- pg.new_build(filename)
340
- update_mw(pg.title, pg.tags)
341
-
342
- end
343
-
344
- h[:modified].each do |filename|
345
-
346
- pg.modify_build(filename)
347
- update_mw(pg.title, pg.tags)
348
-
349
- end
363
+ h[:new].each {|filename| new_pg(filename) }
364
+ h[:modified].each {|filename| update_pg(filename) }
350
365
 
351
366
  @mw.save if @mw.lines.any?
352
367
  outline_filepath = File.join(@filepath, 'myoutline.txt')
@@ -365,7 +380,7 @@ module Wikisys
365
380
  if found then
366
381
 
367
382
  links = found.breadcrumb.map do |x|
368
- [x, x.downcase.gsub(/ +/,'-') + '.html']
383
+ [x, x.gsub(/ +/,'-') + '.html']
369
384
  end
370
385
 
371
386
  pg.create_breadcrumb(filepath, links)
@@ -430,6 +445,7 @@ module Wikisys
430
445
  end
431
446
 
432
447
  end
448
+
433
449
 
434
450
  def view_file(file='index.html')
435
451
  @hc.read(file) { File.read(file) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wikisys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  O3SRDzvvWXrwDFGyRDmGqdEw51FKHPw/6pk4ci0QPIvQEgOyPKfdSesPWmNmtxpf
36
36
  KX/89ohIpftt89vtcCI21R5u
37
37
  -----END CERTIFICATE-----
38
- date: 2021-01-30 00:00:00.000000000 Z
38
+ date: 2021-01-31 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: dir-to-xml
metadata.gz.sig CHANGED
Binary file