aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 62e3629..6a08c4a 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -302,6 +302,7 @@ Serve.prototype.path = function (url) {
case '/git': return this.git(m[2])
case '/image': return this.image(m[2])
case '/npm': return this.npm(m[2])
+ case '/npm-prebuilds': return this.npmPrebuilds(m[2])
case '/npm-readme': return this.npmReadme(m[2])
}
return this.respond(404, 'Not found')
@@ -1971,6 +1972,59 @@ Serve.prototype.npm = function (url) {
)
}
+Serve.prototype.npmPrebuilds = 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 prefix = 'prebuild:' +
+ (name ? name + '-' +
+ (version ? version + '-' : '') : '')
+
+ var render = self.app.render
+ var base = '/npm-prebuilds/' + (author ? u.escapeId(author) + '/' : '')
+ return pull(
+ ph('section', {}, [
+ ph('h3', [ph('a', {href: render.toUrl('/npm-prebuilds/')}, 'npm prebuilds'), ' : ',
+ name ? [ph('a', {href: render.toUrl(base + name)}, name), ' : '] : '',
+ version ? [ph('a', {href: render.toUrl(base + name + '/' + version)}, version)] : '',
+ ]),
+ ph('table', [
+ ph('thead', ph('tr', [
+ ph('th', 'publisher'),
+ ph('th', 'name'),
+ ph('th', 'version'),
+ ph('th', 'runtime'),
+ ph('th', 'abi'),
+ ph('th', 'platform+libc'),
+ ph('th', 'arch'),
+ ph('th', 'size'),
+ ph('th', 'tarball')
+ ])),
+ ph('tbody', pull(
+ self.app.blobMentions({
+ name: {$prefix: prefix},
+ author: author,
+ }),
+ paramap(function (link, cb) {
+ self.app.render.npmPrebuildMention(link, {
+ withAuthor: true,
+ author: author,
+ name: name,
+ version: version,
+ }, cb)
+ }, 4),
+ pull.map(u.toHTML)
+ ))
+ ])
+ ]),
+ self.wrapPage(prefix),
+ self.respondSink(200)
+ )
+}
+
Serve.prototype.npmReadme = function (url) {
var self = this
var id = decodeURIComponent(url.substr(1))