diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-12-08 12:28:31 -0800 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-12-08 12:45:07 -0800 |
commit | 678bce09b58899d8689acf40946b9985db7a9ada (patch) | |
tree | 125e85845452d944f3a4b5590fc9ef6c27203c6b /lib/serve.js | |
parent | ef2fab24f57268bc2a96e74078855dfad047fd5b (diff) | |
download | patchfoo-678bce09b58899d8689acf40946b9985db7a9ada.tar.gz patchfoo-678bce09b58899d8689acf40946b9985db7a9ada.zip |
Render blog messages
Diffstat (limited to 'lib/serve.js')
-rw-r--r-- | lib/serve.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/serve.js b/lib/serve.js index c100f40..c858a1b 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -326,6 +326,7 @@ Serve.prototype.path = function (url) { case '/npm': return this.npm(m[2]) case '/npm-prebuilds': return this.npmPrebuilds(m[2]) case '/npm-readme': return this.npmReadme(m[2]) + case '/markdown': return this.markdown(m[2]) } return this.respond(404, 'Not found') } @@ -2143,6 +2144,31 @@ Serve.prototype.npmReadme = function (url) { ) } +Serve.prototype.markdown = function (url) { + var self = this + var id = decodeURIComponent(url.substr(1)) + var blobs = self.app.sbot.blobs + return pull( + ph('section', {}, [ + ph('h3', [ + ph('a', {href: '/links/' + id}, id.substr(0, 8) + '…') + ]), + u.readNext(function (cb) { + blobs.size(id, function (err, size) { + if (size == null) return cb(null, self.askWantBlobsForm([id])) + pull(blobs.get(id), pull.collect(function (err, chunks) { + if (err) return cb(null, ph('div', u.renderError(err).outerHTML)) + var text = Buffer.concat(chunks).toString() + cb(null, ph('blockquote', self.app.render.markdown(text))) + })) + }) + }) + ]), + self.wrapPage('markdown'), + self.respondSink(200) + ) +} + // wrap a binary source and render it or turn into an embed Serve.prototype.wrapBinary = function (opts) { var self = this |