wikisys 0.3.1 → 0.4.0
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.tar.gz.sig +0 -0
- data/stylesheet/pg.css +75 -0
- metadata +24 -4
- metadata.gz.sig +0 -0
- data/lib/wikisys.rb +0 -379
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58d2c1e764d883278d6cc59cc30701bec9e60e54f40f5d74a2c2ca9de24aaaa3
|
4
|
+
data.tar.gz: 3ce2675464a445aaaa1ae9e5061b34fab9d36556c8d7a37ae06d8cd5a03c9d4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e67d2e605bfb300d986730021834943b5467b3de637cbcc0257602bb9c1939227add73b3d57de71d13cb6b1e2153bc59e2046c6623fc4f3b421583b71e0292ed
|
7
|
+
data.tar.gz: c0d03e1ae012d972ae452a0b8252b444df51c7f3d1d7c55375db126673c4821a96f244090ec4e2c0990c64f063fd9a68546b4c5dedacaba8c7f490ca08c45680
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/stylesheet/pg.css
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
/* begin breadcrumb.css */
|
4
|
+
|
5
|
+
body {font-family: Arial;}
|
6
|
+
|
7
|
+
/* Style the list */
|
8
|
+
ul.breadcrumb {
|
9
|
+
padding: 10px 16px;
|
10
|
+
list-style: none;
|
11
|
+
background-color: #eee;
|
12
|
+
}
|
13
|
+
|
14
|
+
/* Display list items side by side */
|
15
|
+
ul.breadcrumb li {
|
16
|
+
display: inline;
|
17
|
+
font-size: 18px;
|
18
|
+
}
|
19
|
+
|
20
|
+
/* Add a slash symbol (/) before/behind each list item */
|
21
|
+
ul.breadcrumb li+li:before {
|
22
|
+
padding: 8px;
|
23
|
+
color: black;
|
24
|
+
content: "/\00a0";
|
25
|
+
}
|
26
|
+
|
27
|
+
/* Add a color to all links inside the list */
|
28
|
+
ul.breadcrumb li a {
|
29
|
+
color: #0275d8;
|
30
|
+
text-decoration: none;
|
31
|
+
}
|
32
|
+
|
33
|
+
/* Add a color on mouse-over */
|
34
|
+
ul.breadcrumb li a:hover {
|
35
|
+
color: #01447e;
|
36
|
+
text-decoration: underline;
|
37
|
+
}
|
38
|
+
|
39
|
+
/* end breadcrumb */
|
40
|
+
|
41
|
+
article {
|
42
|
+
background-color: rgba(255,255,255,0.5);
|
43
|
+
padding: 1.1em;
|
44
|
+
margin: 0.4em;
|
45
|
+
}
|
46
|
+
|
47
|
+
header div {text-align: right}
|
48
|
+
#tags {
|
49
|
+
background-color: transparent;
|
50
|
+
padding: 2.5em 1.0em;
|
51
|
+
margin: 1.0em 0em;
|
52
|
+
list-style-type: none
|
53
|
+
}
|
54
|
+
#tags li {
|
55
|
+
background-color: transparent;
|
56
|
+
display: inline;
|
57
|
+
padding: 0.1em;
|
58
|
+
margin: 1.3em 0.1em;
|
59
|
+
color: #fff;
|
60
|
+
}
|
61
|
+
|
62
|
+
#tags li a {
|
63
|
+
background-color: #eee;
|
64
|
+
color: #a95;
|
65
|
+
text-decoration: none;
|
66
|
+
font-family: "Courier";
|
67
|
+
font-weight: 600;
|
68
|
+
font-size: 0.9em;
|
69
|
+
padding: 0.4em 0.6em;
|
70
|
+
margin: 0.3em;
|
71
|
+
|
72
|
+
}
|
73
|
+
|
74
|
+
#tags li:hover {background-color: transparent; }
|
75
|
+
#tags li a:hover { background-color: #ededed; color: #66e; }
|
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.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
version: '0.5'
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.5.
|
69
|
+
version: 0.5.4
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0.5'
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.5.
|
79
|
+
version: 0.5.4
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: martile
|
82
82
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,13 +97,33 @@ dependencies:
|
|
97
97
|
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: 1.4.6
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: hashcache
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - "~>"
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0.2'
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.2.10
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0.2'
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: 0.2.10
|
100
120
|
description:
|
101
121
|
email: james@jamesrobertson.eu
|
102
122
|
executables: []
|
103
123
|
extensions: []
|
104
124
|
extra_rdoc_files: []
|
105
125
|
files:
|
106
|
-
-
|
126
|
+
- stylesheet/pg.css
|
107
127
|
homepage: https://github.com/jrobertson/wikisys
|
108
128
|
licenses:
|
109
129
|
- MIT
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/wikisys.rb
DELETED
@@ -1,379 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# file: wikisys.rb
|
4
|
-
|
5
|
-
require 'dxlite'
|
6
|
-
require 'dir-to-xml'
|
7
|
-
require 'mindwords'
|
8
|
-
require 'martile'
|
9
|
-
|
10
|
-
module Wikisys
|
11
|
-
|
12
|
-
class Wiki
|
13
|
-
using ColouredText
|
14
|
-
|
15
|
-
attr_accessor :title, :content, :tags
|
16
|
-
attr_reader :to_xml
|
17
|
-
|
18
|
-
def initialize(filepath='.', entries: 'entries.json', debug: false)
|
19
|
-
|
20
|
-
@filepath = filepath
|
21
|
-
@page = ''
|
22
|
-
@debug = debug
|
23
|
-
|
24
|
-
@hc = HashCache.new(size:30)
|
25
|
-
|
26
|
-
@entries = if entries.is_a? DxLite then
|
27
|
-
|
28
|
-
entries
|
29
|
-
|
30
|
-
elsif File.exists?(entries) then
|
31
|
-
|
32
|
-
DxLite.new(entries)
|
33
|
-
|
34
|
-
else
|
35
|
-
|
36
|
-
DxLite.new('entries/entry(title, tags)')
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
def create_breadcrumb(filepath, links)
|
43
|
-
|
44
|
-
doc = Rexle.new(read_file(filepath))
|
45
|
-
heading = doc.root.element('heading')
|
46
|
-
|
47
|
-
menu = Rexle.new(HtmlCom::Menu.new(:breadcrumb, links).to_html)
|
48
|
-
|
49
|
-
heading.insert_before menu.root
|
50
|
-
write_file filepath, doc.root.xml
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
def page(title)
|
56
|
-
|
57
|
-
r = @entries.find_by_title title
|
58
|
-
@page = r ? read_md(title) : make_page(title)
|
59
|
-
@to_xml = build_xml @page
|
60
|
-
@entries.save
|
61
|
-
|
62
|
-
return @page
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
def page=(raw_content)
|
67
|
-
|
68
|
-
title = raw_content.lines.first.chomp
|
69
|
-
|
70
|
-
r = @entries.find_by_title title
|
71
|
-
make_page(title, raw_content.lines.last.chomp[/(?<=\+ )/]) unless r
|
72
|
-
|
73
|
-
write_md title, raw_content
|
74
|
-
title, content, tags = read_md()
|
75
|
-
@to_xml = build_xml title, content, tags
|
76
|
-
write_xml title, @to_xml
|
77
|
-
|
78
|
-
|
79
|
-
@entries.save
|
80
|
-
@page = raw_content
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
def modify_build(filename)
|
85
|
-
|
86
|
-
@title, @content, @tags = read_md(filename)
|
87
|
-
|
88
|
-
# find the entry
|
89
|
-
# modify the tags if necessary
|
90
|
-
|
91
|
-
r = @entries.find_by_title @title
|
92
|
-
puts 'r: ' + r.inspect if @debug
|
93
|
-
return unless r
|
94
|
-
|
95
|
-
write_xml(@title, build_xml(@title, @content, @tags))
|
96
|
-
|
97
|
-
r.tags = @tags.join(' ') if r.tags != @tags
|
98
|
-
|
99
|
-
end
|
100
|
-
|
101
|
-
def new_build(filename)
|
102
|
-
|
103
|
-
@title, @content, @tags = read_md(filename)
|
104
|
-
@entries.create title: @title, tags: @tags.join(' ')
|
105
|
-
|
106
|
-
puts 'md contents: ' + [@title, @content, @tags].inspect if @debug
|
107
|
-
write_xml(@title, build_xml(@title, @content, @tags))
|
108
|
-
|
109
|
-
end
|
110
|
-
|
111
|
-
def read_file(file='index.html')
|
112
|
-
@hc.read(file) { File.read(file) }
|
113
|
-
end
|
114
|
-
|
115
|
-
private
|
116
|
-
|
117
|
-
def read_md(filename)
|
118
|
-
|
119
|
-
filepath = File.join(@filepath, 'md', filename)
|
120
|
-
return unless File.exists? filepath
|
121
|
-
|
122
|
-
s = read_file(filepath).strip
|
123
|
-
|
124
|
-
# read the title
|
125
|
-
title = s.lines.first.chomp.sub(/^# +/,'')
|
126
|
-
|
127
|
-
# read the hashtags if there is any
|
128
|
-
tagsline = s.lines.last[/^ *\+ +(.*)/,1]
|
129
|
-
|
130
|
-
if tagsline then
|
131
|
-
|
132
|
-
[title, s.lines[1..-2].join, tagsline.split]
|
133
|
-
|
134
|
-
else
|
135
|
-
|
136
|
-
[title, s.lines[1..--1].join, []]
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
def build_xml(title, content, tags)
|
143
|
-
|
144
|
-
puts 'content: ' + content.inspect if @debug
|
145
|
-
s = content.gsub(/\[\[[^\]]+\]\]/) do |raw_link|
|
146
|
-
|
147
|
-
r = @entries.find_by_title title
|
148
|
-
|
149
|
-
e = Rexle::Element.new('a').add_text title
|
150
|
-
e.attributes[:href] = title.gsub(/ +/, '_')
|
151
|
-
|
152
|
-
if r then
|
153
|
-
|
154
|
-
e.attributes[:title] = title.capitalize
|
155
|
-
|
156
|
-
else
|
157
|
-
|
158
|
-
make_page(title.capitalize)
|
159
|
-
e.attributes[:class] = 'new'
|
160
|
-
e.attributes[:title] = title.capitalize + ' (page does not exist)'
|
161
|
-
|
162
|
-
end
|
163
|
-
|
164
|
-
e.xml
|
165
|
-
|
166
|
-
end
|
167
|
-
|
168
|
-
|
169
|
-
heading = "<heading>%s</heading>" % title
|
170
|
-
|
171
|
-
if tags.any? then
|
172
|
-
|
173
|
-
list = tags.map {|tag| " <tag>%s</tag>" % tag}
|
174
|
-
tags = "<tags>\n%s\n </tags>" % list.join("\n")
|
175
|
-
|
176
|
-
body = "<body>\n %s </body>" % \
|
177
|
-
Martile.new(s.lines[1..-2].join.strip).to_html
|
178
|
-
|
179
|
-
else
|
180
|
-
|
181
|
-
body = "<body>%s</body>" % Martile.new(s.lines[1..-1].join.strip).to_html
|
182
|
-
|
183
|
-
end
|
184
|
-
|
185
|
-
"<article>\n %s\n %s\n %s\n</article>" % [heading, body, tags]
|
186
|
-
|
187
|
-
|
188
|
-
end
|
189
|
-
|
190
|
-
def write_xml(title, content)
|
191
|
-
|
192
|
-
filepath = File.join(File.absolute_path(@filepath), 'xml',
|
193
|
-
title.downcase.gsub(/ +/,'_') + '.xml')
|
194
|
-
FileUtils.mkdir_p File.dirname(filepath)
|
195
|
-
#File.write filepath, content
|
196
|
-
write_file filepath, content
|
197
|
-
|
198
|
-
end
|
199
|
-
|
200
|
-
def write_file(filepath, content)
|
201
|
-
|
202
|
-
puts 'writing file: ' + filepath.inspect if @debug
|
203
|
-
File.write filepath, content
|
204
|
-
@hc.write(filepath) { content }
|
205
|
-
end
|
206
|
-
|
207
|
-
def make_page(title, raw_tags=title.downcase.gsub(/['\.\(\)]/,''))
|
208
|
-
|
209
|
-
tags = raw_tags.split.join(' ')
|
210
|
-
s = "#{title}\n\n\n+ " + tags
|
211
|
-
write_md title, s
|
212
|
-
write_xml title, build_xml(s)
|
213
|
-
|
214
|
-
@entries.create title: title, tags: tags
|
215
|
-
|
216
|
-
return s
|
217
|
-
|
218
|
-
end
|
219
|
-
|
220
|
-
def read_md_file(filename)
|
221
|
-
|
222
|
-
filepath = File.join(@filepath, 'md', filename)
|
223
|
-
File.read(filepath)
|
224
|
-
|
225
|
-
end
|
226
|
-
|
227
|
-
def write_md(title, content)
|
228
|
-
|
229
|
-
filepath = File.join(File.absolute_path(@filepath), 'md',
|
230
|
-
title.gsub(/ +/,'_') + '.md')
|
231
|
-
FileUtils.mkdir_p File.dirname(filepath)
|
232
|
-
File.write filepath, content
|
233
|
-
|
234
|
-
end
|
235
|
-
|
236
|
-
end
|
237
|
-
|
238
|
-
class Pages
|
239
|
-
|
240
|
-
attr_accessor :mw, :entries
|
241
|
-
|
242
|
-
def initialize(filepath='.', debug: false)
|
243
|
-
|
244
|
-
@filepath, @debug = filepath, debug
|
245
|
-
|
246
|
-
entries_file = File.join(@filepath, 'entries.txt')
|
247
|
-
|
248
|
-
if File.exists?(entries_file) then
|
249
|
-
@entries = DxLite.new(entries_file)
|
250
|
-
else
|
251
|
-
@entries = DxLite.new('entries/entry(title, tags)')
|
252
|
-
@entries.save entries_file
|
253
|
-
end
|
254
|
-
|
255
|
-
# check for the mindwords raw document file
|
256
|
-
mindwords_file = File.join(@filepath, 'mindwords.txt')
|
257
|
-
|
258
|
-
if File.exists?(mindwords_file) then
|
259
|
-
@mw = MindWords.new(mindwords_file)
|
260
|
-
else
|
261
|
-
@mw = MindWords.new
|
262
|
-
@mw.filepath = mindwords_file
|
263
|
-
end
|
264
|
-
|
265
|
-
scan_md_files()
|
266
|
-
|
267
|
-
end
|
268
|
-
|
269
|
-
private
|
270
|
-
|
271
|
-
|
272
|
-
# Check if any of the md files have been modified or newly created
|
273
|
-
#
|
274
|
-
def scan_md_files()
|
275
|
-
|
276
|
-
filepath = File.join(@filepath, 'md')
|
277
|
-
puts 'about to scan ' + filepath.inspect if @debug
|
278
|
-
dir = DirToXML.new(filepath, index: 'dir.json', debug: @debug)
|
279
|
-
h = dir.activity
|
280
|
-
puts 'h: ' + h.inspect if @debug
|
281
|
-
|
282
|
-
pg = Wiki.new @filepath, entries: @entries
|
283
|
-
|
284
|
-
|
285
|
-
h[:new].each do |filename|
|
286
|
-
|
287
|
-
pg.new_build(filename)
|
288
|
-
update_mw(pg.title, pg.tags)
|
289
|
-
|
290
|
-
end
|
291
|
-
|
292
|
-
h[:modified].each do |filename|
|
293
|
-
|
294
|
-
pg.modify_build(filename)
|
295
|
-
update_mw(pg.title, pg.tags)
|
296
|
-
|
297
|
-
end
|
298
|
-
|
299
|
-
@mw.save if @mw.lines.any?
|
300
|
-
outline_filepath = File.join(@filepath, 'myoutline.txt')
|
301
|
-
|
302
|
-
File.write outline_filepath, @mw.to_outline
|
303
|
-
|
304
|
-
(h[:new] + h[:modified]).each do |filename|
|
305
|
-
|
306
|
-
filepath = File.join(@filepath, 'xml',filename.sub(/\.md$/,'.xml'))
|
307
|
-
s = pg.read_file filepath
|
308
|
-
title = Rexle.new(s).root.text('heading')
|
309
|
-
puts 'about to search title: ' + title.inspect if @debug
|
310
|
-
found = @mw.search(title)
|
311
|
-
|
312
|
-
next unless found
|
313
|
-
|
314
|
-
links = found.breadcrumb.map {|x| [x, x.downcase.gsub(/ +/,'-') + '.html']}
|
315
|
-
pg.create_breadcrumb(filepath, links)
|
316
|
-
|
317
|
-
end
|
318
|
-
|
319
|
-
@entries.save
|
320
|
-
|
321
|
-
|
322
|
-
end # /scan_md_files
|
323
|
-
|
324
|
-
def update_mw(title, line_tags)
|
325
|
-
|
326
|
-
# read the file
|
327
|
-
|
328
|
-
tags = line_tags.reject {|x| x =~ /#{title.strip}/i}
|
329
|
-
puts 'tags: ' + tags.inspect if @debug
|
330
|
-
puts 'title: ' + title.inspect if @debug
|
331
|
-
|
332
|
-
return if tags.empty?
|
333
|
-
|
334
|
-
line = title + ' ' + tags.map {|x| "#" + x }.join(' ') + "\n"
|
335
|
-
puts 'line: ' + line.inspect if @debug
|
336
|
-
|
337
|
-
# does the tagsline contain the topic hashtag?
|
338
|
-
|
339
|
-
#if tagsline =~ /#/ # not yet implemented
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
# check if the title already exists
|
344
|
-
found = @mw.lines.grep(/^#{title} +(?=#)/i)
|
345
|
-
|
346
|
-
if found.any? then
|
347
|
-
|
348
|
-
found_tags = found.first.scan(/(?<=#)\w+/)
|
349
|
-
|
350
|
-
if @debug then
|
351
|
-
|
352
|
-
puts 'tags: ' + tags.inspect
|
353
|
-
puts 'found_tags: ' + found_tags.inspect
|
354
|
-
|
355
|
-
end
|
356
|
-
|
357
|
-
new_tags = tags - found_tags
|
358
|
-
|
359
|
-
# add the new tags to the mindwords line
|
360
|
-
|
361
|
-
hashtags = (found_tags + new_tags).map {|x| '#' + x }.join(' ')
|
362
|
-
|
363
|
-
i = @mw.lines.index(found.first)
|
364
|
-
@mw.lines[i] = line
|
365
|
-
|
366
|
-
else
|
367
|
-
|
368
|
-
@mw.lines << line
|
369
|
-
|
370
|
-
end
|
371
|
-
|
372
|
-
end
|
373
|
-
|
374
|
-
def view_file(file='index.html')
|
375
|
-
@hc.read(file) { File.read(file) }
|
376
|
-
end
|
377
|
-
|
378
|
-
end
|
379
|
-
end
|