Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #185

Merged
merged 6 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/page.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ path = require 'path'
events = require 'events'
glob = require 'glob'

mkdirp = require 'mkdirp'
async = require 'async'

random_id = require './random_id'
Expand All @@ -31,7 +30,7 @@ module.exports = exports = (argv) ->

wikiName = new URL(argv.url).hostname

mkdirp argv.db, (e) ->
fs.mkdir argv.db, { recursive: true }, (e) ->
if e then throw e

#### Private utility methods. ####
Expand All @@ -53,7 +52,7 @@ module.exports = exports = (argv) ->
console.log "ERROR: problem page #{loc} moved to recycler"
)
else
mkdirp(path.dirname(recyclePage), (err) ->
fs.mkdir(path.dirname(recyclePage), { recursive: true }, (err) ->
if err
console.log "ERROR: creating recycler", err
else
Expand Down Expand Up @@ -134,7 +133,7 @@ module.exports = exports = (argv) ->
cb(err)
)
else
mkdirp(path.dirname(recycleLoc), (err) ->
fs.mkdir(path.dirname(recycleLoc), { recursive: true }, (err) ->
if err then cb(err)
fs.rename(loc, recycleLoc, (err) ->
cb(err)
Expand Down Expand Up @@ -179,7 +178,7 @@ module.exports = exports = (argv) ->
cb(err)
)
else
mkdirp(path.dirname(recycleLoc), (err) ->
fs.mkdir(path.dirname(recycleLoc), { recursive: true }, (err) ->
if err then cb(err)
copyFile(loc, recycleLoc, (err) ->
cb(err)
Expand Down Expand Up @@ -234,7 +233,7 @@ module.exports = exports = (argv) ->
cb(err)
)
else
mkdirp(path.dirname(loc), (err) ->
fs.mkdir(path.dirname(loc), { recursive: true }, (err) ->
if err then cb(err)
fs.writeFile(loc, page, (err) ->
if err
Expand Down
4 changes: 2 additions & 2 deletions lib/search.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
fs = require 'fs'
path = require 'path'
events = require 'events'
url = require 'node:url'
writeFileAtomic = require 'write-file-atomic'
mkdirp = require 'mkdirp'

miniSearch = require 'minisearch'

Expand Down Expand Up @@ -84,7 +84,7 @@ module.exports = exports = (argv) ->
touch indexUpdateFlag, (err) ->
cb()
else
mkdirp argv.status, ->
fs.mkdir argv.status, { recursive: true }, ->
writeFileAtomic siteIndexLoc, JSON.stringify(siteIndex), (e) ->
return cb(e) if e
touch indexUpdateFlag, (err) ->
Expand Down
12 changes: 8 additions & 4 deletions lib/server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ url = require 'url'
{ pipeline } = require 'node:stream/promises'

# From npm
mkdirp = require 'mkdirp'
express = require 'express'
hbs = require 'express-hbs'
glob = require 'glob'
async = require 'async'
f = require('flates')
sanitize = require '@mapbox/sanitize-caja'

createDOMPurify = require('dompurify')
{ JSDOM } = require('jsdom')

window = new JSDOM('').window
DOMPurify = createDOMPurify(window)

# node-fetch is now ESM only
fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
Expand Down Expand Up @@ -73,7 +77,7 @@ render = (page) ->
f.p(resolveClient.resolveLinks(story.text or story.caption or 'uploaded image'))
else if story.type is 'html'
f.div {class: "item html"},
f.p(resolveClient.resolveLinks(story.text or '', sanitize))
f.p(resolveClient.resolveLinks(story.text or '', DOMPurify.sanitize))
else f.div {class: "item"}, f.p(resolveClient.resolveLinks(story.text or ''))
).join('\n')

Expand Down Expand Up @@ -427,7 +431,7 @@ module.exports = exports = (argv) ->
res.send('Favicon Saved')

else
mkdirp argv.status, ->
fs.mkdir argv.status, { recursive: true }, ->
fs.writeFile favLoc, buf, (e) ->
if e then return res.e e
res.send('Favicon Saved')
Expand Down
11 changes: 4 additions & 7 deletions lib/sitemap.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ fs = require 'fs'
path = require 'path'
events = require 'events'
writeFileAtomic = require 'write-file-atomic'
_ = require 'lodash'
xml2js = require 'xml2js'

mkdirp = require 'mkdirp'

synopsis = require 'wiki-client/lib/synopsis'

asSlug = (name) ->
Expand Down Expand Up @@ -100,7 +97,7 @@ module.exports = exports = (argv) ->
idx = slugs.indexOf(file)

if ~idx
_.pullAt(sitemap, idx)
sitemap.splice(idx,1)

cb()

Expand All @@ -111,7 +108,7 @@ module.exports = exports = (argv) ->
return cb(e) if e
cb()
else
mkdirp argv.status, ->
fs.mkdir argv.status, { recursive: true }, ->
writeFileAtomic sitemapLoc, JSON.stringify(sitemap), (e) ->
return cb(e) if e
cb()
Expand All @@ -134,7 +131,7 @@ module.exports = exports = (argv) ->

xmlSitemapSave = (sitemap, cb) ->
xmlmap = []
_.each sitemap, (page) ->
sitemap.forEach (page) ->
result = {}
result["loc"] = argv.url + "/" + page.slug + ".html"
if page.date?
Expand All @@ -151,7 +148,7 @@ module.exports = exports = (argv) ->
return cb(e) if e
cb()
else
mkdirp argv.status, ->
fs.mkdir argv.status, { recursive: true }, ->
writeFileAtomic xmlSitemapLoc, xml, (e) ->
return cb(e) if e
cb()
Expand Down
Loading
Loading