wikisys 0.4.3 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/wikisys.rb +335 -198
- data.tar.gz.sig +0 -0
- metadata +39 -40
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49fa19fa6b420d8b8e0d89cfa8d254cf492ba3415a872bc860aa63e7a98ae48d
|
4
|
+
data.tar.gz: 3c18863700240d5b23bb945de9dde6cd9f8b4c49d571c7577b43d493c6f39416
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b90e03720ea801af4294079cd46c016c799d2d7d49a75623d38a0f857b9cb76d4dc9b631b5e7825a205422c611abf987a5ac952e4649cad532465160c7fd63f3
|
7
|
+
data.tar.gz: cdf44af5bb79a9fc39c470ff03864e8071a5c76ea2c9ade9d948a5169c5799d8583f2ce6a94c1221062764f026cff3c03c2948fffa9c4434f7f4bb53e6e54c24
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/wikisys.rb
CHANGED
@@ -7,6 +7,8 @@ require 'dir-to-xml'
|
|
7
7
|
require 'mindwords'
|
8
8
|
require 'martile'
|
9
9
|
require 'hashcache'
|
10
|
+
require 'rxfreadwrite'
|
11
|
+
|
10
12
|
|
11
13
|
module FileFetch
|
12
14
|
|
@@ -28,12 +30,26 @@ module FileFetch
|
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
33
|
+
module StringCase
|
34
|
+
|
35
|
+
refine String do
|
36
|
+
|
37
|
+
def capitalize2()
|
38
|
+
self.sub(/^[a-z]/) {|x| x.upcase }
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
31
45
|
module Wikisys
|
32
46
|
|
33
|
-
class Wiki
|
47
|
+
class Wiki
|
48
|
+
include RXFReadWriteModule
|
34
49
|
include FileFetch
|
35
50
|
using ColouredText
|
36
|
-
|
51
|
+
using StringCase
|
52
|
+
|
37
53
|
attr_accessor :title, :content, :tags
|
38
54
|
attr_reader :to_xml
|
39
55
|
|
@@ -42,15 +58,15 @@ module Wikisys
|
|
42
58
|
@filepath = filepath
|
43
59
|
@page = ''
|
44
60
|
@debug = debug
|
45
|
-
|
61
|
+
|
46
62
|
@hc = HashCache.new(size:30)
|
47
63
|
|
48
64
|
@entries = if entries.is_a? DxLite then
|
49
|
-
|
65
|
+
|
50
66
|
entries
|
51
|
-
|
67
|
+
|
52
68
|
elsif File.exists?(entries) then
|
53
|
-
|
69
|
+
|
54
70
|
DxLite.new(entries)
|
55
71
|
|
56
72
|
else
|
@@ -58,256 +74,283 @@ module Wikisys
|
|
58
74
|
DxLite.new('entries/entry(title, tags)')
|
59
75
|
|
60
76
|
end
|
61
|
-
|
77
|
+
|
62
78
|
end
|
63
|
-
|
79
|
+
|
64
80
|
def create_breadcrumb(filepath, links)
|
65
|
-
|
81
|
+
|
66
82
|
doc = Rexle.new(read_file(filepath))
|
67
83
|
heading = doc.root.element('heading')
|
68
|
-
|
84
|
+
|
69
85
|
menu = Rexle.new(HtmlCom::Menu.new(:breadcrumb, links).to_html)
|
70
|
-
|
86
|
+
|
71
87
|
heading.insert_before menu.root
|
72
88
|
write_file filepath, doc.root.xml
|
73
|
-
|
74
|
-
end
|
89
|
+
|
90
|
+
end
|
75
91
|
|
76
92
|
def page(title)
|
77
93
|
|
78
|
-
r = @entries.find_by_title title
|
94
|
+
r = @entries.find_by_title title
|
79
95
|
@page = r ? read_md(title) : make_page(title)
|
80
96
|
@to_xml = build_xml @page
|
81
97
|
@entries.save
|
82
|
-
|
98
|
+
|
83
99
|
return @page
|
84
100
|
|
85
101
|
end
|
86
|
-
|
102
|
+
|
87
103
|
def page=(raw_content)
|
88
|
-
|
104
|
+
|
89
105
|
title = raw_content.lines.first.chomp
|
90
|
-
|
106
|
+
|
91
107
|
r = @entries.find_by_title title
|
92
108
|
make_page(title, raw_content.lines.last.chomp[/(?<=\+ )/]) unless r
|
93
|
-
|
109
|
+
|
94
110
|
write_md title, raw_content
|
95
111
|
title, content, tags = read_md()
|
96
112
|
@to_xml = build_xml title, content, tags
|
97
113
|
write_xml title, @to_xml
|
98
114
|
|
99
|
-
|
115
|
+
|
100
116
|
@entries.save
|
101
117
|
@page = raw_content
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
def build_xml(filename)
|
123
|
+
|
107
124
|
puts 'inside modify_buld' if @debug
|
108
|
-
|
125
|
+
|
109
126
|
@title, @content, @tags = read_md(filename)
|
110
|
-
|
127
|
+
|
111
128
|
# find the entry
|
112
129
|
# modify the tags if necessary
|
113
130
|
puts '@title: ' + @title.inspect if @debug
|
114
131
|
puts '_ @content: ' + @content.inspect if @debug
|
115
|
-
|
132
|
+
|
116
133
|
r = @entries.find_by_title @title
|
117
134
|
puts 'r: ' + r.inspect if @debug
|
118
|
-
|
119
|
-
if r.nil? then
|
135
|
+
|
136
|
+
if r.nil? and @tags then
|
120
137
|
r = @entries.create title: @title, tags: @tags.join(' ')
|
121
138
|
end
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
139
|
+
|
140
|
+
|
141
|
+
filename = File.basename(@filepath.sub(/\.md$/,'.xml'))
|
142
|
+
xmlfile = File.join(@filepath, 'xml', filename)
|
143
|
+
|
144
|
+
write_xml(xmlfile, make_xml(@title, @content, @tags))
|
145
|
+
|
146
|
+
r.tags = @tags.join(' ') if r and r.tags != @tags
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
alias modify_build build_xml
|
151
|
+
|
130
152
|
def new_build(filename)
|
131
|
-
|
132
|
-
@title, @content, @tags = read_md(filename)
|
153
|
+
|
154
|
+
@title, @content, @tags = read_md(filename)
|
133
155
|
@entries.create title: @title, tags: @tags.join(' ')
|
134
156
|
|
135
157
|
puts 'md contents: ' + [@title, @content, @tags].inspect if @debug
|
136
|
-
write_xml(@title, build_xml(@title, @content, @tags))
|
137
|
-
|
158
|
+
write_xml(@title, build_xml(@title, @content, @tags))
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
# used by wikisys::controler#import_mw
|
163
|
+
#
|
164
|
+
def new_md(filepath, s)
|
165
|
+
|
166
|
+
write_file(filepath, md)
|
167
|
+
#build_xml(filepath)
|
168
|
+
|
169
|
+
#filename = File.basename(filepath.sub(/\.md$/,'.html'))
|
170
|
+
#html_file = File.join(@filepath, 'html', filename)
|
171
|
+
#write_html(html_file)
|
172
|
+
|
138
173
|
end
|
139
|
-
|
174
|
+
|
140
175
|
def read_file(file='index.html')
|
141
|
-
@hc.read(file) {
|
176
|
+
@hc.read(file) { FileX.read(file) }
|
142
177
|
end
|
143
|
-
|
178
|
+
|
144
179
|
def to_css()
|
145
180
|
fetch_file 'pg.css'
|
146
181
|
end
|
147
|
-
|
182
|
+
|
148
183
|
def write_html(filename)
|
149
184
|
|
150
|
-
|
151
|
-
|
185
|
+
FileX.mkdir_p File.join(@filepath, 'html')
|
186
|
+
|
152
187
|
xml = read_file File.join(@filepath, 'xml', filename)
|
153
188
|
puts 'about to fetch_file' if @debug
|
154
189
|
xsl = fetch_file 'pg.xsl'
|
155
190
|
puts 'xsl: ' + xsl.inspect if @debug
|
156
|
-
|
191
|
+
|
157
192
|
html_file = File.join(@filepath, 'html', filename.sub(/\.xml$/,'.html'))
|
158
193
|
write_file(html_file, transform(xsl, xml))
|
159
194
|
|
160
195
|
end
|
161
|
-
|
196
|
+
|
162
197
|
private
|
163
|
-
|
164
|
-
def read_md(
|
165
|
-
|
166
|
-
filepath = File.join(@filepath, 'md', filename)
|
167
|
-
puts 'filepath : ' + filepath.inspect if @debug
|
198
|
+
|
199
|
+
def read_md(filepath)
|
200
|
+
|
201
|
+
#filepath = File.join(@filepath, 'md', filename)
|
202
|
+
#puts 'filepath : ' + filepath.inspect if @debug
|
168
203
|
return unless File.exists? filepath
|
169
|
-
|
204
|
+
|
170
205
|
s = read_file(filepath).strip.gsub(/\r/,'')
|
171
206
|
puts 's: ' + s.inspect if @debug
|
172
|
-
|
207
|
+
|
173
208
|
# read the title
|
174
209
|
title = s.lines.first.chomp.sub(/^# +/,'')
|
175
|
-
|
210
|
+
|
176
211
|
# read the hashtags if there is any
|
177
212
|
tagsline = s.lines.last[/^ *\+ +(.*)/,1]
|
178
213
|
puts 'tagsline: ' + tagsline.inspect if @debug
|
179
|
-
|
214
|
+
|
180
215
|
if tagsline then
|
181
|
-
|
216
|
+
|
182
217
|
[title, s.lines[1..-2].join, tagsline.split]
|
183
|
-
|
218
|
+
|
184
219
|
else
|
185
|
-
|
220
|
+
|
186
221
|
[title, s.lines[1..-1].join, []]
|
187
|
-
|
222
|
+
|
188
223
|
end
|
189
|
-
|
190
|
-
end
|
191
|
-
|
192
|
-
def
|
193
|
-
|
224
|
+
|
225
|
+
end
|
226
|
+
|
227
|
+
def make_xml(title, content, rawtags)
|
228
|
+
|
229
|
+
return unless content
|
230
|
+
|
194
231
|
puts 'content: ' + content.inspect if @debug
|
195
232
|
s = content.gsub(/\[\[[^\]]+\]\]/) do |raw_link|
|
196
|
-
|
197
|
-
r = @entries.find_by_title title
|
198
|
-
|
233
|
+
|
234
|
+
r = @entries.find_by_title title
|
235
|
+
|
199
236
|
e = Rexle::Element.new('a').add_text title
|
200
237
|
e.attributes[:href] = title.gsub(/ +/, '_')
|
201
|
-
|
238
|
+
|
202
239
|
if r then
|
203
|
-
|
204
|
-
e.attributes[:title] = title.
|
205
|
-
|
240
|
+
|
241
|
+
e.attributes[:title] = title.capitalize2
|
242
|
+
|
206
243
|
else
|
207
|
-
|
208
|
-
make_page(title.
|
244
|
+
|
245
|
+
make_page(title.capitalize2)
|
209
246
|
e.attributes[:class] = 'new'
|
210
|
-
e.attributes[:title] = title.
|
211
|
-
|
247
|
+
e.attributes[:title] = title.capitalize2 + ' (page does not exist)'
|
248
|
+
|
212
249
|
end
|
213
|
-
|
250
|
+
|
214
251
|
e.xml
|
215
252
|
|
216
|
-
end
|
217
|
-
|
218
|
-
|
253
|
+
end
|
254
|
+
|
255
|
+
|
219
256
|
heading = "<heading>%s</heading>" % title
|
220
|
-
|
257
|
+
|
221
258
|
if rawtags.any? then
|
222
|
-
|
259
|
+
|
223
260
|
list = tags.map {|tag| " <tag>%s</tag>" % tag}
|
224
261
|
tags = "<tags>\n%s\n </tags>" % list.join("\n")
|
225
|
-
|
262
|
+
|
226
263
|
body = "<body>\n %s </body>" % \
|
227
264
|
Martile.new(s.lines[1..-2].join.strip).to_html
|
228
|
-
|
265
|
+
|
229
266
|
else
|
230
|
-
|
267
|
+
|
231
268
|
body = "<body>%s</body>" % Martile.new(s.lines[1..-1].join.strip).to_html
|
232
269
|
tags = ''
|
233
270
|
|
234
271
|
end
|
235
|
-
|
272
|
+
|
236
273
|
"<article id='%s'>\n %s\n %s\n %s\n</article>" % \
|
237
274
|
[title.gsub(/ +/,'-'), heading, body, tags]
|
238
|
-
|
239
|
-
|
275
|
+
|
276
|
+
|
240
277
|
end
|
241
|
-
|
242
|
-
|
278
|
+
|
279
|
+
|
243
280
|
def transform(xsl, xml)
|
244
281
|
|
245
282
|
doc = Nokogiri::XML(xml)
|
246
283
|
xslt = Nokogiri::XSLT(xsl)
|
247
284
|
|
248
|
-
xslt.transform(doc)
|
249
|
-
|
250
|
-
end
|
251
|
-
|
285
|
+
xslt.transform(doc)
|
286
|
+
|
287
|
+
end
|
288
|
+
|
252
289
|
def write_xml(s, content)
|
253
|
-
|
290
|
+
|
254
291
|
filename = s =~ /\.xml$/ ? s : s.gsub(/ +/,'_') + '.xml'
|
255
292
|
filepath = File.join(File.absolute_path(@filepath), 'xml', filename)
|
256
|
-
|
257
|
-
#
|
293
|
+
FileX.mkdir_p File.dirname(filepath)
|
294
|
+
#FileX.write filepath, content
|
258
295
|
write_file filepath, content
|
259
|
-
|
260
|
-
end
|
261
|
-
|
296
|
+
|
297
|
+
end
|
298
|
+
|
262
299
|
def write_file(filepath, content)
|
263
|
-
|
300
|
+
|
264
301
|
puts 'writing file: ' + filepath.inspect if @debug
|
265
|
-
|
266
|
-
@hc.write(filepath) { content }
|
302
|
+
FileX.write filepath, content
|
303
|
+
@hc.write(filepath) { content }
|
267
304
|
end
|
268
|
-
|
305
|
+
|
269
306
|
def make_page(title, raw_tags=title.downcase.gsub(/['\.\(\)]/,''))
|
270
|
-
|
307
|
+
|
271
308
|
tags = raw_tags.split.join(' ')
|
272
309
|
s = "#{title}\n\n\n+ " + tags
|
273
310
|
write_md title, s
|
274
311
|
write_xml title, build_xml(s)
|
275
|
-
|
276
|
-
@entries.create
|
277
|
-
|
312
|
+
|
313
|
+
@entries.create({title: title, tags: tags})
|
314
|
+
@title, @content, @tags = title, '', tags
|
315
|
+
|
278
316
|
return s
|
279
|
-
|
280
|
-
end
|
281
|
-
|
317
|
+
|
318
|
+
end
|
319
|
+
|
282
320
|
def read_md_file(filename)
|
283
|
-
|
321
|
+
|
284
322
|
filepath = File.join(@filepath, 'md', filename)
|
285
|
-
|
286
|
-
|
323
|
+
FileX.read(filepath)
|
324
|
+
|
287
325
|
end
|
288
|
-
|
326
|
+
|
327
|
+
# apparently this method was to be deleted, but it's still being
|
328
|
+
# used so will therefore remain for now
|
329
|
+
#
|
289
330
|
def write_md(title, content)
|
290
|
-
|
331
|
+
|
332
|
+
s = title
|
291
333
|
puts 'inside write_md' if @debug
|
292
334
|
filename = s =~ /\.md$/ ? s : s.gsub(/ +/,'_') + '.md'
|
293
335
|
filepath = File.join(File.absolute_path(@filepath), 'md', filename)
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
end
|
298
|
-
|
336
|
+
FileX.mkdir_p File.dirname(filepath)
|
337
|
+
FileX.write filepath, content
|
338
|
+
|
339
|
+
end
|
340
|
+
|
341
|
+
|
299
342
|
end
|
300
|
-
|
343
|
+
|
301
344
|
class Pages
|
302
|
-
|
345
|
+
|
303
346
|
attr_accessor :mw, :entries
|
304
347
|
|
305
348
|
def initialize(filepath='.', debug: false)
|
306
|
-
|
349
|
+
|
307
350
|
@filepath, @debug = filepath, debug
|
308
|
-
|
309
|
-
entries_file = File.join(@filepath, 'entries.
|
310
|
-
|
351
|
+
|
352
|
+
entries_file = File.join(@filepath, 'entries.xml')
|
353
|
+
|
311
354
|
if File.exists?(entries_file) then
|
312
355
|
@entries = DxLite.new(entries_file)
|
313
356
|
else
|
@@ -317,139 +360,233 @@ module Wikisys
|
|
317
360
|
|
318
361
|
# check for the mindwords raw document file
|
319
362
|
mindwords_file = File.join(@filepath, 'mindwords.txt')
|
320
|
-
|
321
|
-
if File.exists?(mindwords_file) then
|
363
|
+
|
364
|
+
if File.exists?(mindwords_file) then
|
322
365
|
@mw = MindWords.new(mindwords_file)
|
323
366
|
else
|
324
367
|
@mw = MindWords.new
|
325
368
|
@mw.filepath = mindwords_file
|
326
369
|
end
|
327
|
-
|
370
|
+
|
328
371
|
@pg = Wiki.new @filepath, entries: @entries, debug: @debug
|
329
|
-
|
372
|
+
|
330
373
|
#scan_md_files()
|
331
|
-
|
374
|
+
|
375
|
+
end
|
376
|
+
|
377
|
+
def import_mw(obj=File.join(@filepath, 'mindwords.txt'))
|
378
|
+
|
379
|
+
s, _ = RXFReader.read(obj)
|
380
|
+
|
381
|
+
@mw = MindWords.new(s)
|
382
|
+
FileX.write 'outline.txt', @mw.to_outline
|
383
|
+
|
384
|
+
FileX.mkdir_p 'md'
|
385
|
+
FileX.mkdir_p 'html'
|
386
|
+
|
387
|
+
@mw.to_words.each do |title, attributes|
|
388
|
+
|
389
|
+
breadcrumb, hashtags = attributes.values
|
390
|
+
|
391
|
+
s = "# %s\n\n\n" % title.capitalize2
|
392
|
+
s += '+ ' + hashtags if hashtags.strip.length > 0
|
393
|
+
|
394
|
+
file = File.join(@filepath, 'md', title.capitalize2.gsub(/ +/,'-') \
|
395
|
+
+ '.md')
|
396
|
+
|
397
|
+
if not File.exists?(file) then
|
398
|
+
|
399
|
+
@pg.new_md(file, s)
|
400
|
+
|
401
|
+
end
|
402
|
+
|
403
|
+
end
|
404
|
+
|
405
|
+
#gen_html_files()
|
406
|
+
gen_sidenav()
|
332
407
|
end
|
333
|
-
|
408
|
+
|
409
|
+
# creates a new page from an existing Markdown file
|
410
|
+
#
|
334
411
|
def new_pg(filename)
|
335
|
-
|
412
|
+
|
336
413
|
@pg.new_build(filename)
|
414
|
+
@entries.save
|
415
|
+
|
337
416
|
update_mw(@pg.title, @pg.tags)
|
338
|
-
|
417
|
+
@mw.save if @mw.lines.any?
|
418
|
+
|
419
|
+
build_html(filename)
|
420
|
+
|
339
421
|
end
|
340
|
-
|
422
|
+
|
423
|
+
# refreshes an existing page from an existing Markdown file
|
424
|
+
#
|
341
425
|
def update_pg(filename)
|
342
|
-
|
426
|
+
|
343
427
|
@pg.modify_build(filename)
|
428
|
+
@entries.save
|
429
|
+
|
344
430
|
update_mw(@pg.title, @pg.tags)
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
431
|
+
@mw.save if @mw.lines.any?
|
432
|
+
|
433
|
+
build_html(filename)
|
434
|
+
|
435
|
+
end
|
436
|
+
|
437
|
+
private
|
438
|
+
|
439
|
+
def build_html(filename)
|
440
|
+
|
441
|
+
xml_file = filename.sub(/\.md$/,'.xml')
|
442
|
+
filepath = File.join(@filepath, 'xml', xml_file)
|
443
|
+
s = @pg.read_file filepath
|
444
|
+
title = Rexle.new(s).root.text('heading')
|
445
|
+
puts 'about to search title: ' + title.inspect if @debug
|
446
|
+
found = @mw.search(title)
|
447
|
+
|
448
|
+
if found then
|
449
|
+
|
450
|
+
links = found.breadcrumb.map do |x|
|
451
|
+
[x, x.gsub(/ +/,'-') + '.html']
|
452
|
+
end
|
453
|
+
|
454
|
+
@pg.create_breadcrumb(filepath, links)
|
455
|
+
|
456
|
+
end
|
457
|
+
|
458
|
+
@pg.write_html xml_file
|
459
|
+
|
460
|
+
end
|
349
461
|
|
350
|
-
|
351
462
|
# Check if any of the md files have been modified or newly created
|
352
463
|
#
|
353
464
|
def scan_md_files()
|
354
|
-
|
465
|
+
|
355
466
|
filepath = File.join(@filepath, 'md')
|
356
467
|
puts 'about to scan ' + filepath.inspect if @debug
|
357
468
|
dir = DirToXML.new(filepath, index: 'dir.json', debug: @debug)
|
358
469
|
h = dir.activity
|
359
470
|
puts 'h: ' + h.inspect if @debug
|
360
|
-
|
471
|
+
|
361
472
|
return if (h[:new] + h[:modified]).empty?
|
362
|
-
|
473
|
+
|
363
474
|
h[:new].each {|filename| new_pg(filename) }
|
364
475
|
h[:modified].each {|filename| update_pg(filename) }
|
365
476
|
|
366
|
-
@mw.save if @mw.lines.any?
|
477
|
+
@mw.save if @mw.lines.any?
|
367
478
|
outline_filepath = File.join(@filepath, 'myoutline.txt')
|
368
|
-
|
369
|
-
|
370
|
-
|
479
|
+
|
480
|
+
FileX.write outline_filepath, @mw.to_outline
|
481
|
+
|
371
482
|
(h[:new] + h[:modified]).each do |filename|
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
s = pg.read_file filepath
|
376
|
-
title = Rexle.new(s).root.text('heading')
|
377
|
-
puts 'about to search title: ' + title.inspect if @debug
|
378
|
-
found = @mw.search(title)
|
379
|
-
|
380
|
-
if found then
|
381
|
-
|
382
|
-
links = found.breadcrumb.map do |x|
|
383
|
-
[x, x.gsub(/ +/,'-') + '.html']
|
384
|
-
end
|
385
|
-
|
386
|
-
pg.create_breadcrumb(filepath, links)
|
387
|
-
|
388
|
-
end
|
389
|
-
|
390
|
-
pg.write_html xml_file
|
391
|
-
|
483
|
+
|
484
|
+
build_html filename
|
485
|
+
|
392
486
|
end
|
393
|
-
|
487
|
+
|
394
488
|
@entries.save
|
395
489
|
|
396
|
-
|
397
|
-
end # /scan_md_files
|
398
|
-
|
490
|
+
|
491
|
+
end # /scan_md_files
|
492
|
+
|
399
493
|
def update_mw(title, line_tags)
|
400
|
-
|
494
|
+
|
401
495
|
# read the file
|
402
496
|
|
403
497
|
tags = line_tags.reject {|x| x =~ /#{title.strip}/i}
|
404
498
|
puts 'tags: ' + tags.inspect if @debug
|
405
499
|
puts 'title: ' + title.inspect if @debug
|
406
|
-
|
500
|
+
|
407
501
|
return if tags.empty?
|
408
|
-
|
502
|
+
|
409
503
|
line = title + ' ' + tags.map {|x| "#" + x }.join(' ') + "\n"
|
410
504
|
puts 'line: ' + line.inspect if @debug
|
411
|
-
|
505
|
+
|
412
506
|
# does the tagsline contain the topic hashtag?
|
413
|
-
|
507
|
+
|
414
508
|
#if tagsline =~ /#/ # not yet implemented
|
415
|
-
|
416
509
|
|
417
|
-
|
510
|
+
|
511
|
+
|
418
512
|
# check if the title already exists
|
419
513
|
found = @mw.lines.grep(/^#{title} +(?=#)/i)
|
420
|
-
|
514
|
+
|
421
515
|
if found.any? then
|
422
|
-
|
516
|
+
|
423
517
|
found_tags = found.first.scan(/(?<=#)\w+/)
|
424
|
-
|
518
|
+
|
425
519
|
if @debug then
|
426
|
-
|
520
|
+
|
427
521
|
puts 'tags: ' + tags.inspect
|
428
522
|
puts 'found_tags: ' + found_tags.inspect
|
429
|
-
|
523
|
+
|
430
524
|
end
|
431
525
|
|
432
|
-
new_tags = tags - found_tags
|
433
|
-
|
526
|
+
new_tags = tags - found_tags
|
527
|
+
|
434
528
|
# add the new tags to the mindwords line
|
435
|
-
|
529
|
+
|
436
530
|
hashtags = (found_tags + new_tags).map {|x| '#' + x }.join(' ')
|
437
531
|
|
438
532
|
i = @mw.lines.index(found.first)
|
439
533
|
@mw.lines[i] = line
|
440
|
-
|
534
|
+
|
441
535
|
else
|
442
|
-
|
536
|
+
|
443
537
|
@mw.lines << line
|
444
|
-
|
445
|
-
end
|
446
|
-
|
538
|
+
|
539
|
+
end
|
540
|
+
|
447
541
|
end
|
448
542
|
|
449
|
-
|
543
|
+
|
450
544
|
def view_file(file='index.html')
|
451
|
-
@hc.read(file) {
|
545
|
+
@hc.read(file) { FileX.read(file) }
|
546
|
+
end
|
547
|
+
|
548
|
+
end
|
549
|
+
|
550
|
+
class Controller
|
551
|
+
using StringCase
|
552
|
+
|
553
|
+
def initialize(filepath: '.')
|
554
|
+
@filepath = filepath
|
555
|
+
|
556
|
+
@pages = Pages.new filepath
|
557
|
+
|
452
558
|
end
|
453
559
|
|
560
|
+
def import_mw(obj)
|
561
|
+
|
562
|
+
s, _ = RXFReader.read(obj)
|
563
|
+
|
564
|
+
@mw = MindWords.new(s)
|
565
|
+
FileX.write 'outline.txt', @mw.to_outline
|
566
|
+
|
567
|
+
FileX.mkdir_p 'md'
|
568
|
+
FileX.mkdir_p 'html'
|
569
|
+
|
570
|
+
@mw.to_words.each do |title, attributes|
|
571
|
+
|
572
|
+
breadcrumb, hashtags = attributes.values
|
573
|
+
|
574
|
+
s = "# %s\n\n\n" % title.capitalize2
|
575
|
+
s += '+ ' + hashtags if hashtags.strip.length > 0
|
576
|
+
|
577
|
+
file = File.join(@filepath, 'md', title.capitalize2.gsub(/ +/,'-') \
|
578
|
+
+ '.md')
|
579
|
+
|
580
|
+
if not File.exists?(file) then
|
581
|
+
|
582
|
+
pg.new_md(file, s)
|
583
|
+
|
584
|
+
end
|
585
|
+
|
586
|
+
end
|
587
|
+
|
588
|
+
#gen_html_files()
|
589
|
+
gen_sidenav()
|
590
|
+
end
|
454
591
|
end
|
455
592
|
end
|
data.tar.gz.sig
CHANGED
Binary 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
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -11,31 +11,31 @@ cert_chain:
|
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMjIyMjEzMzQxWhcN
|
15
|
+
MjMwMjIyMjEzMzQxWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDRiQLq
|
17
|
+
puh4qyyeKj1si9k9FvQtqHvLBOQv4a6fpgXS3nP4UX+kRLzVo3A97Dn5gVT9N5IN
|
18
|
+
1GJsd3KbKmg40OadufO2S5dorxi8y0dgoQSDTSteuSBhL5k8//xkVNJORF2eS76l
|
19
|
+
JeygpkzyME3K0pyJyLr7DPYyn+L/DA53O7E7fOj41SyxsIcV2STdGgAhq2QWGCsG
|
20
|
+
AUXG/E1V+x0LcDHHsJN+pJar1P8wmPGfkO1+8TsiuM/bqdb+lfQYW6ZCap5gGD5G
|
21
|
+
ghbBkiT5fQTZhSQouMMX7aGBVLS4AH4WEuqNDlhn6KVrTzzav6sPWNJlcB6kVoGK
|
22
|
+
f/pxjrouI2aTEvq2FHHkxzPnExJcI9nwHSrwSnyV1EkE4+AzhXyebWFFEbS8aUTq
|
23
|
+
2eOvd+SXLVW0KHG7e+usEUKmh0bo7VuCswyYpK3cJyOjqL9f45PoA7uB3u1MLCFM
|
24
|
+
uJk+/tlv1B+JlwiD2onaYQ0vgdk/ASbly/uwVOqwSE+jUoN/tnVFbvKh/R8CAwEA
|
25
|
+
AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUJOXLMzXq
|
26
|
+
isNrleM8MNYcSpSSpI4wJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
27
27
|
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAUScfjIQE/XDR375JHpT7UkOwScGbHaur2yiiPUNp
|
29
|
+
/JGz17UZsvjDh0mzKXMrMFzMbc1UxH/fa7bftxdz4iuGgyPc5XYlhVQoDlxAtUH+
|
30
|
+
1lq8REPE8ZFYWrk+isfZ1l9wVqZbySdJRFpksZpCzUubWMN2L3ofqRPS2de56N/o
|
31
|
+
XDptO95tt4d3Wtx1PIK+t79oMyDukDjYDsADsqrga2ImELpWTBkOImDIphN4Rp0k
|
32
|
+
lDL/fySls4YVl/kl5lIA2zxp/hoOx5FP43b6aw/680YratTYNkDj8c6zXbpGDWLS
|
33
|
+
ibey6S+qwMAEDVNrfqNYWdYBUFMWKEmUKEWMecBL2+tFyaUku4e3kh4zccZfDfTc
|
34
|
+
fE/2EbG6iF6ibG9d5x7+I1gZ+L/3pbXp0vZ/mTKAZ72lB9PgbF1YsJX7Zi7fgJBr
|
35
|
+
tlrSOGB1I3nWz/uvurJuTFG0W9bre5ZoWbnTuk1D1hNCzr3H5M+rB1bKG+kmeFJi
|
36
|
+
hVN4NL4V8O7Nw12AplEAzA+r
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2022-05-09 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: dir-to-xml
|
@@ -43,60 +43,60 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '1.
|
46
|
+
version: '1.2'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.
|
49
|
+
version: 1.2.2
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '1.
|
56
|
+
version: '1.2'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 1.
|
59
|
+
version: 1.2.2
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: mindwords
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: '0.
|
66
|
+
version: '0.8'
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
69
|
+
version: 0.8.1
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '0.
|
76
|
+
version: '0.8'
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.
|
79
|
+
version: 0.8.1
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: martile
|
82
82
|
requirement: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
84
|
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: '1.
|
86
|
+
version: '1.6'
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.
|
89
|
+
version: 1.6.2
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
96
|
+
version: '1.6'
|
97
97
|
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
|
-
version: 1.
|
99
|
+
version: 1.6.2
|
100
100
|
- !ruby/object:Gem::Dependency
|
101
101
|
name: hashcache
|
102
102
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,7 +118,7 @@ dependencies:
|
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: 0.2.10
|
120
120
|
description:
|
121
|
-
email:
|
121
|
+
email: digital.robertson@gmail.com
|
122
122
|
executables: []
|
123
123
|
extensions: []
|
124
124
|
extra_rdoc_files: []
|
@@ -145,9 +145,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
|
-
|
149
|
-
rubygems_version: 2.7.10
|
148
|
+
rubygems_version: 3.2.22
|
150
149
|
signing_key:
|
151
150
|
specification_version: 4
|
152
|
-
summary: A poor man's wiki.
|
151
|
+
summary: A poor man's wiki (currently unmaintained).
|
153
152
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|