wiki-server 0.21.1 → 0.21.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.
- package/.github/workflows/node.js.yml +31 -0
- package/lib/search.coffee +23 -39
- package/lib/server.coffee +4 -6
- package/package.json +3 -3
- package/.travis.yml +0 -12
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
|
|
3
|
+
|
|
4
|
+
name: Node.js CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ "master" ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ "master" ]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
strategy:
|
|
18
|
+
matrix:
|
|
19
|
+
node-version: [14.x, 16.x, 18.x]
|
|
20
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v3
|
|
24
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
25
|
+
uses: actions/setup-node@v3
|
|
26
|
+
with:
|
|
27
|
+
node-version: ${{ matrix.node-version }}
|
|
28
|
+
cache: 'npm'
|
|
29
|
+
- run: npm ci
|
|
30
|
+
- run: npm run build --if-present
|
|
31
|
+
- run: npm test
|
package/lib/search.coffee
CHANGED
|
@@ -44,53 +44,37 @@ module.exports = exports = (argv) ->
|
|
|
44
44
|
fs.close fd, (err) ->
|
|
45
45
|
cb(err)
|
|
46
46
|
|
|
47
|
-
searchPageUpdate = (slug, page,
|
|
47
|
+
searchPageUpdate = (slug, page, cb) ->
|
|
48
48
|
# to update we have to remove the page first, and then readd it
|
|
49
49
|
timeLabel = "SITE INDEX update #{slug} - #{wikiName}"
|
|
50
50
|
console.time timeLabel
|
|
51
|
+
|
|
51
52
|
try
|
|
52
|
-
|
|
53
|
+
pageText = page.story.reduce( extractPageText, '')
|
|
53
54
|
catch err
|
|
54
|
-
console.log "SITE INDEX *** #{wikiName} reduce to extract the
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
siteIndex.
|
|
55
|
+
console.log "SITE INDEX *** #{wikiName} reduce to extract the text on #{slug} failed", err.message
|
|
56
|
+
pageText = ""
|
|
57
|
+
if siteIndex.has slug
|
|
58
|
+
siteIndex.replace {
|
|
58
59
|
'id': slug
|
|
59
60
|
'title': page.title
|
|
60
|
-
'content':
|
|
61
|
+
'content': pageText
|
|
62
|
+
}
|
|
63
|
+
else
|
|
64
|
+
siteIndex.add {
|
|
65
|
+
'id': slug
|
|
66
|
+
'title': page.title
|
|
67
|
+
'content': pageText
|
|
61
68
|
}
|
|
62
|
-
catch err
|
|
63
|
-
# swallow error, if the page was not in index
|
|
64
|
-
console.log "SITE INDEX *** removing #{slug} from index failed", err unless err.message.includes('not in the index')
|
|
65
|
-
|
|
66
|
-
try
|
|
67
|
-
newText = page.story.reduce( extractPageText, '')
|
|
68
|
-
catch err
|
|
69
|
-
console.log "SITE INDEX *** #{wikiName} reduce to extract the new text on #{slug} failed", err.message
|
|
70
|
-
newText = ""
|
|
71
|
-
siteIndex.add {
|
|
72
|
-
'id': slug
|
|
73
|
-
'title': page.title
|
|
74
|
-
'content': newText
|
|
75
|
-
}
|
|
76
69
|
console.timeEnd timeLabel
|
|
77
70
|
cb()
|
|
78
71
|
|
|
79
|
-
searchPageRemove = (slug,
|
|
72
|
+
searchPageRemove = (slug, cb) ->
|
|
80
73
|
# remove page from index
|
|
81
74
|
timeLabel = "SITE INDEX page remove #{slug} - #{wikiName}"
|
|
82
75
|
console.time timeLabel
|
|
83
76
|
try
|
|
84
|
-
|
|
85
|
-
catch err
|
|
86
|
-
console.log "SITE INDEX *** #{wikiName} reduce to extract the text for removing #{slug} failed", err.message
|
|
87
|
-
origText = ""
|
|
88
|
-
try
|
|
89
|
-
siteIndex.remove {
|
|
90
|
-
'id': slug
|
|
91
|
-
'title': title
|
|
92
|
-
'content': origText
|
|
93
|
-
}
|
|
77
|
+
siteIndex.discard slug
|
|
94
78
|
catch err
|
|
95
79
|
# swallow error, if the page was not in index
|
|
96
80
|
console.log "removing #{slug} from index #{wikiName} failed", err unless err.message.includes('not in the index')
|
|
@@ -140,14 +124,14 @@ module.exports = exports = (argv) ->
|
|
|
140
124
|
switch item.action
|
|
141
125
|
when "update"
|
|
142
126
|
itself.start()
|
|
143
|
-
searchPageUpdate(item.slug, item.page,
|
|
127
|
+
searchPageUpdate(item.slug, item.page, (e) ->
|
|
144
128
|
process.nextTick( ->
|
|
145
129
|
serial(queue.shift())
|
|
146
130
|
)
|
|
147
131
|
)
|
|
148
132
|
when "remove"
|
|
149
133
|
itself.start()
|
|
150
|
-
searchPageRemove(item.slug,
|
|
134
|
+
searchPageRemove(item.slug, (e) ->
|
|
151
135
|
process.nextTick( ->
|
|
152
136
|
serial(queue.shift())
|
|
153
137
|
)
|
|
@@ -172,7 +156,7 @@ module.exports = exports = (argv) ->
|
|
|
172
156
|
# really need to extract text from the markdown, but for now just remove link brackets, urls...
|
|
173
157
|
pageText += ' ' + currentItem.text.replace /\[{2}|\[(?:[\S]+)|\]{1,2}|\\n/g, ' '
|
|
174
158
|
when 'html'
|
|
175
|
-
pageText += ' ' + currentItem.text.replace /<[
|
|
159
|
+
pageText += ' ' + currentItem.text.replace /<[^\>]*>?/g, ''
|
|
176
160
|
else
|
|
177
161
|
if currentItem.text?
|
|
178
162
|
for line in currentItem.text.split /\r\n?|\n/
|
|
@@ -247,9 +231,9 @@ module.exports = exports = (argv) ->
|
|
|
247
231
|
process.nextTick ( ->
|
|
248
232
|
serial(queue.shift()))
|
|
249
233
|
|
|
250
|
-
itself.removePage = (slug
|
|
234
|
+
itself.removePage = (slug) ->
|
|
251
235
|
action = "remove"
|
|
252
|
-
queue.push({action, slug
|
|
236
|
+
queue.push({action, slug })
|
|
253
237
|
if Array.isArray(siteIndex) and !working
|
|
254
238
|
itself.start()
|
|
255
239
|
searchRestore (e) ->
|
|
@@ -258,9 +242,9 @@ module.exports = exports = (argv) ->
|
|
|
258
242
|
else
|
|
259
243
|
serial(queue.shift()) unless working
|
|
260
244
|
|
|
261
|
-
itself.update = (slug, page
|
|
245
|
+
itself.update = (slug, page) ->
|
|
262
246
|
action = "update"
|
|
263
|
-
queue.push({action, slug, page
|
|
247
|
+
queue.push({action, slug, page})
|
|
264
248
|
if Array.isArray(siteIndex) and !working
|
|
265
249
|
itself.start()
|
|
266
250
|
searchRestore( (e) ->
|
package/lib/server.coffee
CHANGED
|
@@ -610,12 +610,11 @@ module.exports = exports = (argv) ->
|
|
|
610
610
|
actionCB = (e, page, status) ->
|
|
611
611
|
#if e then return res.e e
|
|
612
612
|
if status is 404
|
|
613
|
-
res.status(status).send(page)
|
|
613
|
+
# res.status(status).send(page)
|
|
614
|
+
return res.e page,status
|
|
614
615
|
# Using Coffee-Scripts implicit returns we assign page.story to the
|
|
615
616
|
# result of a list comprehension by way of a switch expression.
|
|
616
617
|
try
|
|
617
|
-
# save the original page, so we can remove it from the index.
|
|
618
|
-
origStory = Object.assign([], page.story) or []
|
|
619
618
|
page.story = switch action.type
|
|
620
619
|
when 'move'
|
|
621
620
|
action.order.map (id) ->
|
|
@@ -667,7 +666,7 @@ module.exports = exports = (argv) ->
|
|
|
667
666
|
sitemaphandler.update(req.params[0], page)
|
|
668
667
|
|
|
669
668
|
# update site index
|
|
670
|
-
searchhandler.update(req.params[0], page
|
|
669
|
+
searchhandler.update(req.params[0], page)
|
|
671
670
|
|
|
672
671
|
# log action
|
|
673
672
|
|
|
@@ -721,7 +720,6 @@ module.exports = exports = (argv) ->
|
|
|
721
720
|
# we need the original page text to remove it from the index, so get the original text before deleting it
|
|
722
721
|
pagehandler.get pageFile, (e, page, status) ->
|
|
723
722
|
title = page.title
|
|
724
|
-
origStory = Object.assign([], page.story) or []
|
|
725
723
|
pagehandler.delete pageFile, (err) ->
|
|
726
724
|
if err
|
|
727
725
|
res.status(500).send(err)
|
|
@@ -729,7 +727,7 @@ module.exports = exports = (argv) ->
|
|
|
729
727
|
sitemaphandler.removePage pageFile
|
|
730
728
|
res.status(200).send('')
|
|
731
729
|
# update site index
|
|
732
|
-
searchhandler.removePage(req.params[0]
|
|
730
|
+
searchhandler.removePage(req.params[0])
|
|
733
731
|
|
|
734
732
|
|
|
735
733
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wiki-server",
|
|
3
3
|
"description": "A Federated Wiki Server",
|
|
4
|
-
"version": "0.21.
|
|
4
|
+
"version": "0.21.3",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ward Cunningham",
|
|
7
7
|
"email": "ward@c2.com",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"glob": "^7.1.4",
|
|
34
34
|
"lodash": "^4.17.19",
|
|
35
35
|
"method-override": "^2.3.10",
|
|
36
|
-
"minisearch": "^
|
|
36
|
+
"minisearch": "^6.0.0",
|
|
37
37
|
"mkdirp": "^0.5.5",
|
|
38
38
|
"morgan": "^1.9.1",
|
|
39
39
|
"node-fetch": "^2.6.1",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"xml2js": "^0.4.23"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"test": "
|
|
45
|
+
"test": "grunt mochaTest"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"grunt": "^1.0.4",
|