git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit 5285e716749369d47e938077f6d87389eb282ba9

initial file-picker

austinfrey committed on 4/12/2019, 5:02:46 AM
Parent: 90dfad001a91b412a745a9cad0dccf4a3ef49dc2

Files changed

bin.jschanged
mvd/index.jschanged
mvd/views.jschanged
package.jsonchanged
file-picker/index.jsadded
bin.jsView
@@ -9,8 +9,9 @@
99 const muxrpcli = require('muxrpcli')
1010 const {pull, values, once} = require('pull-stream')
1111 const toPull = require('stream-to-pull-stream')
1212 const webresolve = require('ssb-web-resolver')
13 +const h = require('hyperscript')
1314
1415 var SEC = 1e3
1516 var MIN = 60*SEC
1617
@@ -60,17 +61,17 @@
6061 send.address = 'ws://100.115.92.2:8989~shs:VelntasZy86CuIihzSpkzPvIOYgyu3FO3NZww/UOirk='
6162
6263 var m = urlIdRegex.exec(req.url)
6364
64- function onError(err) { if (err) console.error('[viewer]', err) }
65 + function onError(err) { if (err) console.error('ERROR', err) }
6566
6667 if(req.url == '/') {
6768 var filePath = path.join(__dirname, 'localhost/build/index.html')
6869
6970 return pull(file(filePath), toPull(res, onError))
7071 }
7172 if(req.url == '/mvd') {
72- var filePath = path.join(__dirname, 'build/index.html')
73 + var filePath = path.join(__dirname, 'mvd/build/index.html')
7374
7475 return pull(file(filePath), toPull(res, onError))
7576 }
7677 if(req.url.startsWith('/web/')) {
@@ -90,18 +91,49 @@
9091
9192 function serveWeb (req, res, url) {
9293 var self = this
9394 var id = decodeURIComponent(url.substr(1))
95 + var components = url.split('/')
9496
95- var components = url.split('/')
9697 if (components[0] === '') components.shift()
9798 if (components[0] === 'web') components.shift()
99 +
98100 components[0] = decodeURIComponent(components[0])
99101
102 + var initId = components[0]
103 + var pathArray = [...components].slice(1)
104 + var restOfPath = pathArray[0] ? pathArray.join('/') + '/' : ''
105 +
100106 webresolve(sbot, components, function (err, data) {
101107 if (err) return respond(res, 404, 'ERROR: ' + err)
102108
109 + if (data.slice(2, 7).toString() === 'links') {
110 + const dir = JSON.parse(data)
111 + const entries = Object.keys(dir.links).map(key => {
112 + const urlPath = '/web/'
113 + + encodeURIComponent(initId)
114 + + '/'
115 + + restOfPath
116 + + key
103117
118 + return h('div', [
119 + h('img', {
120 + src: (key.indexOf('.') > -1)
121 + ? '/img/emoji/page_with_curl.png'
122 + : '/img/emoji/file_folder.png',
123 + style: {
124 + width: '15px',
125 + height: 'auto'
126 + }
127 + }),
128 + h('a', {href: urlPath}, key)
129 + ])
130 + })
131 +
132 + var html = h('div', entries)
133 +
134 + return pull(once(html.outerHTML), toPull(res, onError))
135 + }
104136 return pull(once(data), toPull(res))
105137 })
106138 }
107139 })
mvd/index.jsView
@@ -54,9 +54,9 @@
5454 h('li', h('a', {href: '#wall/' + id }, 'Wall')),
5555 h('li', h('a', {href: '#queue'}, 'Queue')),
5656 h('li', h('a', {href: '#key' }, 'Key')),
5757 h('li.right', h('a', {href: 'http://gitmx.com/#%NPNNvcnTMZUFZSWl/2Z4XX+YSdqsqOhyPacp+lgpQUw=.sha256'}, '?')),
58- h('form.search', {
58 + h('form.search', {
5959 onsubmit: function (e) {
6060 if (search.value[0] == '#')
6161 window.location.hash = '#' + search.value
6262 else
mvd/views.jsView
@@ -512,9 +512,9 @@
512512 }
513513
514514 pull(
515515 createStream({
516- limit: 1000,
516 + limit: 1000, // this needs to be a high number for scrollign to work!
517517 reverse: true,
518518 live: false,
519519 query: [{$filter: { value: { timestamp: { $gt: 0 }}}}]
520520 }),
@@ -537,10 +537,9 @@
537537 if (msg.value) {
538538 if (msg.value.timestamp > Date.now()) {
539539 return h('div.future')
540540 } else {
541- var node = render(msg)
542- return node
541 + return render(msg)
543542 }
544543 }
545544 })
546545 )
@@ -656,9 +655,9 @@
656655 function hash () {
657656 return window.location.hash.substring(1)
658657 }
659658
660-module.exports = function () {
659 +module.exports = function (mount) {
661660 var src = hash()
662661
663662 if (src.substring(52, 59) == '?unbox=') {
664663 privateMsg(src)
package.jsonView
@@ -4,36 +4,30 @@
44 "description": "minimum viable decent",
55 "main": "index.js",
66 "scripts": {
77 "start": "node bin server",
8- "decent": "node bin server --appname=decent",
9- "ssb": "node bin server --appname=ssb",
10- "testnet": "node bin server --appname=testnet",
11- "build:mvd": "node mvd/style.js && mkdir -p build && browserify mvd/index.js | indexhtmlify > build/index.html",
12- "build:localhost": "browserify localhost/index.js -t sheetify | indexhtmlify > localhost/build/index.html"
8 + "testnet": "ssb_appname=ssb_testnet node bin server",
9 + "build:mvd": "node mvd/style.js && mkdir -p mvd/build && browserify mvd/index.js | indexhtmlify > mvd/build/index.html",
10 + "build:localhost": "browserify localhost/index.js -t sheetify | indexhtmlify > localhost/build/index.html",
11 + "publish:mvd": "ssb-webify publish mvd/build"
1312 },
1413 "devDependencies": {
1514 "browserify": "^16.2.2",
1615 "indexhtmlify": "^1.3.1"
1716 },
1817 "author": "Ev Bogue <ev@evbogue.com>",
1918 "license": "MIT",
2019 "dependencies": {
21- "broadcast-stream": "^0.2.2",
22- "chloride": "^2.2.14",
2320 "dataurl-": "^0.1.0",
2421 "deep-extend": "^0.6.0",
2522 "diff": "^3.5.0",
26- "emoji-server": "^1.0.0",
2723 "human-time": "0.0.1",
2824 "hyperfile": "^2.0.0",
2925 "hyperloadmore": "^1.1.0",
3026 "hyperscript": "^2.0.2",
3127 "hyperscroll": "^1.0.0",
3228 "inu-engine": "^1.0.0-pre.0",
33- "multiblob-http": "^0.4.2",
3429 "muxrpcli": "^1.1.0",
35- "nanomorph": "^5.4.0",
3630 "non-private-ip": "^1.4.3",
3731 "open": "^6.1.0",
3832 "os-homedir": "^1.0.2",
3933 "patch-package": "^6.1.0",
file-picker/index.jsView
@@ -1,0 +1,32 @@
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 +}

Built with git-ssb-web