git ssb

3+

ev / decent



Commit d2a1433a0ec00097a926dfe6ffc4d2d6bbb1b4c0

attempt to integrate sdash and ssb-viewer into one decent package

Ev Bogue committed on 6/23/2017, 5:16:58 PM
Parent: 44fa44b60b078e9257408541c9c5824267deb7ca

Files changed

decent.jschanged
package.jsonchanged
serve.jschanged
yarn.lockchanged
sdash.jsadded
decent.jsView
@@ -47,9 +47,15 @@
4747 .use(require('ssb-ws'))
4848 .use(require('ssb-links'))
4949 .use(require('ssb-query'))
5050 .use(require('ssb-ebt'))
51- // .use(require('ssb-fulltext'))
51 + .use(require('./serve'))
52 + .use(require('./sdash'))
53 + .use(require('ssb-viewer-ev'))
54 + // .use(require('sdash'))
55 + //.use(require('ssb-fulltext'))
56 + //var lite = require('./serve')
57 + //lite.serve()
5258
5359 // add third-party plugins
5460 //require('scuttlebot/plugins/plugins').loadUserPlugins(createSbot, config)
5561
@@ -60,10 +66,8 @@
6066
6167 // write RPC manifest to ~/.ssb/manifest.json
6268 fs.writeFileSync(manifestFile, JSON.stringify(server.getManifest(), null, 2))
6369
64- var lite = require('./serve')
65- lite.serve()
6670
6771 } else {
6872
6973 // normal command:
package.jsonView
@@ -1,7 +1,7 @@
11 {
22 "name": "decent",
3- "version": "2.0.0",
3 + "version": "2.0.1",
44 "description": "A decent(tralized) lite client for secure scuttlebutt",
55 "homepage": "http://gitmx.com/%25Wq%2FvobdcDedC0FBO2UdowxhPcqokSwtf9Og1mjYvQGE%3D.sha256",
66 "scripts": {
77 "build": "node scripts/style.js && mkdir -p build && browserify index.js | indexhtmlify > build/index.html",
@@ -9,7 +9,9 @@
99 },
1010 "author": "Ev Bogue",
1111 "license": "MIT",
1212 "dependencies": {
13- "minbase": "^1.3.0"
13 + "minbase": "^1.3.0",
14 + "sdash": "^3.0.0",
15 + "ssb-viewer-ev": "^1.0.0"
1416 }
1517 }
serve.jsView
@@ -1,9 +1,9 @@
11 var http = require('http');
22 var serve = require('ecstatic');
33 var client = require('ssb-client')
44
5-exports.serve = function() {
5 +exports.init = function() {
66 http.createServer(
77 serve({ root: __dirname + '/build/'})
88 ).listen(3013);
99
yarn.lockView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 116283 bytes
New file size: 111730 bytes
sdash.jsView
@@ -1,0 +1,81 @@
1 +var http = require('http')
2 +var fs = require('fs')
3 +var h = require('hyperscript')
4 +var pull = require('pull-stream')
5 +var client = require('ssb-client')
6 +var md = require('ssb-markdown')
7 +
8 +var config = require('ssb-config/inject')(process.env.ssb_appname)
9 +var ssbKeys = require('ssb-keys')
10 +var path = require('path')
11 +
12 +var title = 'sdash'
13 +var opts = {"modern":true,}
14 +var lite;
15 +
16 +var style = fs.readFileSync(__dirname + '/node_modules/sdash/style.css', 'utf8')
17 +
18 +exports.name = 'sdash'
19 +exports.manifest = {}
20 +exports.version = require('./package').version
21 +
22 +exports.init = function (sbot, config) {
23 +
24 + var viewerUrl = 'http://' + config.host + ':8807/'
25 + var liteURL = 'http://' + config.host + ':3013/'
26 + var id = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret')).id
27 +
28 + http.createServer(function (req, res){
29 + if (req.url === '/') {
30 + client(function (err, sbot) {
31 + pull(
32 + sbot.query.read({query: [{$filter: { value: { author: id, content: {type: 'post'}}}}], limit: 1, reverse: true}),
33 + pull.drain(function (data) {
34 + post = data
35 + gotPost()
36 + sbot.close()
37 + })
38 + )
39 + })
40 + function gotPost() {
41 + res.end(
42 + h('html',
43 + h('head',
44 + h('title', title),
45 + h('style', style)
46 + ),
47 + h('body',
48 + h('div.msg',
49 + h('script', {src: viewerUrl + encodeURI(post.key) + '.js'})
50 + )
51 + )
52 + ).outerHTML)
53 + }
54 + }
55 + if (req.url === '/invite/') {
56 + client(function (err, sbot) {
57 + sbot.invite.create(opts, function (err, invite) {
58 + if(err) throw err
59 + lite = invite
60 + gotInvite()
61 + sbot.close()
62 + })
63 + })
64 + function gotInvite() {
65 + res.end(
66 + h('html',
67 + h('head',
68 + h('title', title),
69 + h('style', style)
70 + ),
71 + h('body',
72 + h('div.msg',
73 + h('p', {innerHTML: '<a href="' + liteURL + '#' + lite + '" rel="nofollow" target="_blank">'+ liteURL + '#' + lite + '</a>'})
74 + )
75 + )
76 + ).outerHTML)
77 + }
78 + }
79 + }).listen(1337)
80 +
81 +}

Built with git-ssb-web