diff options
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'}) + )) ])) }) } |