wikisys 0.4.2 → 0.5.0
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
- checksums.yaml.gz.sig +0 -0
- data/lib/wikisys.rb +359 -212
- data.tar.gz.sig +0 -0
- metadata +34 -35
- 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: f85de4628d4264c982a5e1274a431dcc4d83141f02fc00a16a2beae66fb75135
|
|
4
|
+
data.tar.gz: e0716628f734f05b4ff9cb345399b43f8c04d71120e3a0ed779d737b9fc1fd4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6413d79961cd120efdda28ba31d7646cd7604232f7258a063edc7bf624e1c4ea6ad20fa41a91165b241c9bdd1e440e4d2b36b386cc1e95b9e7977cfe260194de
|
|
7
|
+
data.tar.gz: 86c00d890331085832453527e6ffe3d6a4d4a53633cce73990ff368dc411b4483e508e1ac3f6c0c3cb3ac92b699826e1a4502d38d2042bea7c6208710247e9c3
|
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 RXFReadWrite
|
|
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,243 +74,277 @@ 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
|
+
|
|
124
|
+
puts 'inside modify_buld' if @debug
|
|
125
|
+
|
|
107
126
|
@title, @content, @tags = read_md(filename)
|
|
108
|
-
|
|
127
|
+
|
|
109
128
|
# find the entry
|
|
110
129
|
# modify the tags if necessary
|
|
111
|
-
|
|
130
|
+
puts '@title: ' + @title.inspect if @debug
|
|
131
|
+
puts '_ @content: ' + @content.inspect if @debug
|
|
132
|
+
|
|
112
133
|
r = @entries.find_by_title @title
|
|
113
134
|
puts 'r: ' + r.inspect if @debug
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
135
|
+
|
|
136
|
+
if r.nil? then
|
|
137
|
+
r = @entries.create title: @title, tags: @tags.join(' ')
|
|
138
|
+
end
|
|
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
|
+
|
|
118
146
|
r.tags = @tags.join(' ') if r.tags != @tags
|
|
119
|
-
|
|
120
|
-
end
|
|
121
|
-
|
|
147
|
+
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
alias modify_build build_xml
|
|
151
|
+
|
|
122
152
|
def new_build(filename)
|
|
123
|
-
|
|
124
|
-
@title, @content, @tags = read_md(filename)
|
|
153
|
+
|
|
154
|
+
@title, @content, @tags = read_md(filename)
|
|
125
155
|
@entries.create title: @title, tags: @tags.join(' ')
|
|
126
156
|
|
|
127
157
|
puts 'md contents: ' + [@title, @content, @tags].inspect if @debug
|
|
128
|
-
write_xml(@title, build_xml(@title, @content, @tags))
|
|
129
|
-
|
|
158
|
+
write_xml(@title, build_xml(@title, @content, @tags))
|
|
159
|
+
|
|
130
160
|
end
|
|
131
|
-
|
|
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
|
+
|
|
173
|
+
end
|
|
174
|
+
|
|
132
175
|
def read_file(file='index.html')
|
|
133
|
-
@hc.read(file) {
|
|
176
|
+
@hc.read(file) { FileX.read(file) }
|
|
134
177
|
end
|
|
135
|
-
|
|
178
|
+
|
|
136
179
|
def to_css()
|
|
137
180
|
fetch_file 'pg.css'
|
|
138
181
|
end
|
|
139
|
-
|
|
182
|
+
|
|
140
183
|
def write_html(filename)
|
|
141
184
|
|
|
142
|
-
|
|
143
|
-
|
|
185
|
+
FileX.mkdir_p File.join(@filepath, 'html')
|
|
186
|
+
|
|
144
187
|
xml = read_file File.join(@filepath, 'xml', filename)
|
|
145
188
|
puts 'about to fetch_file' if @debug
|
|
146
189
|
xsl = fetch_file 'pg.xsl'
|
|
147
190
|
puts 'xsl: ' + xsl.inspect if @debug
|
|
148
|
-
|
|
191
|
+
|
|
149
192
|
html_file = File.join(@filepath, 'html', filename.sub(/\.xml$/,'.html'))
|
|
150
193
|
write_file(html_file, transform(xsl, xml))
|
|
151
194
|
|
|
152
195
|
end
|
|
153
|
-
|
|
196
|
+
|
|
154
197
|
private
|
|
155
|
-
|
|
156
|
-
def read_md(
|
|
157
|
-
|
|
158
|
-
filepath = File.join(@filepath, 'md', filename)
|
|
198
|
+
|
|
199
|
+
def read_md(filepath)
|
|
200
|
+
|
|
201
|
+
#filepath = File.join(@filepath, 'md', filename)
|
|
202
|
+
#puts 'filepath : ' + filepath.inspect if @debug
|
|
159
203
|
return unless File.exists? filepath
|
|
160
|
-
|
|
161
|
-
s = read_file(filepath).strip
|
|
162
|
-
|
|
204
|
+
|
|
205
|
+
s = read_file(filepath).strip.gsub(/\r/,'')
|
|
206
|
+
puts 's: ' + s.inspect if @debug
|
|
207
|
+
|
|
163
208
|
# read the title
|
|
164
209
|
title = s.lines.first.chomp.sub(/^# +/,'')
|
|
165
|
-
|
|
210
|
+
|
|
166
211
|
# read the hashtags if there is any
|
|
167
212
|
tagsline = s.lines.last[/^ *\+ +(.*)/,1]
|
|
168
|
-
|
|
213
|
+
puts 'tagsline: ' + tagsline.inspect if @debug
|
|
214
|
+
|
|
169
215
|
if tagsline then
|
|
170
|
-
|
|
216
|
+
|
|
171
217
|
[title, s.lines[1..-2].join, tagsline.split]
|
|
172
|
-
|
|
218
|
+
|
|
173
219
|
else
|
|
174
|
-
|
|
175
|
-
[title, s.lines[1
|
|
176
|
-
|
|
220
|
+
|
|
221
|
+
[title, s.lines[1..-1].join, []]
|
|
222
|
+
|
|
177
223
|
end
|
|
178
|
-
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
def
|
|
182
|
-
|
|
224
|
+
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def make_xml(title, content, rawtags)
|
|
228
|
+
|
|
183
229
|
puts 'content: ' + content.inspect if @debug
|
|
184
230
|
s = content.gsub(/\[\[[^\]]+\]\]/) do |raw_link|
|
|
185
|
-
|
|
186
|
-
r = @entries.find_by_title title
|
|
187
|
-
|
|
231
|
+
|
|
232
|
+
r = @entries.find_by_title title
|
|
233
|
+
|
|
188
234
|
e = Rexle::Element.new('a').add_text title
|
|
189
235
|
e.attributes[:href] = title.gsub(/ +/, '_')
|
|
190
|
-
|
|
236
|
+
|
|
191
237
|
if r then
|
|
192
|
-
|
|
193
|
-
e.attributes[:title] = title.
|
|
194
|
-
|
|
238
|
+
|
|
239
|
+
e.attributes[:title] = title.capitalize2
|
|
240
|
+
|
|
195
241
|
else
|
|
196
|
-
|
|
197
|
-
make_page(title.
|
|
242
|
+
|
|
243
|
+
make_page(title.capitalize2)
|
|
198
244
|
e.attributes[:class] = 'new'
|
|
199
|
-
e.attributes[:title] = title.
|
|
200
|
-
|
|
245
|
+
e.attributes[:title] = title.capitalize2 + ' (page does not exist)'
|
|
246
|
+
|
|
201
247
|
end
|
|
202
|
-
|
|
248
|
+
|
|
203
249
|
e.xml
|
|
204
250
|
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
|
|
208
254
|
heading = "<heading>%s</heading>" % title
|
|
209
|
-
|
|
210
|
-
if
|
|
211
|
-
|
|
255
|
+
|
|
256
|
+
if rawtags.any? then
|
|
257
|
+
|
|
212
258
|
list = tags.map {|tag| " <tag>%s</tag>" % tag}
|
|
213
259
|
tags = "<tags>\n%s\n </tags>" % list.join("\n")
|
|
214
|
-
|
|
260
|
+
|
|
215
261
|
body = "<body>\n %s </body>" % \
|
|
216
262
|
Martile.new(s.lines[1..-2].join.strip).to_html
|
|
217
|
-
|
|
263
|
+
|
|
218
264
|
else
|
|
219
|
-
|
|
265
|
+
|
|
220
266
|
body = "<body>%s</body>" % Martile.new(s.lines[1..-1].join.strip).to_html
|
|
267
|
+
tags = ''
|
|
221
268
|
|
|
222
269
|
end
|
|
223
|
-
|
|
270
|
+
|
|
224
271
|
"<article id='%s'>\n %s\n %s\n %s\n</article>" % \
|
|
225
|
-
[title.
|
|
226
|
-
|
|
227
|
-
|
|
272
|
+
[title.gsub(/ +/,'-'), heading, body, tags]
|
|
273
|
+
|
|
274
|
+
|
|
228
275
|
end
|
|
229
|
-
|
|
230
|
-
|
|
276
|
+
|
|
277
|
+
|
|
231
278
|
def transform(xsl, xml)
|
|
232
279
|
|
|
233
280
|
doc = Nokogiri::XML(xml)
|
|
234
281
|
xslt = Nokogiri::XSLT(xsl)
|
|
235
282
|
|
|
236
|
-
xslt.transform(doc)
|
|
237
|
-
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
def write_xml(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
#
|
|
283
|
+
xslt.transform(doc)
|
|
284
|
+
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def write_xml(s, content)
|
|
288
|
+
|
|
289
|
+
filename = s =~ /\.xml$/ ? s : s.gsub(/ +/,'_') + '.xml'
|
|
290
|
+
filepath = File.join(File.absolute_path(@filepath), 'xml', filename)
|
|
291
|
+
FileX.mkdir_p File.dirname(filepath)
|
|
292
|
+
#FileX.write filepath, content
|
|
246
293
|
write_file filepath, content
|
|
247
|
-
|
|
248
|
-
end
|
|
249
|
-
|
|
294
|
+
|
|
295
|
+
end
|
|
296
|
+
|
|
250
297
|
def write_file(filepath, content)
|
|
251
|
-
|
|
298
|
+
|
|
252
299
|
puts 'writing file: ' + filepath.inspect if @debug
|
|
253
|
-
|
|
254
|
-
@hc.write(filepath) { content }
|
|
300
|
+
FileX.write filepath, content
|
|
301
|
+
@hc.write(filepath) { content }
|
|
255
302
|
end
|
|
256
|
-
|
|
303
|
+
|
|
257
304
|
def make_page(title, raw_tags=title.downcase.gsub(/['\.\(\)]/,''))
|
|
258
|
-
|
|
305
|
+
|
|
259
306
|
tags = raw_tags.split.join(' ')
|
|
260
307
|
s = "#{title}\n\n\n+ " + tags
|
|
261
308
|
write_md title, s
|
|
262
309
|
write_xml title, build_xml(s)
|
|
263
|
-
|
|
264
|
-
@entries.create title: title, tags: tags
|
|
265
|
-
|
|
310
|
+
|
|
311
|
+
@entries.create title: title, tags: tags
|
|
312
|
+
@title, @content, @tags = title, '', tags
|
|
313
|
+
|
|
266
314
|
return s
|
|
267
|
-
|
|
268
|
-
end
|
|
269
|
-
|
|
315
|
+
|
|
316
|
+
end
|
|
317
|
+
|
|
270
318
|
def read_md_file(filename)
|
|
271
|
-
|
|
319
|
+
|
|
272
320
|
filepath = File.join(@filepath, 'md', filename)
|
|
273
|
-
|
|
274
|
-
|
|
321
|
+
FileX.read(filepath)
|
|
322
|
+
|
|
275
323
|
end
|
|
276
|
-
|
|
277
|
-
def
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
File.
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
324
|
+
|
|
325
|
+
def write_md_to_be_deleted(title, content)
|
|
326
|
+
|
|
327
|
+
puts 'inside write_md' if @debug
|
|
328
|
+
filename = s =~ /\.md$/ ? s : s.gsub(/ +/,'_') + '.md'
|
|
329
|
+
filepath = File.join(File.absolute_path(@filepath), 'md', filename)
|
|
330
|
+
FileX.mkdir_p File.dirname(filepath)
|
|
331
|
+
FileX.write filepath, content
|
|
332
|
+
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
|
|
286
336
|
end
|
|
287
|
-
|
|
337
|
+
|
|
288
338
|
class Pages
|
|
289
|
-
|
|
339
|
+
|
|
290
340
|
attr_accessor :mw, :entries
|
|
291
341
|
|
|
292
342
|
def initialize(filepath='.', debug: false)
|
|
293
|
-
|
|
343
|
+
|
|
294
344
|
@filepath, @debug = filepath, debug
|
|
295
|
-
|
|
296
|
-
entries_file = File.join(@filepath, 'entries.
|
|
297
|
-
|
|
345
|
+
|
|
346
|
+
entries_file = File.join(@filepath, 'entries.xml')
|
|
347
|
+
|
|
298
348
|
if File.exists?(entries_file) then
|
|
299
349
|
@entries = DxLite.new(entries_file)
|
|
300
350
|
else
|
|
@@ -304,136 +354,233 @@ module Wikisys
|
|
|
304
354
|
|
|
305
355
|
# check for the mindwords raw document file
|
|
306
356
|
mindwords_file = File.join(@filepath, 'mindwords.txt')
|
|
307
|
-
|
|
308
|
-
if File.exists?(mindwords_file) then
|
|
357
|
+
|
|
358
|
+
if File.exists?(mindwords_file) then
|
|
309
359
|
@mw = MindWords.new(mindwords_file)
|
|
310
360
|
else
|
|
311
361
|
@mw = MindWords.new
|
|
312
362
|
@mw.filepath = mindwords_file
|
|
313
363
|
end
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
364
|
+
|
|
365
|
+
@pg = Wiki.new @filepath, entries: @entries, debug: @debug
|
|
366
|
+
|
|
367
|
+
#scan_md_files()
|
|
368
|
+
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
def import_mw(obj=File.join(@filepath, 'mindwords.txt'))
|
|
372
|
+
|
|
373
|
+
s, _ = RXFReader.read(obj)
|
|
374
|
+
|
|
375
|
+
@mw = MindWords.new(s)
|
|
376
|
+
FileX.write 'outline.txt', @mw.to_outline
|
|
377
|
+
|
|
378
|
+
FileX.mkdir_p 'md'
|
|
379
|
+
FileX.mkdir_p 'html'
|
|
380
|
+
|
|
381
|
+
@mw.to_words.each do |title, attributes|
|
|
382
|
+
|
|
383
|
+
breadcrumb, hashtags = attributes.values
|
|
384
|
+
|
|
385
|
+
s = "# %s\n\n\n" % title.capitalize2
|
|
386
|
+
s += '+ ' + hashtags if hashtags.strip.length > 0
|
|
387
|
+
|
|
388
|
+
file = File.join(@filepath, 'md', title.capitalize2.gsub(/ +/,'-') \
|
|
389
|
+
+ '.md')
|
|
390
|
+
|
|
391
|
+
if not File.exists?(file) then
|
|
392
|
+
|
|
393
|
+
@pg.new_md(file, s)
|
|
394
|
+
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
#gen_html_files()
|
|
400
|
+
gen_sidenav()
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
# creates a new page from an existing Markdown file
|
|
404
|
+
#
|
|
405
|
+
def new_pg(filename)
|
|
406
|
+
|
|
407
|
+
@pg.new_build(filename)
|
|
408
|
+
@entries.save
|
|
409
|
+
|
|
410
|
+
update_mw(@pg.title, @pg.tags)
|
|
411
|
+
@mw.save if @mw.lines.any?
|
|
412
|
+
|
|
413
|
+
build_html(filename)
|
|
414
|
+
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
# refreshes an existing page from an existing Markdown file
|
|
418
|
+
#
|
|
419
|
+
def update_pg(filename)
|
|
420
|
+
|
|
421
|
+
@pg.modify_build(filename)
|
|
422
|
+
@entries.save
|
|
423
|
+
|
|
424
|
+
update_mw(@pg.title, @pg.tags)
|
|
425
|
+
@mw.save if @mw.lines.any?
|
|
426
|
+
|
|
427
|
+
build_html(filename)
|
|
428
|
+
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
private
|
|
432
|
+
|
|
433
|
+
def build_html(filename)
|
|
434
|
+
|
|
435
|
+
xml_file = filename.sub(/\.md$/,'.xml')
|
|
436
|
+
filepath = File.join(@filepath, 'xml', xml_file)
|
|
437
|
+
s = @pg.read_file filepath
|
|
438
|
+
title = Rexle.new(s).root.text('heading')
|
|
439
|
+
puts 'about to search title: ' + title.inspect if @debug
|
|
440
|
+
found = @mw.search(title)
|
|
441
|
+
|
|
442
|
+
if found then
|
|
443
|
+
|
|
444
|
+
links = found.breadcrumb.map do |x|
|
|
445
|
+
[x, x.gsub(/ +/,'-') + '.html']
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
@pg.create_breadcrumb(filepath, links)
|
|
449
|
+
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
@pg.write_html xml_file
|
|
453
|
+
|
|
317
454
|
end
|
|
318
|
-
|
|
319
|
-
private
|
|
320
455
|
|
|
321
|
-
|
|
322
456
|
# Check if any of the md files have been modified or newly created
|
|
323
457
|
#
|
|
324
458
|
def scan_md_files()
|
|
325
|
-
|
|
459
|
+
|
|
326
460
|
filepath = File.join(@filepath, 'md')
|
|
327
461
|
puts 'about to scan ' + filepath.inspect if @debug
|
|
328
462
|
dir = DirToXML.new(filepath, index: 'dir.json', debug: @debug)
|
|
329
463
|
h = dir.activity
|
|
330
464
|
puts 'h: ' + h.inspect if @debug
|
|
331
|
-
|
|
465
|
+
|
|
332
466
|
return if (h[:new] + h[:modified]).empty?
|
|
333
|
-
|
|
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
|
|
350
467
|
|
|
351
|
-
|
|
468
|
+
h[:new].each {|filename| new_pg(filename) }
|
|
469
|
+
h[:modified].each {|filename| update_pg(filename) }
|
|
470
|
+
|
|
471
|
+
@mw.save if @mw.lines.any?
|
|
352
472
|
outline_filepath = File.join(@filepath, 'myoutline.txt')
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
473
|
+
|
|
474
|
+
FileX.write outline_filepath, @mw.to_outline
|
|
475
|
+
|
|
356
476
|
(h[:new] + h[:modified]).each do |filename|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
s = pg.read_file filepath
|
|
361
|
-
title = Rexle.new(s).root.text('heading')
|
|
362
|
-
puts 'about to search title: ' + title.inspect if @debug
|
|
363
|
-
found = @mw.search(title)
|
|
364
|
-
|
|
365
|
-
if found then
|
|
366
|
-
|
|
367
|
-
links = found.breadcrumb.map do |x|
|
|
368
|
-
[x, x.downcase.gsub(/ +/,'-') + '.html']
|
|
369
|
-
end
|
|
370
|
-
|
|
371
|
-
pg.create_breadcrumb(filepath, links)
|
|
372
|
-
|
|
373
|
-
end
|
|
374
|
-
|
|
375
|
-
pg.write_html xml_file
|
|
376
|
-
|
|
477
|
+
|
|
478
|
+
build_html filename
|
|
479
|
+
|
|
377
480
|
end
|
|
378
|
-
|
|
481
|
+
|
|
379
482
|
@entries.save
|
|
380
483
|
|
|
381
|
-
|
|
382
|
-
end # /scan_md_files
|
|
383
|
-
|
|
484
|
+
|
|
485
|
+
end # /scan_md_files
|
|
486
|
+
|
|
384
487
|
def update_mw(title, line_tags)
|
|
385
|
-
|
|
488
|
+
|
|
386
489
|
# read the file
|
|
387
490
|
|
|
388
491
|
tags = line_tags.reject {|x| x =~ /#{title.strip}/i}
|
|
389
492
|
puts 'tags: ' + tags.inspect if @debug
|
|
390
493
|
puts 'title: ' + title.inspect if @debug
|
|
391
|
-
|
|
494
|
+
|
|
392
495
|
return if tags.empty?
|
|
393
|
-
|
|
496
|
+
|
|
394
497
|
line = title + ' ' + tags.map {|x| "#" + x }.join(' ') + "\n"
|
|
395
498
|
puts 'line: ' + line.inspect if @debug
|
|
396
|
-
|
|
499
|
+
|
|
397
500
|
# does the tagsline contain the topic hashtag?
|
|
398
|
-
|
|
501
|
+
|
|
399
502
|
#if tagsline =~ /#/ # not yet implemented
|
|
400
|
-
|
|
401
503
|
|
|
402
|
-
|
|
504
|
+
|
|
505
|
+
|
|
403
506
|
# check if the title already exists
|
|
404
507
|
found = @mw.lines.grep(/^#{title} +(?=#)/i)
|
|
405
|
-
|
|
508
|
+
|
|
406
509
|
if found.any? then
|
|
407
|
-
|
|
510
|
+
|
|
408
511
|
found_tags = found.first.scan(/(?<=#)\w+/)
|
|
409
|
-
|
|
512
|
+
|
|
410
513
|
if @debug then
|
|
411
|
-
|
|
514
|
+
|
|
412
515
|
puts 'tags: ' + tags.inspect
|
|
413
516
|
puts 'found_tags: ' + found_tags.inspect
|
|
414
|
-
|
|
517
|
+
|
|
415
518
|
end
|
|
416
519
|
|
|
417
|
-
new_tags = tags - found_tags
|
|
418
|
-
|
|
520
|
+
new_tags = tags - found_tags
|
|
521
|
+
|
|
419
522
|
# add the new tags to the mindwords line
|
|
420
|
-
|
|
523
|
+
|
|
421
524
|
hashtags = (found_tags + new_tags).map {|x| '#' + x }.join(' ')
|
|
422
525
|
|
|
423
526
|
i = @mw.lines.index(found.first)
|
|
424
527
|
@mw.lines[i] = line
|
|
425
|
-
|
|
528
|
+
|
|
426
529
|
else
|
|
427
|
-
|
|
530
|
+
|
|
428
531
|
@mw.lines << line
|
|
429
|
-
|
|
430
|
-
end
|
|
431
|
-
|
|
532
|
+
|
|
533
|
+
end
|
|
534
|
+
|
|
432
535
|
end
|
|
433
|
-
|
|
536
|
+
|
|
537
|
+
|
|
434
538
|
def view_file(file='index.html')
|
|
435
|
-
@hc.read(file) {
|
|
539
|
+
@hc.read(file) { FileX.read(file) }
|
|
540
|
+
end
|
|
541
|
+
|
|
542
|
+
end
|
|
543
|
+
|
|
544
|
+
class Controller
|
|
545
|
+
using StringCase
|
|
546
|
+
|
|
547
|
+
def initialize(filepath: '.')
|
|
548
|
+
@filepath = filepath
|
|
549
|
+
|
|
550
|
+
@pages = Pages.new filepath
|
|
551
|
+
|
|
436
552
|
end
|
|
437
553
|
|
|
554
|
+
def import_mw(obj)
|
|
555
|
+
|
|
556
|
+
s, _ = RXFReader.read(obj)
|
|
557
|
+
|
|
558
|
+
@mw = MindWords.new(s)
|
|
559
|
+
FileX.write 'outline.txt', @mw.to_outline
|
|
560
|
+
|
|
561
|
+
FileX.mkdir_p 'md'
|
|
562
|
+
FileX.mkdir_p 'html'
|
|
563
|
+
|
|
564
|
+
@mw.to_words.each do |title, attributes|
|
|
565
|
+
|
|
566
|
+
breadcrumb, hashtags = attributes.values
|
|
567
|
+
|
|
568
|
+
s = "# %s\n\n\n" % title.capitalize2
|
|
569
|
+
s += '+ ' + hashtags if hashtags.strip.length > 0
|
|
570
|
+
|
|
571
|
+
file = File.join(@filepath, 'md', title.capitalize2.gsub(/ +/,'-') \
|
|
572
|
+
+ '.md')
|
|
573
|
+
|
|
574
|
+
if not File.exists?(file) then
|
|
575
|
+
|
|
576
|
+
pg.new_md(file, s)
|
|
577
|
+
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
#gen_html_files()
|
|
583
|
+
gen_sidenav()
|
|
584
|
+
end
|
|
438
585
|
end
|
|
439
586
|
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.0
|
|
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-02-22 00:00:00.000000000 Z
|
|
39
39
|
dependencies:
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: dir-to-xml
|
|
@@ -43,20 +43,20 @@ 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.1
|
|
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.1
|
|
60
60
|
- !ruby/object:Gem::Dependency
|
|
61
61
|
name: mindwords
|
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -83,20 +83,20 @@ dependencies:
|
|
|
83
83
|
requirements:
|
|
84
84
|
- - "~>"
|
|
85
85
|
- !ruby/object:Gem::Version
|
|
86
|
-
version: '1.
|
|
86
|
+
version: '1.5'
|
|
87
87
|
- - ">="
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 1.
|
|
89
|
+
version: 1.5.0
|
|
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.5'
|
|
97
97
|
- - ">="
|
|
98
98
|
- !ruby/object:Gem::Version
|
|
99
|
-
version: 1.
|
|
99
|
+
version: 1.5.0
|
|
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,8 +145,7 @@ 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
151
|
summary: A poor man's wiki.
|
metadata.gz.sig
CHANGED
|
Binary file
|