aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js37
1 files changed, 29 insertions, 8 deletions
diff --git a/lib/serve.js b/lib/serve.js
index b3f886f..5ebfa47 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -1876,6 +1876,8 @@ Serve.prototype.gitObjectLinks = function (headMsgId, type) {
Serve.prototype.npm = function (url) {
var self = this
var parts = url.split('/')
+ var author = parts[1] && parts[1][0] === '@'
+ ? u.unescapeId(parts.splice(1, 1)[0]) : null
var name = parts[1]
var version = parts[2]
var distTag = parts[3]
@@ -1884,15 +1886,27 @@ Serve.prototype.npm = function (url) {
(version ? version + ':' +
(distTag ? distTag + ':' : '') : '') : '')
+ var render = self.app.render
+ var base = '/npm/' + (author ? u.escapeId(author) + '/' : '')
+ var pathWithoutAuthor = '/npm/' +
+ (name ? name + '/' +
+ (version ? version + '/' +
+ (distTag ? distTag + '/' : '') : '') : '')
return pull(
ph('section', {}, [
- ph('h3', ['npm: ',
- name ? [ph('code', name), ' '] : '',
- version ? [ph('code', version), ' '] : '',
- distTag ? [ph('code', distTag), ' '] : ''
+ ph('h3', [ph('a', {href: render.toUrl('/npm/')}, 'npm'), ' : ',
+ author ? [
+ self.phIdLink(author), ' ',
+ ph('sub', ph('a', {href: render.toUrl(pathWithoutAuthor)}, '×')),
+ ' : '
+ ] : '',
+ name ? [ph('a', {href: render.toUrl(base + name)}, name), ' : '] : '',
+ version ? [ph('a', {href: render.toUrl(base + name + '/' + version)}, version), ' : '] : '',
+ distTag ? [ph('a', {href: render.toUrl(base + name + '/' + version + '/' + distTag)}, distTag)] : ''
]),
ph('table', [
ph('thead', ph('tr', [
+ !author ? ph('td', 'publisher') : '',
ph('td', 'package'),
ph('td', 'version'),
ph('td', 'tag'),
@@ -1901,14 +1915,21 @@ Serve.prototype.npm = function (url) {
])),
ph('tbody', pull(
self.app.blobMentions({
- name: {$prefix: prefix}
+ name: {$prefix: prefix},
+ author: author,
}),
distTag && !version && pull.filter(function (link) {
return link.name.split(':')[3] === distTag
}),
- pull.map(function (link) {
- return self.app.render.npmPackageMention(link)
- }),
+ paramap(function (link, cb) {
+ self.app.render.npmPackageMention(link, {
+ withAuthor: !author,
+ author: author,
+ name: name,
+ version: version,
+ distTag: distTag,
+ }, cb)
+ }, 4),
pull.map(u.toHTML)
))
])