wikisys 0.3.1 → 0.4.4
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/lib/wikisys.rb +148 -44
- data/stylesheet/pg.css +75 -0
- data/stylesheet/pg.xsl +52 -0
- metadata +26 -4
- 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: ae7927009247eb0c4ba3820315c78e8a1f822ba201ccd20ed29fc909068a8f95
|
4
|
+
data.tar.gz: 5f153c0f68c9c1497fed420e6569d731932d8ea9666a8cd8b76d5324c65775d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10f1a4712a081beff1b802960a7930ca6f69be9363671ba2191ea1ac4e2098a6538cfd68f07ae1852d1b7f690febae6de9e2441376bdcb1b17a4bf34e97d2b49
|
7
|
+
data.tar.gz: c5c771e88170a318f3972e34314e14d91db806cfe951649bcd2e87db40c8656f18e309975c00025ebb610dea2722e5813efef13aacf3aaaa5d77d152ea2477dc
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/wikisys.rb
CHANGED
@@ -6,11 +6,46 @@ require 'dxlite'
|
|
6
6
|
require 'dir-to-xml'
|
7
7
|
require 'mindwords'
|
8
8
|
require 'martile'
|
9
|
+
require 'hashcache'
|
10
|
+
|
11
|
+
module FileFetch
|
12
|
+
|
13
|
+
def fetch_filepath(filename)
|
14
|
+
|
15
|
+
lib = File.dirname(__FILE__)
|
16
|
+
File.join(lib,'..','stylesheet',filename)
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def fetch_file(filename)
|
21
|
+
|
22
|
+
filepath = fetch_filepath filename
|
23
|
+
read filepath
|
24
|
+
end
|
25
|
+
|
26
|
+
def read(s)
|
27
|
+
RXFHelper.read(s).first
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module StringCase
|
32
|
+
|
33
|
+
refine String do
|
34
|
+
|
35
|
+
def capitalize2()
|
36
|
+
self.sub(/^[a-z]/) {|x| x.upcase }
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
9
42
|
|
10
43
|
module Wikisys
|
11
44
|
|
12
|
-
class Wiki
|
45
|
+
class Wiki
|
46
|
+
include FileFetch
|
13
47
|
using ColouredText
|
48
|
+
using StringCase
|
14
49
|
|
15
50
|
attr_accessor :title, :content, :tags
|
16
51
|
attr_reader :to_xml
|
@@ -49,8 +84,7 @@ module Wikisys
|
|
49
84
|
heading.insert_before menu.root
|
50
85
|
write_file filepath, doc.root.xml
|
51
86
|
|
52
|
-
end
|
53
|
-
|
87
|
+
end
|
54
88
|
|
55
89
|
def page(title)
|
56
90
|
|
@@ -83,16 +117,24 @@ module Wikisys
|
|
83
117
|
|
84
118
|
def modify_build(filename)
|
85
119
|
|
120
|
+
puts 'inside modify_buld' if @debug
|
121
|
+
|
86
122
|
@title, @content, @tags = read_md(filename)
|
87
123
|
|
88
124
|
# find the entry
|
89
125
|
# modify the tags if necessary
|
126
|
+
puts '@title: ' + @title.inspect if @debug
|
127
|
+
puts '_ @content: ' + @content.inspect if @debug
|
90
128
|
|
91
129
|
r = @entries.find_by_title @title
|
92
130
|
puts 'r: ' + r.inspect if @debug
|
93
|
-
return unless r
|
94
131
|
|
95
|
-
|
132
|
+
if r.nil? then
|
133
|
+
r = @entries.create title: @title, tags: @tags.join(' ')
|
134
|
+
end
|
135
|
+
|
136
|
+
xmlfile = filename.sub(/\.md$/,'.xml')
|
137
|
+
write_xml(xmlfile, build_xml(@title, @content, @tags))
|
96
138
|
|
97
139
|
r.tags = @tags.join(' ') if r.tags != @tags
|
98
140
|
|
@@ -112,20 +154,41 @@ module Wikisys
|
|
112
154
|
@hc.read(file) { File.read(file) }
|
113
155
|
end
|
114
156
|
|
157
|
+
def to_css()
|
158
|
+
fetch_file 'pg.css'
|
159
|
+
end
|
160
|
+
|
161
|
+
def write_html(filename)
|
162
|
+
|
163
|
+
FileUtils.mkdir_p File.join(@filepath, 'html')
|
164
|
+
|
165
|
+
xml = read_file File.join(@filepath, 'xml', filename)
|
166
|
+
puts 'about to fetch_file' if @debug
|
167
|
+
xsl = fetch_file 'pg.xsl'
|
168
|
+
puts 'xsl: ' + xsl.inspect if @debug
|
169
|
+
|
170
|
+
html_file = File.join(@filepath, 'html', filename.sub(/\.xml$/,'.html'))
|
171
|
+
write_file(html_file, transform(xsl, xml))
|
172
|
+
|
173
|
+
end
|
174
|
+
|
115
175
|
private
|
116
176
|
|
117
177
|
def read_md(filename)
|
118
178
|
|
119
179
|
filepath = File.join(@filepath, 'md', filename)
|
180
|
+
puts 'filepath : ' + filepath.inspect if @debug
|
120
181
|
return unless File.exists? filepath
|
121
182
|
|
122
|
-
s = read_file(filepath).strip
|
183
|
+
s = read_file(filepath).strip.gsub(/\r/,'')
|
184
|
+
puts 's: ' + s.inspect if @debug
|
123
185
|
|
124
186
|
# read the title
|
125
187
|
title = s.lines.first.chomp.sub(/^# +/,'')
|
126
188
|
|
127
189
|
# read the hashtags if there is any
|
128
190
|
tagsline = s.lines.last[/^ *\+ +(.*)/,1]
|
191
|
+
puts 'tagsline: ' + tagsline.inspect if @debug
|
129
192
|
|
130
193
|
if tagsline then
|
131
194
|
|
@@ -133,13 +196,13 @@ module Wikisys
|
|
133
196
|
|
134
197
|
else
|
135
198
|
|
136
|
-
[title, s.lines[1
|
199
|
+
[title, s.lines[1..-1].join, []]
|
137
200
|
|
138
201
|
end
|
139
202
|
|
140
203
|
end
|
141
204
|
|
142
|
-
def build_xml(title, content,
|
205
|
+
def build_xml(title, content, rawtags)
|
143
206
|
|
144
207
|
puts 'content: ' + content.inspect if @debug
|
145
208
|
s = content.gsub(/\[\[[^\]]+\]\]/) do |raw_link|
|
@@ -151,13 +214,13 @@ module Wikisys
|
|
151
214
|
|
152
215
|
if r then
|
153
216
|
|
154
|
-
e.attributes[:title] = title.
|
217
|
+
e.attributes[:title] = title.capitalize2
|
155
218
|
|
156
219
|
else
|
157
220
|
|
158
|
-
make_page(title.
|
221
|
+
make_page(title.capitalize2)
|
159
222
|
e.attributes[:class] = 'new'
|
160
|
-
e.attributes[:title] = title.
|
223
|
+
e.attributes[:title] = title.capitalize2 + ' (page does not exist)'
|
161
224
|
|
162
225
|
end
|
163
226
|
|
@@ -168,7 +231,7 @@ module Wikisys
|
|
168
231
|
|
169
232
|
heading = "<heading>%s</heading>" % title
|
170
233
|
|
171
|
-
if
|
234
|
+
if rawtags.any? then
|
172
235
|
|
173
236
|
list = tags.map {|tag| " <tag>%s</tag>" % tag}
|
174
237
|
tags = "<tags>\n%s\n </tags>" % list.join("\n")
|
@@ -179,18 +242,30 @@ module Wikisys
|
|
179
242
|
else
|
180
243
|
|
181
244
|
body = "<body>%s</body>" % Martile.new(s.lines[1..-1].join.strip).to_html
|
245
|
+
tags = ''
|
182
246
|
|
183
247
|
end
|
184
248
|
|
185
|
-
"<article>\n %s\n %s\n %s\n</article>" %
|
249
|
+
"<article id='%s'>\n %s\n %s\n %s\n</article>" % \
|
250
|
+
[title.gsub(/ +/,'-'), heading, body, tags]
|
186
251
|
|
187
252
|
|
188
253
|
end
|
189
254
|
|
190
|
-
|
255
|
+
|
256
|
+
def transform(xsl, xml)
|
257
|
+
|
258
|
+
doc = Nokogiri::XML(xml)
|
259
|
+
xslt = Nokogiri::XSLT(xsl)
|
260
|
+
|
261
|
+
xslt.transform(doc)
|
191
262
|
|
192
|
-
|
193
|
-
|
263
|
+
end
|
264
|
+
|
265
|
+
def write_xml(s, content)
|
266
|
+
|
267
|
+
filename = s =~ /\.xml$/ ? s : s.gsub(/ +/,'_') + '.xml'
|
268
|
+
filepath = File.join(File.absolute_path(@filepath), 'xml', filename)
|
194
269
|
FileUtils.mkdir_p File.dirname(filepath)
|
195
270
|
#File.write filepath, content
|
196
271
|
write_file filepath, content
|
@@ -226,8 +301,9 @@ module Wikisys
|
|
226
301
|
|
227
302
|
def write_md(title, content)
|
228
303
|
|
229
|
-
|
230
|
-
|
304
|
+
puts 'inside write_md' if @debug
|
305
|
+
filename = s =~ /\.md$/ ? s : s.gsub(/ +/,'_') + '.md'
|
306
|
+
filepath = File.join(File.absolute_path(@filepath), 'md', filename)
|
231
307
|
FileUtils.mkdir_p File.dirname(filepath)
|
232
308
|
File.write filepath, content
|
233
309
|
|
@@ -262,12 +338,60 @@ module Wikisys
|
|
262
338
|
@mw.filepath = mindwords_file
|
263
339
|
end
|
264
340
|
|
265
|
-
|
341
|
+
@pg = Wiki.new @filepath, entries: @entries, debug: @debug
|
342
|
+
|
343
|
+
#scan_md_files()
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
def new_pg(filename)
|
348
|
+
|
349
|
+
@pg.new_build(filename)
|
350
|
+
@entries.save
|
351
|
+
|
352
|
+
update_mw(@pg.title, @pg.tags)
|
353
|
+
@mw.save if @mw.lines.any?
|
354
|
+
|
355
|
+
build_html(filename)
|
266
356
|
|
267
357
|
end
|
268
358
|
|
359
|
+
def update_pg(filename)
|
360
|
+
|
361
|
+
@pg.modify_build(filename)
|
362
|
+
@entries.save
|
363
|
+
|
364
|
+
update_mw(@pg.title, @pg.tags)
|
365
|
+
@mw.save if @mw.lines.any?
|
366
|
+
|
367
|
+
build_html(filename)
|
368
|
+
|
369
|
+
end
|
370
|
+
|
269
371
|
private
|
270
372
|
|
373
|
+
def build_html(filename)
|
374
|
+
|
375
|
+
xml_file = filename.sub(/\.md$/,'.xml')
|
376
|
+
filepath = File.join(@filepath, 'xml', xml_file)
|
377
|
+
s = @pg.read_file filepath
|
378
|
+
title = Rexle.new(s).root.text('heading')
|
379
|
+
puts 'about to search title: ' + title.inspect if @debug
|
380
|
+
found = @mw.search(title)
|
381
|
+
|
382
|
+
if found then
|
383
|
+
|
384
|
+
links = found.breadcrumb.map do |x|
|
385
|
+
[x, x.gsub(/ +/,'-') + '.html']
|
386
|
+
end
|
387
|
+
|
388
|
+
@pg.create_breadcrumb(filepath, links)
|
389
|
+
|
390
|
+
end
|
391
|
+
|
392
|
+
@pg.write_html xml_file
|
393
|
+
|
394
|
+
end
|
271
395
|
|
272
396
|
# Check if any of the md files have been modified or newly created
|
273
397
|
#
|
@@ -279,22 +403,10 @@ module Wikisys
|
|
279
403
|
h = dir.activity
|
280
404
|
puts 'h: ' + h.inspect if @debug
|
281
405
|
|
282
|
-
|
283
|
-
|
406
|
+
return if (h[:new] + h[:modified]).empty?
|
284
407
|
|
285
|
-
h[:new].each
|
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
|
408
|
+
h[:new].each {|filename| new_pg(filename) }
|
409
|
+
h[:modified].each {|filename| update_pg(filename) }
|
298
410
|
|
299
411
|
@mw.save if @mw.lines.any?
|
300
412
|
outline_filepath = File.join(@filepath, 'myoutline.txt')
|
@@ -303,16 +415,7 @@ module Wikisys
|
|
303
415
|
|
304
416
|
(h[:new] + h[:modified]).each do |filename|
|
305
417
|
|
306
|
-
|
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)
|
418
|
+
build_html filename
|
316
419
|
|
317
420
|
end
|
318
421
|
|
@@ -370,6 +473,7 @@ module Wikisys
|
|
370
473
|
end
|
371
474
|
|
372
475
|
end
|
476
|
+
|
373
477
|
|
374
478
|
def view_file(file='index.html')
|
375
479
|
@hc.read(file) { File.read(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; }
|
data/stylesheet/pg.xsl
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
|
2
|
+
|
3
|
+
<xsl:template match='article'>
|
4
|
+
|
5
|
+
<html>
|
6
|
+
<head>
|
7
|
+
<link rel="stylesheet" type="text/css" href=pg.css"/>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<xsl:variable name='id' select='@id'/>
|
11
|
+
<header><div><a href='../edit?id={$id}'>edit</a></div></header>
|
12
|
+
<div>
|
13
|
+
<xsl:copy-of select='ul[@class="breadcrumb"]' />
|
14
|
+
</div>
|
15
|
+
<article>
|
16
|
+
<xsl:apply-templates select='heading' />
|
17
|
+
<xsl:copy-of select='body/*' />
|
18
|
+
</article>
|
19
|
+
<xsl:apply-templates select='tags' />
|
20
|
+
</body>
|
21
|
+
</html>
|
22
|
+
|
23
|
+
</xsl:template>
|
24
|
+
|
25
|
+
<xsl:template match='heading'>
|
26
|
+
|
27
|
+
<h1><xsl:value-of select='.' /></h1>
|
28
|
+
|
29
|
+
</xsl:template>
|
30
|
+
|
31
|
+
<xsl:template match='tags'>
|
32
|
+
|
33
|
+
<ul id='tags'>
|
34
|
+
<xsl:apply-templates select='tag' />
|
35
|
+
</ul>
|
36
|
+
|
37
|
+
</xsl:template>
|
38
|
+
|
39
|
+
<xsl:template match='tag'>
|
40
|
+
|
41
|
+
<li>
|
42
|
+
<xsl:element name='a'>
|
43
|
+
<xsl:attribute name='href'>
|
44
|
+
../hashtags.html#<xsl:value-of select='.' />
|
45
|
+
</xsl:attribute>
|
46
|
+
<xsl:value-of select='.' />
|
47
|
+
</xsl:element>
|
48
|
+
</li>
|
49
|
+
|
50
|
+
</xsl:template>
|
51
|
+
|
52
|
+
</xsl:stylesheet>
|
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.4
|
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
|
38
|
+
date: 2021-02-01 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: dir-to-xml
|
@@ -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,6 +97,26 @@ 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: []
|
@@ -104,6 +124,8 @@ extensions: []
|
|
104
124
|
extra_rdoc_files: []
|
105
125
|
files:
|
106
126
|
- lib/wikisys.rb
|
127
|
+
- stylesheet/pg.css
|
128
|
+
- stylesheet/pg.xsl
|
107
129
|
homepage: https://github.com/jrobertson/wikisys
|
108
130
|
licenses:
|
109
131
|
- MIT
|
metadata.gz.sig
CHANGED
Binary file
|