Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests; misc fixes #532

Merged
merged 9 commits into from Dec 18, 2015
Next

Improve torrent.createServer() index page

- Download link uses correct filename
- List shows file paths, not just name
- Add file size
- Show torrent name at top, instead of generic “WebTorrent” title
  • Loading branch information
feross committed Dec 10, 2015
commit 4d6fa88a9ec5731fb649d14490123b0e421caa74
@@ -3,6 +3,7 @@ module.exports = Server
var debug = require('debug')('webtorrent:server')
var http = require('http')
var mime = require('mime')
var prettyBytes = require('pretty-bytes')
var pump = require('pump')
var rangeParser = require('range-parser')
var url = require('url')
@@ -58,9 +59,12 @@ function Server (torrent, opts) {
if (pathname === '/') {
res.setHeader('Content-Type', 'text/html')
var listHtml = torrent.files.map(function (file, i) {
return '<li><a href="/' + i + '">' + file.name + '</a></li>'
return '<li><a download="' + file.name + '" href="/' + i + '">' + file.path + '</a> ' +
'(' + prettyBytes(file.length) + ')</li>'
}).join('<br>')
return res.end('<h1>WebTorrent</h1><ol>' + listHtml + '</ol>')

var html = '<h1>' + torrent.name + '</h1><ol>' + listHtml + '</ol>'
return res.end(html)
}

var index = Number(pathname.slice(1))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.