Commit 0882250828f8b296fbb0440e8f4e54238db0c88c
in the beginning
Michael Williams committed on 10/27/2016, 1:08:03 PMFiles changed
.gitignore | added |
README.md | added |
graph.js | added |
index.js | added |
out/index.js | added |
package.json | added |
profile.js | added |
test/index.js | added |
README.md | ||
---|---|---|
@@ -1,0 +1,39 @@ | ||
1 … | +# ssb-viz | |
2 … | + | |
3 … | +visualize the ssb network graph | |
4 … | + | |
5 … | +```shell | |
6 … | +npm install ssb-viz -g | |
7 … | +``` | |
8 … | + | |
9 … | +## scripts | |
10 … | + | |
11 … | +### build | |
12 … | + | |
13 … | +```sh | |
14 … | +npm run build | |
15 … | +``` | |
16 … | + | |
17 … | +### start | |
18 … | + | |
19 … | +```sh | |
20 … | +npm start | |
21 … | +``` | |
22 … | + | |
23 … | +## license | |
24 … | + | |
25 … | +The Apache License | |
26 … | + | |
27 … | +Copyright © 2016 Michael Williams | |
28 … | + | |
29 … | +Licensed under the Apache License, Version 2.0 (the "License"); | |
30 … | +you may not use this file except in compliance with the License. | |
31 … | +You may obtain a copy of the License at | |
32 … | + | |
33 … | + http://www.apache.org/licenses/LICENSE-2.0 | |
34 … | + | |
35 … | +Unless required by applicable law or agreed to in writing, software | |
36 … | +distributed under the License is distributed on an "AS IS" BASIS, | |
37 … | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
38 … | +See the License for the specific language governing permissions and | |
39 … | +limitations under the License. |
graph.js | ||
---|---|---|
@@ -1,0 +1,30 @@ | ||
1 … | +const pull = require('pull-stream') | |
2 … | +const Sbot = require('ssb-client') | |
3 … | +const waterfall = require('run-waterfall') | |
4 … | + | |
5 … | +module.exports = Graph | |
6 … | + | |
7 … | +function Graph (sbot, cb) { | |
8 … | + waterfall([ | |
9 … | + (cb) => sbot.friends.all(cb), | |
10 … | + (friends, cb) => { | |
11 … | + cb(null, { | |
12 … | + nodes: Object.keys(friends).map(id => ({ id })), | |
13 … | + links: Object.keys(friends).reduce((sofar, friend) => { | |
14 … | + const friendOfFriends = Object.keys(friends[friend]) | |
15 … | + .filter(id => friends[friend][id] === true) | |
16 … | + const edges = friendOfFriends.map(friendOfFriend => { | |
17 … | + return { | |
18 … | + fromId: friend, | |
19 … | + toId: friendOfFriend | |
20 … | + } | |
21 … | + }) | |
22 … | + return [ | |
23 … | + ...sofar, | |
24 … | + ...edges | |
25 … | + ] | |
26 … | + }, []) | |
27 … | + }) | |
28 … | + } | |
29 … | + ], cb) | |
30 … | +} |
index.js | ||
---|---|---|
@@ -1,0 +1,15 @@ | ||
1 … | +const fs = require('fs') | |
2 … | +const Path = require('path') | |
3 … | +const fromJson = require('ngraph.fromjson') | |
4 … | +const Renderer = require('ngraph.pixel') | |
5 … | +const Graph = require('./graph') | |
6 … | + | |
7 … | +module.exports = function (sbot, cb) { | |
8 … | + Graph(sbot, (err, data) => { | |
9 … | + if (err) return cb(err) | |
10 … | + const str = JSON.stringify(data) | |
11 … | + const graph = fromJson(str) | |
12 … | + const display = Renderer(graph) | |
13 … | + cb(null, display) | |
14 … | + }) | |
15 … | +} |
out/index.js | |||
---|---|---|---|
@@ -1,0 +1,21 @@ | |||
1 … | +const insertCss = require('insert-css') | ||
2 … | +const Sbot = require('ssb-client') | ||
3 … | +const Viz = require('../') | ||
4 … | + | ||
5 … | +insertCss(` | ||
6 … | + html, body { | ||
7 … | + width: 100%; | ||
8 … | + height: 100%; | ||
9 … | + position: absolute; | ||
10 … | + overflow: hidden; | ||
11 … | + padding: 0; | ||
12 … | + margin: 0; | ||
13 … | + } | ||
14 … | +`) | ||
15 … | + | ||
16 … | +Sbot((err, sbot) => { | ||
17 … | + Viz(sbot, (err, viz) => { | ||
18 … | + if (err) throw err | ||
19 … | + sbot.close() | ||
20 … | + }) | ||
21 … | +}) |
package.json | ||
---|---|---|
@@ -1,0 +1,57 @@ | ||
1 … | +{ | |
2 … | + "name": "ssb-viz", | |
3 … | + "version": "0.0.0", | |
4 … | + "description": "visualize the ssb network graph", | |
5 … | + "main": "index.js", | |
6 … | + "scripts": { | |
7 … | + "test": "tape test.js", | |
8 … | + "start": "electro out/bundle.js", | |
9 … | + "bundle": "browselectrify out/index.js", | |
10 … | + "build": "npm run --silent bundle -- > out/bundle.js", | |
11 … | + "disc": "npm run --silent bundle -- --full-paths | discify --open", | |
12 … | + "push": "gh-pages -d out", | |
13 … | + "deploy": "npm-run-all -s build push" | |
14 … | + }, | |
15 … | + "browserify": { | |
16 … | + "transform": [ | |
17 … | + "brfs", | |
18 … | + "es2040" | |
19 … | + ] | |
20 … | + }, | |
21 … | + "repository": { | |
22 … | + "type": "git", | |
23 … | + "url": "git+https://github.com/ahdinosaur/ssb-viz.git" | |
24 … | + }, | |
25 … | + "keywords": [], | |
26 … | + "author": "Mikey <michael.williams@enspiral.com> (http://dinosaur.is)", | |
27 … | + "license": "Apache-2.0", | |
28 … | + "bugs": { | |
29 … | + "url": "https://github.com/ahdinosaur/ssb-viz/issues" | |
30 … | + }, | |
31 … | + "homepage": "https://github.com/ahdinosaur/ssb-viz#readme", | |
32 … | + "devDependencies": { | |
33 … | + "browserify": "^13.0.0", | |
34 … | + "budo": "^8.1.0", | |
35 … | + "disc": "^1.3.2", | |
36 … | + "envify": "^3.4.0", | |
37 … | + "gh-pages": "^0.11.0", | |
38 … | + "npm-run-all": "^1.6.0", | |
39 … | + "tape": "^4.5.1", | |
40 … | + "uglifyify": "^3.0.1", | |
41 … | + "watchify": "^3.7.0" | |
42 … | + }, | |
43 … | + "dependencies": { | |
44 … | + "brfs": "^1.4.3", | |
45 … | + "browselectrify": "^1.0.1", | |
46 … | + "electro": "^2.0.2", | |
47 … | + "electron": "^1.4.4", | |
48 … | + "es2040": "^1.2.4", | |
49 … | + "insert-css": "^1.0.0", | |
50 … | + "ngraph.fromjson": "^0.1.8", | |
51 … | + "ngraph.pixel": "^2.2.0", | |
52 … | + "pull-stream": "^3.4.5", | |
53 … | + "run-waterfall": "^1.1.3", | |
54 … | + "ssb-client": "^4.3.0", | |
55 … | + "stream-to-pull-stream": "^1.7.2" | |
56 … | + } | |
57 … | +} |
Built with git-ssb-web