aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-09-30 23:58:01 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-10-01 12:17:30 -1000
commitab3a0ab5900e05e5c2227eca74196d9460a5354d (patch)
treea8f86c87cb885eb2dfa3e2600384e4680e484f16 /lib/serve.js
parent3643ae071dc1e2ba89f67606bd267eb3e3f0f312 (diff)
downloadpatchfoo-ab3a0ab5900e05e5c2227eca74196d9460a5354d.tar.gz
patchfoo-ab3a0ab5900e05e5c2227eca74196d9460a5354d.zip
Render npm prebuilds
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))