wiki-server 0.21.0-rc.1 → 0.21.0-rc.2
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/lib/search.coffee +27 -13
- package/package.json +2 -2
package/lib/search.coffee
CHANGED
|
@@ -162,21 +162,23 @@ module.exports = exports = (argv) ->
|
|
|
162
162
|
itself.stop()
|
|
163
163
|
|
|
164
164
|
extractPageText = (pageText, currentItem, currentIndex, array) ->
|
|
165
|
+
# console.log('extractPageText', pageText, currentItem, currentIndex, array)
|
|
165
166
|
try
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
167
|
+
if currentItem.text?
|
|
168
|
+
switch currentItem.type
|
|
169
|
+
when 'paragraph'
|
|
170
|
+
pageText += ' ' + currentItem.text.replace /\[{2}|\[(?:[\S]+)|\]{1,2}/g, ''
|
|
171
|
+
when 'markdown'
|
|
172
|
+
# really need to extract text from the markdown, but for now just remove link brackets, urls...
|
|
173
|
+
pageText += ' ' + currentItem.text.replace /\[{2}|\[(?:[\S]+)|\]{1,2}|\\n/g, ' '
|
|
174
|
+
when 'html'
|
|
175
|
+
pageText += ' ' + currentItem.text.replace /<[^>]*>/g, ''
|
|
176
|
+
else
|
|
177
|
+
if currentItem.text?
|
|
178
|
+
for line in currentItem.text.split /\r\n?|\n/
|
|
179
|
+
pageText += ' ' + line.replace /\[{2}|\[(?:[\S]+)|\]{1,2}/g, '' unless line.match /^[A-Z]+[ ].*/
|
|
178
180
|
catch err
|
|
179
|
-
throw new Error("Error extracting text from #{currentIndex}")
|
|
181
|
+
throw new Error("Error extracting text from #{currentIndex}, #{err}")
|
|
180
182
|
pageText
|
|
181
183
|
|
|
182
184
|
|
|
@@ -230,6 +232,7 @@ module.exports = exports = (argv) ->
|
|
|
230
232
|
pageText = page.story.reduce( extractPageText, '')
|
|
231
233
|
catch err
|
|
232
234
|
console.log "SITE INDEX *** #{wikiName} reduce to extract text on #{slug} failed", err.message
|
|
235
|
+
# console.log "page", page
|
|
233
236
|
pageText = ""
|
|
234
237
|
siteIndex.add {
|
|
235
238
|
'id': slug
|
|
@@ -281,6 +284,17 @@ module.exports = exports = (argv) ->
|
|
|
281
284
|
itself.once 'indexed', ->
|
|
282
285
|
fs.unlink indexUpdateFlag, (err) ->
|
|
283
286
|
console.log "+++ SITE INDEX #{wikiName} : unable to delete update flag" if err
|
|
287
|
+
else
|
|
288
|
+
# not been updated, but is it the correct version?
|
|
289
|
+
fs.readFile siteIndexLoc, (err, data) ->
|
|
290
|
+
if !err
|
|
291
|
+
try
|
|
292
|
+
testIndex = JSON.parse(data)
|
|
293
|
+
if testIndex.serializationVersion != 2
|
|
294
|
+
console.log('+++ SITE INDEX #{wikiName} : updating to latest version.')
|
|
295
|
+
itself.createIndex pagehandler
|
|
296
|
+
else
|
|
297
|
+
console.log "+++ SITE INDEX #{wikiName} : error reading index"
|
|
284
298
|
else
|
|
285
299
|
# index does not exist, so create it
|
|
286
300
|
itself.createIndex pagehandler
|
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.0-rc.
|
|
4
|
+
"version": "0.21.0-rc.2",
|
|
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": "^5.0.0",
|
|
37
37
|
"mkdirp": "^0.5.5",
|
|
38
38
|
"morgan": "^1.9.1",
|
|
39
39
|
"node-fetch": "^2.6.1",
|