Commit bea0d6f86662e5db7348deb37bef697f1226edae
initial standalone ssb-server implementation. will also serve ssb-webified apps
austinfrey committed on 4/8/2019, 11:52:38 PMParent: a425ae10c31740a80df9cd0fb2c15de82b6bad4f
Files changed
.gitignore | changed |
bin.js | changed |
config.js | changed |
config/inject.js | changed |
package.json | changed |
avatar.js | deleted |
compose.js | deleted |
index.js | deleted |
keys.js | deleted |
package-lock.json | added |
mvd-indexes.js | deleted |
public/favicon.ico | added |
public/favicon_io.zip | added |
mvd.png | deleted |
query/index.js | deleted |
ui/avatar.js | added |
ui/compose.js | added |
ui/index.js | added |
ui/keys.js | added |
ui/mvd-indexes.js | added |
ui/render.js | added |
ui/style.css | added |
ui/style.css.json | added |
ui/style.js | added |
ui/tools.js | added |
ui/views.js | added |
render.js | deleted |
scuttlebot.js | deleted |
style.css | deleted |
style.css.json | deleted |
style.js | deleted |
tools.js | deleted |
views.js | deleted |
bin.js | |||
---|---|---|---|
@@ -1,76 +1,125 @@ | |||
1 | 1 … | var fs = require('fs') | |
2 | 2 … | var path = require('path') | |
3 | 3 … | var ssbKeys = require('ssb-keys') | |
4 | 4 … | var stringify = require('pull-stringify') | |
5 | -var open = require('opn') | ||
5 … | +var open = require('open') | ||
6 | 6 … | var home = require('os-homedir')() | |
7 | 7 … | var nonPrivate = require('non-private-ip') | |
8 | 8 … | var muxrpcli = require('muxrpcli') | |
9 … | +var {pull, values, once} = require('pull-stream') | ||
10 … | +var toPull = require('stream-to-pull-stream') | ||
11 … | +const webresolve = require('ssb-web-resolver') | ||
9 | 12 … | ||
10 | 13 … | var SEC = 1e3 | |
11 | 14 … | var MIN = 60*SEC | |
12 | 15 … | ||
13 | -var network = 'ssb' | ||
14 | -//var network = 'decent' | ||
15 | -//var network = 'testnet' | ||
16 | - | ||
16 … | +var network = process.env.ssb_appname || 'ssb' | ||
17 | 17 … | var config = require('./config/inject')(network) | |
18 | 18 … | ||
19 … | +var urlIdRegex = /^(?:\/(([%&@]|%25|%26|%40)(?:[A-Za-z0-9\/+]|%2[Ff]|%2[Bb]){43}(?:=|%3[Dd])\.(?:sha256|ed25519))(?:\.([^?]*))?|(\/.*?))(?:\?(.*))?$/ | ||
20 … | + | ||
19 | 21 … | config.keys = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret')) | |
20 | 22 … | ||
21 | 23 … | var mvdClient = fs.readFileSync(path.join('./build/index.html')) | |
24 … | +var favicon = fs.readFileSync(path.join('./public/favicon.ico')) | ||
22 | 25 … | ||
23 | 26 … | var manifestFile = path.join(config.path, 'manifest.json') | |
24 | 27 … | ||
25 | 28 … | var argv = process.argv.slice(2) | |
26 | 29 … | var i = argv.indexOf('--') | |
27 | 30 … | var conf = argv.slice(i+1) | |
28 | 31 … | argv = ~i ? argv.slice(0, i) : argv | |
29 | 32 … | ||
30 | -if (argv[0] == 'server') { | ||
31 | - | ||
32 | - var createSbot = require('scuttlebot-release/node_modules/scuttlebot') | ||
33 | - .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/master')) | ||
34 | - .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/gossip')) | ||
35 | - .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/replicate')) | ||
33 … | +if (argv[0] == 'start') { | ||
34 … | + | ||
35 … | + var createSbot = require('ssb-server') | ||
36 … | + | ||
37 … | + createSbot | ||
38 … | + .use(require('ssb-server/plugins/master')) | ||
39 … | + .use(require('ssb-replicate')) | ||
36 | 40 … | .use(require('ssb-friends')) | |
41 … | + .use(require('ssb-gossip')) | ||
37 | 42 … | .use(require('ssb-blobs')) | |
38 | 43 … | .use(require('ssb-backlinks')) | |
39 | - .use(require('./query')) | ||
44 … | + .use(require('ssb-query')) | ||
40 | 45 … | .use(require('ssb-links')) | |
41 | 46 … | .use(require('ssb-ebt')) | |
42 | 47 … | .use(require('ssb-search')) | |
43 | - .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/invite')) | ||
44 | - .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/local')) | ||
45 | - .use(require('decent-ws')) | ||
48 … | + .use(require('ssb-server/plugins/local')) | ||
49 … | + .use(require('ssb-ws')) | ||
46 | 50 … | .use({ | |
47 | 51 … | name: 'serve', | |
48 | 52 … | version: '1.0.0', | |
49 | 53 … | init: function (sbot) { | |
54 … | + console.log(sbot.getAddress()) | ||
50 | 55 … | sbot.ws.use(function (req, res, next) { | |
51 | 56 … | var send = config | |
57 … | + | ||
52 | 58 … | delete send.keys // very important to keep this, as it removes the server keys from the config before broadcast | |
53 | - send.address = sbot.ws.getAddress() | ||
54 | - sbot.invite.create({modern: true}, function (err, cb) { | ||
55 | - send.invite = cb | ||
56 | - }) | ||
57 | - if(req.url == '/') | ||
58 | - res.end(mvdClient) | ||
59 | - if(req.url == '/get-config') | ||
60 | - res.end(JSON.stringify(send)) | ||
61 | - else next() | ||
59 … | + | ||
60 … | + send.address = 'ws://100.115.92.2:8989~shs:VelntasZy86CuIihzSpkzPvIOYgyu3FO3NZww/UOirk=' | ||
61 … | + | ||
62 … | + //sbot.invite.create({modern: true}, function (err, cb) { | ||
63 … | + // send.invite = cb | ||
64 … | + //}) | ||
65 … | + | ||
66 … | + var m = urlIdRegex.exec(req.url) | ||
67 … | + | ||
68 … | + if(req.url == '/') { | ||
69 … | + console.log('/') | ||
70 … | + return res.end('<h1>/</h1>') | ||
71 … | + } | ||
72 … | + if(req.url.startsWith('/web/')) { | ||
73 … | + return serveWeb(req, res, m[4]) | ||
74 … | + } | ||
75 … | + if(req.url == '/get-config') { | ||
76 … | + console.log('/get-config') | ||
77 … | + return res.end(JSON.stringify(send)) | ||
78 … | + } | ||
79 … | + if(req.url == '/favicon.ico') { | ||
80 … | + console.log('/favicon') | ||
81 … | + return res.end(favicon) | ||
82 … | + } else next() | ||
83 … | + | ||
84 … | + function respond(res, status, message) { | ||
85 … | + res.writeHead(status) | ||
86 … | + res.end(message) | ||
87 … | + } | ||
88 … | + | ||
89 … | + function serveWeb (req, res, url) { | ||
90 … | + var self = this | ||
91 … | + var id = decodeURIComponent(url.substr(1)) | ||
92 … | + | ||
93 … | + var components = url.split('/') | ||
94 … | + if (components[0] === '') components.shift() | ||
95 … | + if (components[0] === 'web') components.shift() | ||
96 … | + components[0] = decodeURIComponent(components[0]) | ||
97 … | + | ||
98 … | + webresolve(sbot, components, function (err, data) { | ||
99 … | + console.log(err) | ||
100 … | + if (err) return respond(res, 404, 'ERROR: ' + err) | ||
101 … | + | ||
102 … | + function onError(err) { | ||
103 … | + if (err) console.error('[viewer]', err) | ||
104 … | + } | ||
105 … | + | ||
106 … | + return pull(once(data), toPull(res)) | ||
107 … | + }) | ||
108 … | + } | ||
62 | 109 … | }) | |
63 | 110 … | } | |
64 | 111 … | }) | |
65 | - | ||
66 | - open('http://localhost:' + config.ws.port, {wait: false}) | ||
67 | - | ||
68 | - var server = createSbot(config) | ||
69 | - | ||
70 | - fs.writeFileSync(manifestFile, JSON.stringify(server.getManifest(), null, 2)) | ||
71 | -} else { | ||
72 | 112 … | ||
113 … | + // open('http://localhost:' + config.ws.port, {wait: false}) | ||
114 … | + | ||
115 … | + // start server | ||
116 … | + var server = createSbot(config) | ||
117 … | + | ||
118 … | + fs.writeFileSync(manifestFile, JSON.stringify(server.getManifest(), null, 2)) | ||
119 … | +} | ||
120 … | +else { | ||
121 … | + | ||
73 | 122 … | var manifest | |
74 | 123 … | try { | |
75 | 124 … | manifest = JSON.parse(fs.readFileSync(manifestFile)) | |
76 | 125 … | } catch (err) { |
config.js | ||
---|---|---|
@@ -2,9 +2,9 @@ | ||
2 | 2 … | |
3 | 3 … | module.exports = function () { |
4 | 4 … | //var host = window.location.origin |
5 | 5 … | |
6 | - var host = 'http://100.115.92.2:8989' | |
6 … | + var host = 'http://100.115.92.2:9191' | |
7 | 7 … | |
8 | 8 … | function getConfig () { |
9 | 9 … | http.get(host + '/get-config', function (res) { |
10 | 10 … | res.on('data', function (data, remote) { |
@@ -25,9 +25,9 @@ | ||
25 | 25 … | } |
26 | 26 … | |
27 | 27 … | config.blobsUrl = host + '/blobs/get/' |
28 | 28 … | config.emojiUrl = host + '/img/emoji/' |
29 | - | |
29 … | + console.log(config) | |
30 | 30 … | if (config.ws.remote) |
31 | 31 … | config.remote = config.ws.remote |
32 | 32 … | else |
33 | 33 … | config.remote = config.address |
config/inject.js | ||
---|---|---|
@@ -29,29 +29,29 @@ | ||
29 | 29 … | network = { |
30 | 30 … | port: 3333, |
31 | 31 … | ws: { |
32 | 32 … | port: 3939 |
33 | - }, | |
34 | - caps: { | |
33 … | + }, | |
34 … | + caps: { | |
35 | 35 … | shs: 'EVRctE2Iv8GrO/BpQCF34e2FMPsDJot9x0j846LjVtc=', |
36 | - sign: null | |
36 … | + sign: null | |
37 | 37 … | } |
38 | 38 … | } |
39 | 39 … | } |
40 | 40 … | |
41 | - if (name === 'testnet') { | |
42 | - network = { | |
41 … | + if (name === 'ssb_testnet') { | |
42 … | + network = { | |
43 | 43 … | port: 9999, |
44 | 44 … | ws: { |
45 | 45 … | port: 9191 |
46 | - }, | |
46 … | + }, | |
47 | 47 … | caps: { |
48 | 48 … | shs: 'sR74I0+OW6LBYraQQ2YtFtqV5Ns77Tv5DyMfyWbrlpI=', |
49 | - sign: null | |
49 … | + sign: null | |
50 | 50 … | } |
51 | 51 … | } |
52 | 52 … | } |
53 | - | |
53 … | + | |
54 | 54 … | var HOME = home() || 'browser' //most probably browser |
55 | 55 … | |
56 | 56 … | return RC(name, merge(network, { |
57 | 57 … | name: name, |
package.json | ||
---|---|---|
@@ -7,19 +7,19 @@ | ||
7 | 7 … | "start": "node bin server", |
8 | 8 … | "decent": "node bin server --appname=decent", |
9 | 9 … | "ssb": "node bin server --appname=ssb", |
10 | 10 … | "testnet": "node bin server --appname=testnet", |
11 | - "build": "node style.js && mkdir -p build && browserify index.js | indexhtmlify > build/index.html" | |
11 … | + "build": "node ui/style.js && mkdir -p build && browserify ui/index.js | indexhtmlify > build/index.html" | |
12 | 12 … | }, |
13 | 13 … | "devDependencies": { |
14 | 14 … | "browserify": "^16.2.2", |
15 | 15 … | "indexhtmlify": "^1.3.1" |
16 | 16 … | }, |
17 | 17 … | "author": "Ev Bogue <ev@evbogue.com>", |
18 | 18 … | "license": "MIT", |
19 | 19 … | "dependencies": { |
20 … | + "chloride": "^2.2.14", | |
20 | 21 … | "dataurl-": "^0.1.0", |
21 | - "decent-ws": "1.0.4", | |
22 | 22 … | "deep-extend": "^0.6.0", |
23 | 23 … | "diff": "^3.5.0", |
24 | 24 … | "emoji-server": "^1.0.0", |
25 | 25 … | "human-time": "0.0.1", |
@@ -29,32 +29,41 @@ | ||
29 | 29 … | "hyperscroll": "^1.0.0", |
30 | 30 … | "multiblob-http": "^0.4.2", |
31 | 31 … | "muxrpcli": "^1.1.0", |
32 | 32 … | "non-private-ip": "^1.4.3", |
33 | - "opn": "^5.3.0", | |
33 … | + "open": "^6.1.0", | |
34 | 34 … | "os-homedir": "^1.0.2", |
35 … | + "patch-package": "^6.1.0", | |
35 | 36 … | "pull-more": "^1.1.0", |
36 | 37 … | "pull-next-query": "^1.0.0", |
37 | 38 … | "pull-reconnect": "0.0.3", |
38 | - "pull-stream": "^3.6.8", | |
39 … | + "pull-stream": "^3.6.9", | |
39 | 40 … | "pull-stringify": "^2.0.0", |
40 | 41 … | "rc": "^1.2.7", |
41 | - "scuttlebot-release": "ssbc/scuttlebot-release#11.3.x-fixups", | |
42 | 42 … | "simple-mime": "^0.1.0", |
43 | 43 … | "split-buffer": "^1.0.0", |
44 | 44 … | "ssb-avatar": "^0.2.0", |
45 | 45 … | "ssb-backlinks": "^0.7.1", |
46 | 46 … | "ssb-blobs": "^1.1.5", |
47 | 47 … | "ssb-client": "^4.5.7", |
48 | 48 … | "ssb-ebt": "^5.1.5", |
49 | 49 … | "ssb-feed": "^2.3.0", |
50 | - "ssb-friends": "^2.4.0", | |
50 … | + "ssb-friends": "^3.1.6", | |
51 … | + "ssb-gossip": "^1.0.6", | |
52 … | + "ssb-invite": "^2.0.4", | |
51 | 53 … | "ssb-keys": "^7.0.16", |
52 | 54 … | "ssb-links": "^3.0.3", |
53 | 55 … | "ssb-markdown": "^3.6.0", |
54 | 56 … | "ssb-mentions": "^0.5.0", |
57 … | + "ssb-query": "^2.3.0", | |
55 | 58 … | "ssb-ref": "^2.11.1", |
59 … | + "ssb-replicate": "^1.2.3", | |
56 | 60 … | "ssb-search": "^1.0.1", |
61 … | + "ssb-server": "^13.6.3", | |
62 … | + "ssb-viewer": "^1.0.0", | |
63 … | + "ssb-web-resolver": "^1.1.2", | |
64 … | + "ssb-ws": "^6.0.0", | |
57 | 65 … | "stack": "^0.1.0", |
66 … | + "stream-to-pull-stream": "^1.7.3", | |
58 | 67 … | "visualize-buffer": "0.0.1" |
59 | 68 … | } |
60 | 69 … | } |
avatar.js | ||
---|---|---|
@@ -1,92 +1,0 @@ | ||
1 | -var pull = require('pull-stream') | |
2 | -var query = require('./scuttlebot').query | |
3 | -var h = require('hyperscript') | |
4 | -var visualize = require('visualize-buffer') | |
5 | - | |
6 | -var avatar = require('ssb-avatar') | |
7 | - | |
8 | -var sbot = require('./scuttlebot') | |
9 | - | |
10 | -var config = require('./config')() | |
11 | - | |
12 | -var id = require('./keys').id | |
13 | - | |
14 | -var ref = require('ssb-ref') | |
15 | - | |
16 | -module.exports.name = function (key) { | |
17 | - | |
18 | - var avatarname = h('span', key.substring(0, 10)) | |
19 | - if (ref.isFeedId(key)) { | |
20 | - avatar(sbot, id, key, function (err, data) { | |
21 | - if (err) throw err | |
22 | - if (data.name) { | |
23 | - if (data.name[0] != '@') { | |
24 | - var name = '@' + data.name | |
25 | - } else { | |
26 | - var name = data.name | |
27 | - } | |
28 | - localStorage[key + 'name'] = name | |
29 | - avatarname.textContent = name | |
30 | - } | |
31 | - }) | |
32 | - } | |
33 | - return avatarname | |
34 | -} | |
35 | - | |
36 | -module.exports.image = function (key) { | |
37 | - var img = visualize(new Buffer(key.substring(1), 'base64'), 256) | |
38 | - | |
39 | - if (ref.isFeedId(key)) { | |
40 | - avatar(sbot, id, key, function (err, data) { | |
41 | - if (err) throw err | |
42 | - if (data.image) { | |
43 | - localStorage[key + 'image'] = data.image | |
44 | - img.src = config.blobsUrl + data.image | |
45 | - } | |
46 | - }) | |
47 | - } | |
48 | - return img | |
49 | -} | |
50 | - | |
51 | -module.exports.cachedName = function (key) { | |
52 | - var avatarname = h('span', key.substring(0, 10)) | |
53 | - | |
54 | - if (localStorage[key + 'name']) { | |
55 | - avatarname.textContent = localStorage[key + 'name'] | |
56 | - } else { | |
57 | - if (ref.isFeedId(key)) { | |
58 | - avatar(sbot, id, key, function (err, data) { | |
59 | - if (data.name) { | |
60 | - if (data.name[0] != '@') { | |
61 | - var name = '@' + data.name | |
62 | - } else { | |
63 | - var name = data.name | |
64 | - } | |
65 | - localStorage[key + 'name'] = name | |
66 | - avatarname.textContent = name | |
67 | - } | |
68 | - }) | |
69 | - } | |
70 | - } | |
71 | - | |
72 | - return avatarname | |
73 | -} | |
74 | - | |
75 | -module.exports.cachedImage = function (key) { | |
76 | - var img = visualize(new Buffer(key.substring(1), 'base64'), 256) | |
77 | - | |
78 | - if (localStorage[key + 'image']) { | |
79 | - img.src = config.blobsUrl + localStorage[key + 'image'] | |
80 | - } else { | |
81 | - if (ref.isFeedId(key)) { | |
82 | - avatar(sbot, id, key, function (err, data) { | |
83 | - if (data.image) { | |
84 | - localStorage[key + 'image'] = data.image | |
85 | - img.src = config.blobsUrl + data.image | |
86 | - } | |
87 | - }) | |
88 | - } | |
89 | - } | |
90 | - | |
91 | - return img | |
92 | -} |
compose.js | ||
---|---|---|
@@ -1,187 +1,0 @@ | ||
1 | -var h = require('hyperscript') | |
2 | -var pull = require('pull-stream') | |
3 | -var sbot = require('./scuttlebot') | |
4 | -var human = require('human-time') | |
5 | -var id = require('./keys').id | |
6 | -var mentions = require('ssb-mentions') | |
7 | - | |
8 | -var avatar = require('./avatar') | |
9 | -var tools = require('./tools') | |
10 | - | |
11 | -var mime = require('simple-mime')('application/octect-stream') | |
12 | -var split = require('split-buffer') | |
13 | - | |
14 | -var route = require('./views') | |
15 | - | |
16 | -function file_input (onAdded) { | |
17 | - return h('label.btn', 'Upload file', | |
18 | - h('input', { type: 'file', hidden: true, | |
19 | - onchange: function (ev) { | |
20 | - var file = ev.target.files[0] | |
21 | - if (!file) return | |
22 | - var reader = new FileReader() | |
23 | - reader.onload = function () { | |
24 | - pull( | |
25 | - pull.values(split(new Buffer(reader.result), 64*1024)), | |
26 | - sbot.addblob(function (err, blob) { | |
27 | - if(err) return console.error(err) | |
28 | - onAdded({ | |
29 | - link: blob, | |
30 | - name: file.name, | |
31 | - size: reader.result.length || reader.result.byteLength, | |
32 | - type: mime(file.name) | |
33 | - }) | |
34 | - }) | |
35 | - ) | |
36 | - } | |
37 | - reader.readAsArrayBuffer(file) | |
38 | - } | |
39 | - })) | |
40 | -} | |
41 | - | |
42 | -module.exports = function (opts, fallback) { | |
43 | - var files = [] | |
44 | - var filesById = {} | |
45 | - | |
46 | - var composer = h('div.composer') | |
47 | - var container = h('div.container') | |
48 | - if (opts.boostAuthor) { | |
49 | - var boostName = avatar.cachedName(opts.boostAuthor) | |
50 | - } | |
51 | - if (opts.boostContent) { | |
52 | - var textarea = h('textarea.compose') | |
53 | - var str = opts.boostContent | |
54 | - var lines = str.split("\n") | |
55 | - for(var i=0; i<lines.length; i++) { | |
56 | - lines[i] = "> " + lines[i] | |
57 | - } | |
58 | - var newContent = lines.join("\n") | |
59 | - var content = 'Boosting: ' + opts.boostKey + '\n\n' + newContent + ' - [' + boostName.textContent + ']('+ opts.boostAuthor + ')' | |
60 | - textarea.value = content | |
61 | - } | |
62 | - | |
63 | - else if (opts.mentions) { | |
64 | - var textarea = h('textarea.compose', opts.mentions) | |
65 | - } | |
66 | - | |
67 | - else if (opts.type == 'wiki') | |
68 | - var textarea = h('textarea.compose', {placeholder: opts.placeholder || 'Write a wiki (anyone can edit)'}) | |
69 | - else if (opts.type == 'post') | |
70 | - var textarea = h('textarea.compose', {placeholder: opts.placeholder || 'Write a message (only you can edit)'}) | |
71 | - else | |
72 | - var textarea = h('textarea.compose', {placeholder: opts.placeholder || 'Write a message (only you can edit)'}, fallback.messageText) | |
73 | - | |
74 | - var cancelBtn = h('button.btn', 'Cancel', { | |
75 | - onclick: function () { | |
76 | - var cancel | |
77 | - console.log(opts) | |
78 | - | |
79 | - if (opts.type == 'edit') { | |
80 | - cancel = document.getElementById('edit:' + opts.branch.substring(0,44)) | |
81 | - var oldMessage = h('div.message__body', tools.markdown(fallback.messageText)) | |
82 | - cancel.parentNode.replaceChild(oldMessage, cancel) | |
83 | - oldMessage.parentNode.appendChild(fallback.buttons) | |
84 | - } else if (opts.branch) { | |
85 | - //cancel reply composer | |
86 | - cancel = document.getElementById('re:' + opts.branch.substring(0,44)) | |
87 | - cancel.parentNode.removeChild(cancel) | |
88 | - message = document.getElementById(opts.branch.substring(0,44)) | |
89 | - message.appendChild(fallback.buttons) | |
90 | - } else { | |
91 | - // cancel generic composer | |
92 | - cancel = document.getElementById('composer') | |
93 | - cancel.parentNode.removeChild(cancel) | |
94 | - } | |
95 | - } | |
96 | - | |
97 | - }) | |
98 | - | |
99 | - var initialButtons = h('span', | |
100 | - h('button.btn', 'Preview', { | |
101 | - onclick: function () { | |
102 | - if (textarea.value) { | |
103 | - var msg = {} | |
104 | - | |
105 | - msg.value = { | |
106 | - "author": id, | |
107 | - "content": opts | |
108 | - } | |
109 | - | |
110 | - msg.value.content.text = textarea.value | |
111 | - msg.value.content.mentions = mentions(textarea.value).map( | |
112 | - function (mention) { | |
113 | - var file = filesById[mention.link] | |
114 | - if (file) { | |
115 | - if (file.type) mention.type = file.type | |
116 | - if (file.size) mention.size = file.size | |
117 | - } | |
118 | - return mention | |
119 | - } | |
120 | - ) | |
121 | - | |
122 | - if (opts.recps) | |
123 | - msg.value.private = true | |
124 | - | |
125 | - console.log(msg) | |
126 | - if (opts.type == 'post' || opts.type == 'wiki') | |
127 | - var header = tools.header(msg) | |
128 | - if (opts.type == 'update') | |
129 | - var header = tools.timestamp(msg, {edited: true}) | |
130 | - var preview = h('div', | |
131 | - header, | |
132 | - h('div.message__content', tools.markdown(msg.value.content.text)), | |
133 | - h('button.btn', 'Publish', { | |
134 | - onclick: function () { | |
135 | - if (msg.value.content) { | |
136 | - sbot.publish(msg.value.content, function (err, msg) { | |
137 | - if(err) throw err | |
138 | - console.log('Published!', msg) | |
139 | - if (opts.type == 'edit') { | |
140 | - var message = document.getElementById(opts.branch.substring(0,44)) | |
141 | - fallback.messageText = msg.value.content.text | |
142 | - var editBody = h('div.message__body', | |
143 | - tools.timestamp(msg, {edited: true}), | |
144 | - h('div', tools.markdown(msg.value.content.text)) | |
145 | - ) | |
146 | - | |
147 | - message.replaceChild(editBody, message.childNodes[message.childNodes.length - 1]) | |
148 | - editBody.parentNode.appendChild(fallback.buttons) | |
149 | - } else { | |
150 | - if (opts.branch) | |
151 | - cancel = document.getElementById('re:' + opts.branch.substring(0,44)) | |
152 | - else | |
153 | - cancel = document.getElementById('composer') | |
154 | - cancel.parentNode.removeChild(cancel) | |
155 | - } | |
156 | - }) | |
157 | - } | |
158 | - } | |
159 | - }), | |
160 | - h('button.btn', 'Cancel', { | |
161 | - onclick: function () { | |
162 | - composer.replaceChild(container, composer.firstChild) | |
163 | - container.appendChild(textarea) | |
164 | - container.appendChild(initialButtons) | |
165 | - } | |
166 | - }) | |
167 | - ) | |
168 | - composer.replaceChild(preview, composer.firstChild) | |
169 | - } | |
170 | - } | |
171 | - }), | |
172 | - file_input(function (file) { | |
173 | - files.push(file) | |
174 | - filesById[file.link] = file | |
175 | - var embed = file.type.indexOf('image/') === 0 ? '!' : '' | |
176 | - textarea.value += embed + '['+file.name+']('+file.link+')' | |
177 | - }), | |
178 | - cancelBtn | |
179 | - ) | |
180 | - | |
181 | - composer.appendChild(container) | |
182 | - container.appendChild(textarea) | |
183 | - container.appendChild(initialButtons) | |
184 | - | |
185 | - return composer | |
186 | -} | |
187 | - |
index.js | ||
---|---|---|
@@ -1,81 +1,0 @@ | ||
1 | -var h = require('hyperscript') | |
2 | -var route = require('./views') | |
3 | -var avatar = require('./avatar') | |
4 | - | |
5 | -var compose = require('./compose') | |
6 | - | |
7 | -var id = require('./keys').id | |
8 | - | |
9 | -document.head.appendChild(h('style', require('./style.css.json'))) | |
10 | - | |
11 | -var screen = h('div#screen') | |
12 | - | |
13 | -var search = h('input.search', {placeholder: 'Search'}) | |
14 | - | |
15 | -var nav = h('div.navbar', | |
16 | - h('div.internal', | |
17 | - h('li', h('a', {href: '#' + id}, h('span.avatar--small', avatar.image(id)))), | |
18 | - h('li', h('a', {href: '#' + id}, avatar.name(id))), | |
19 | - h('li', h('a', 'New Post', { | |
20 | - onclick: function () { | |
21 | - if (document.getElementById('composer')) { return } | |
22 | - else { | |
23 | - var currentScreen = document.getElementById('screen') | |
24 | - var opts = {} | |
25 | - opts.type = 'post' | |
26 | - var composer = h('div.content#composer', h('div.message', compose(opts))) | |
27 | - if (currentScreen.firstChild.firstChild) { | |
28 | - currentScreen.firstChild.insertBefore(composer, currentScreen.firstChild.firstChild) | |
29 | - } else { | |
30 | - currentScreen.firstChild.appendChild(composer) | |
31 | - } | |
32 | - } | |
33 | - } | |
34 | - })), | |
35 | - h('li', h('a', 'New Wiki', { | |
36 | - onclick: function () { | |
37 | - if (document.getElementById('composer')) { return } | |
38 | - else { | |
39 | - var currentScreen = document.getElementById('screen') | |
40 | - var opts = {} | |
41 | - opts.type = 'wiki' | |
42 | - var composer = h('div.content#composer', h('div.message', compose(opts))) | |
43 | - if (currentScreen.firstChild.firstChild) { | |
44 | - currentScreen.firstChild.insertBefore(composer, currentScreen.firstChild.firstChild) | |
45 | - } else { | |
46 | - currentScreen.firstChild.appendChild(composer) | |
47 | - } | |
48 | - } | |
49 | - } | |
50 | - })), | |
51 | - h('li', h('a', {href: '#' }, 'All')), | |
52 | - h('li', h('a', {href: '#private' }, 'Private')), | |
53 | - h('li', h('a', {href: '#friends/' + id }, 'Friends')), | |
54 | - h('li', h('a', {href: '#wall/' + id }, 'Wall')), | |
55 | - h('li', h('a', {href: '#queue'}, 'Queue')), | |
56 | - h('li', h('a', {href: '#key' }, 'Key')), | |
57 | - h('li.right', h('a', {href: 'http://gitmx.com/#%NPNNvcnTMZUFZSWl/2Z4XX+YSdqsqOhyPacp+lgpQUw=.sha256'}, '?')), | |
58 | - h('form.search', { | |
59 | - onsubmit: function (e) { | |
60 | - if (search.value[0] == '#') | |
61 | - window.location.hash = '#' + search.value | |
62 | - else | |
63 | - window.location.hash = '?' + search.value | |
64 | - e.preventDefault() | |
65 | - }}, | |
66 | - search | |
67 | - ) | |
68 | - ) | |
69 | -) | |
70 | - | |
71 | -document.body.appendChild(nav) | |
72 | -document.body.appendChild(screen) | |
73 | -route() | |
74 | - | |
75 | -window.onhashchange = function () { | |
76 | - var oldscreen = document.getElementById('screen') | |
77 | - var newscreen = h('div#screen') | |
78 | - oldscreen.parentNode.replaceChild(newscreen, oldscreen) | |
79 | - route() | |
80 | -} | |
81 | - |
keys.js | ||
---|---|---|
@@ -1,6 +1,0 @@ | ||
1 | - | |
2 | -var config = require('./config')() | |
3 | -var ssbKeys = require('ssb-keys') | |
4 | -var path = require('path') | |
5 | - | |
6 | -module.exports = ssbKeys.loadOrCreateSync(path.join(config.caps.shs + '/secret')) |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 0 bytes New file size: 276075 bytes |
mvd-indexes.js | ||
---|---|---|
@@ -1,20 +1,0 @@ | ||
1 | -var Indexes = require('flumeview-query/indexes') | |
2 | -var pkg = require('./package.json') | |
3 | -exports.name = 'mvd-indexes' | |
4 | -exports.version = pkg.version | |
5 | -exports.manifest = {} | |
6 | - | |
7 | -exports.init = function (sbot, config) { | |
8 | - | |
9 | - var view = | |
10 | - sbot._flumeUse('query/mvd', Indexes(1, { | |
11 | - indexes: [ | |
12 | - {key: 'chr', value: [['value', 'timestamp' ]]} | |
13 | - ] | |
14 | - })) | |
15 | - | |
16 | - var indexes = view.indexes() | |
17 | - sbot.query.add(indexes[0]) | |
18 | - | |
19 | - return {} | |
20 | -} |
public/favicon.ico |
---|
public/favicon_io.zip | ||
---|---|---|
@@ -1,0 +1,480 @@ | ||
1 … | +PK | |
2 … | + ���N�Q�:N N apple-touch-icon.png�PNG | |
3 … | + | |
4 … | + IHDR � � =�2 IDATx^�} xU����ιS�$�$�3���@�NV���A?�Z����Vm��i�U�������ƪu�g'*�0�2�Ly�g��Y' ���s�� c�S�g�}�^�=����wNp�5��ePb���J!������W���:;S�,�!q3�����) ꙱�j�� | |
5 … | +����#;�� Ct���p1&����}�d���>'��DNe�#�i���h�b���M ï~Zx�ڵ 8�s�d|���CF0Xk�KM�x��������?��iI���O��a8�t�+�� | |
6 … | +?�l^�:;2���)Q�u93]@�1�_�F�~��;�� �N(��d��7 �����;��s��{l9K.����Sf.�j-�(��aEoc�Y��{��_�c���>������+�4�����g���" |