Files: 2cc03a6a37da12941e8a3db0673988b37da61bf7 / file-picker / index.js
769 bytesRaw
1 | const h = require('hyperscript') |
2 | |
3 | module.exports = function (err, data) { |
4 | if (err) return respond(res, 404, 'ERROR: ' + err) |
5 | |
6 | if (data.slice(2, 7).toString() === 'links') { |
7 | const dir = JSON.parse(data) |
8 | const entries = Object.keys(dir.links).map(key => { |
9 | const urlPath = '/web/' |
10 | + encodeURIComponent(initId) |
11 | + '/' |
12 | + restOfPath |
13 | + key |
14 | |
15 | return h('div', [ |
16 | h('img', { |
17 | src: '/img/emoji/file_folder.png', |
18 | style: { |
19 | width: '15px', |
20 | height: 'auto' |
21 | } |
22 | }), |
23 | h('a', {href: urlPath}, key) |
24 | ]) |
25 | }) |
26 | |
27 | var html = h('div', entries) |
28 | |
29 | return pull(once(html.outerHTML), toPull(res, onError)) |
30 | } |
31 | return pull(once(data), toPull(res)) |
32 | } |
33 |
Built with git-ssb-web