wiki-server 0.24.2 → 0.25.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.
@@ -29,11 +29,12 @@ module.exports = exports = (argv) ->
29
29
  fs.exists server, (exists) ->
30
30
  if exists
31
31
  console.log 'starting plugin', plugin
32
- try
33
- plugins[plugin] = require server
32
+ import(server).then((exported) ->
33
+ plugins[plugin] = exported
34
34
  plugins[plugin].startServer?(params)
35
- catch e
35
+ ).catch((e) ->
36
36
  console.log 'failed to start plugin', plugin, e?.stack or e
37
+ )
37
38
 
38
39
  startServers = (params) ->
39
40
  # emitter = new events.EventEmitter()
package/lib/server.coffee CHANGED
@@ -163,15 +163,15 @@ module.exports = exports = (argv) ->
163
163
  .catch (err) ->
164
164
  console.error('Unable to fetch remote resource', remote, slug, err)
165
165
  cb(err, 'Page not found', 404)
166
-
167
166
 
168
-
167
+
168
+
169
169
  #### Express configuration ####
170
170
  # Set up all the standard express server options,
171
171
  # including hbs to use handlebars/mustache templates
172
172
  # saved with a .html extension, and no layout.
173
173
 
174
- #
174
+ #
175
175
  staticPathOptions = {
176
176
  dotfiles: 'ignore'
177
177
  etag: true
@@ -186,11 +186,24 @@ module.exports = exports = (argv) ->
186
186
  app.engine('html', hbs.express4())
187
187
  app.set('view options', layout: false)
188
188
 
189
- # use logger, at least in development, probably needs a param to configure (or turn off).
190
- # use stream to direct to somewhere other than stdout.
191
- wikiName = new URL(argv.url).hostname
192
- logger.token('vhost', () ->
193
- return wikiName)
189
+ # return deterministically colored strings
190
+ colorString = (str) ->
191
+ colorReset = '\x1b[0m'
192
+ hash = 0;
193
+ str.split('').forEach (char) ->
194
+ hash = char.charCodeAt(0) + ((hash << 5) - hash)
195
+ color = '\x1b[38;2'
196
+ for i in [0..2]
197
+ do (i) ->
198
+ value = (hash >> (i * 8)) & 0xff
199
+ color += ';' + value.toString()
200
+ color += 'm'
201
+ return color + str + colorReset
202
+
203
+ # use logger, at least in development, probably needs a param to configure (or turn off).
204
+ # use stream to direct to somewhere other than stdout.
205
+ logger.token('vhost', (req, res) ->
206
+ return colorString(req.hostname))
194
207
  app.use(logger(':vhost :method :url :status :res[content-length] - :response-time ms'))
195
208
  app.use(cookieParser())
196
209
  app.use(bodyParser.json({ limit: argv.uploadLimit}))
@@ -559,7 +572,7 @@ module.exports = exports = (argv) ->
559
572
  dict
560
573
  , {}))
561
574
  )
562
-
575
+
563
576
  admin = (req, res, next) ->
564
577
  if securityhandler.isAdmin(req)
565
578
  next()
@@ -604,7 +617,7 @@ module.exports = exports = (argv) ->
604
617
  res.status(fetchRes.status).end()
605
618
  .catch (err) ->
606
619
  console.log("ERROR: Proxy Request ", requestURL, err)
607
- res.status(500).end()
620
+ res.status(500).end()
608
621
  else
609
622
  res.status(400).end()
610
623
 
@@ -681,7 +694,7 @@ module.exports = exports = (argv) ->
681
694
  # otherwise ask pagehandler for it.
682
695
  if action.fork
683
696
  pagehandler.saveToRecycler req.params[0], (err) ->
684
- if err and err isnt 'page does not exist'
697
+ if err and err isnt 'page does not exist'
685
698
  console.log "Error saving #{req.params[0]} before fork: #{err}"
686
699
  if action.forkPage
687
700
  forkPageCopy = JSON.parse(JSON.stringify(action.forkPage))
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.24.2",
4
+ "version": "0.25.0",
5
5
  "author": {
6
6
  "name": "Ward Cunningham",
7
7
  "email": "ward@c2.com",
@@ -33,7 +33,7 @@
33
33
  "glob": "^7.2.3",
34
34
  "jsdom": "^24.0.0",
35
35
  "method-override": "^3.0.0",
36
- "minisearch": "^6.3.0",
36
+ "minisearch": "^7.1.0",
37
37
  "morgan": "^1.9.1",
38
38
  "node-fetch": "^3.3.2",
39
39
  "write-file-atomic": "^5.0.0",
@@ -49,9 +49,9 @@
49
49
  "grunt-mocha-test": "^0.13.3",
50
50
  "mocha": "^10.4.0",
51
51
  "should": "^13.2.3",
52
- "supertest": "^6.3.4",
52
+ "supertest": "^7.0.0",
53
53
  "wiki-client": "^0.29.1",
54
- "wiki-plugin-activity": "^0.5.0",
54
+ "wiki-plugin-activity": "^0.6.0",
55
55
  "wiki-plugin-video": "^0.3.1"
56
56
  },
57
57
  "engines": {