diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-09-20 10:43:25 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-09-20 10:44:17 -1000 |
commit | 2eb748d24d3ee0d13f990d2b7eab167a1b41b930 (patch) | |
tree | bc28850107b8360a188ecd59dc8c78887eecc410 /lib/render.js | |
parent | a9feab3b1f5335b14fc0feba4da2b9fe40aa1224 (diff) | |
download | patchfoo-2eb748d24d3ee0d13f990d2b7eab167a1b41b930.tar.gz patchfoo-2eb748d24d3ee0d13f990d2b7eab167a1b41b930.zip |
Render npm package readmes
Diffstat (limited to 'lib/render.js')
-rw-r--r-- | lib/render.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/render.js b/lib/render.js index 6001184..5a0ddaa 100644 --- a/lib/render.js +++ b/lib/render.js @@ -422,12 +422,14 @@ Render.prototype.npmPackageMention = function (link, opts, cb) { var self = this var done = multicb({pluck: 1, spread: true}) var base = '/npm/' + (opts.author ? u.escapeId(link.author) + '/' : '') - var pathWithAuthor = '/npm/' + + var pathWithAuthor = opts.withAuthor ? '/npm/' + u.escapeId(link.author) + '/' + (opts.name ? opts.name + '/' + (opts.version ? opts.version + '/' + - (opts.distTag ? opts.distTag + '/' : '') : '') : '') - self.app.getAbout(link.author, function (err, about) { + (opts.distTag ? opts.distTag + '/' : '') : '') : '') : '' + self.app.getAbout(link.author, done()) + self.app.getBlobState(link.link, done()) + done(function (err, about, blobState) { if (err) return cb(err) cb(null, h('tr', [ opts.withAuthor ? h('td', h('a', { @@ -452,7 +454,20 @@ Render.prototype.npmPackageMention = function (link, opts, cb) { h('td', typeof link.link === 'string' ? h('code', h('a', { href: self.toUrl('/links/' + link.link), title: 'package tarball' - }, link.link.substr(0, 8) + '…')) : '') + }, link.link.substr(0, 8) + '…')) : ''), + h('td', + blobState === 'wanted' ? + 'fetching...' + : blobState ? h('a', { + href: self.toUrl('/npm-readme/' + encodeURIComponent(link.link)), + title: 'package contents' + }, 'readme') + : h('form', {action: '', method: 'post'}, + h('input', {type: 'hidden', name: 'action', value: 'want-blobs'}), + h('input', {type: 'hidden', name: 'async_want', value: '1'}), + h('input', {type: 'hidden', name: 'blob_ids', value: link.link}), + h('input', {type: 'submit', value: 'fetch'}) + )) ])) }) } |