git ssb

3+

ev / sdash



Commit 3a4d25efb5cc4deb27280b8d8c796052914bb64d

rewrite sdash as an sbot plugin

Ev Bogue committed on 1/12/2017, 1:16:40 AM
Parent: 318383db2d5f15f36928ea41e5158a5de1dd0973

Files changed

index.jschanged
bin.jsadded
index.jsView
@@ -6,60 +6,68 @@
66 var md = require('ssb-markdown')
77
88 var title = 'sdash'
99 var me = '@8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=.ed25519'
10-var viewerUrl = 'https://viewer.evbogue.com/'
10 +var viewerUrl = 'http://evbogue.com:8807/'
1111
1212 var liteURL = 'http://ssb.evbogue.com/'
1313 var opts = {"modern":true,}
1414 var lite;
1515
16-http.createServer(function (req, res){
17- if (req.url === '/') {
18- client(function (err, sbot) {
19- pull(
20- sbot.query.read({query: [{$filter: { value: { author: me, content: {type: 'post'}}}}], limit: 1, reverse: true}),
21- pull.drain(function (data) {
22- post = data
23- gotPost()
24- })
25- )
26- })
27- function gotPost() {
28- res.end(
29- h('html',
30- h('head',
31- h('title', title),
32- h('style', fs.readFileSync('style.css', 'utf8'))
33- ),
34- h('body',
35- h('div.msg',
36- h('script', {src: viewerUrl + encodeURI(post.key) + '.js'})
16 +exports.name = 'viewer'
17 +exports.manifest = {}
18 +exports.version = require('./package').version
19 +
20 +exports.init = function (sbot, config) {
21 +
22 + http.createServer(function (req, res){
23 + if (req.url === '/') {
24 + client(function (err, sbot) {
25 + pull(
26 + sbot.query.read({query: [{$filter: { value: { author: me, content: {type: 'post'}}}}], limit: 1, reverse: true}),
27 + pull.drain(function (data) {
28 + post = data
29 + gotPost()
30 + })
31 + )
32 + })
33 + function gotPost() {
34 + res.end(
35 + h('html',
36 + h('head',
37 + h('title', title)
38 + // h('style', fs.readFileSync('style.css', 'utf8'))
39 + ),
40 + h('body',
41 + h('div.msg',
42 + h('script', {src: viewerUrl + encodeURI(post.key) + '.js'})
43 + )
3744 )
38- )
39- ).outerHTML)
45 + ).outerHTML)
46 + }
4047 }
41- }
42- if (req.url === '/invite/') {
43-client(function (err, sbot) {
44- sbot.invite.create(opts, function (err, invite) {
45- if(err) throw err
46- lite = invite
47- gotInvite()
48 + if (req.url === '/invite/') {
49 + client(function (err, sbot) {
50 + sbot.invite.create(opts, function (err, invite) {
51 + if(err) throw err
52 + lite = invite
53 + gotInvite()
54 + })
4855 })
49- })
50- function gotInvite() {
51- res.end(
52- h('html',
53- h('head',
54- h('title', title),
55- h('style', fs.readFileSync('style.css', 'utf8'))
56- ),
57- h('body',
58- h('div.msg',
59- h('p', {innerHTML: '<a href="' + liteURL + '#' + lite + '" rel="nofollow" target="_blank">'+ liteURL + '#' + lite + '</a>'})
56 + function gotInvite() {
57 + res.end(
58 + h('html',
59 + h('head',
60 + h('title', title),
61 + h('style', fs.readFileSync('./style.css', 'utf8'))
62 + ),
63 + h('body',
64 + h('div.msg',
65 + h('p', {innerHTML: '<a href="' + liteURL + '#' + lite + '" rel="nofollow" target="_blank">'+ liteURL + '#' + lite + '</a>'})
66 + )
6067 )
61- )
62- ).outerHTML)
68 + ).outerHTML)
69 + }
6370 }
64- }
65-}).listen(1337)
71 + }).listen(1337)
72 +
73 +}
bin.jsView
@@ -1,0 +1,6 @@
1 +#!/usr/bin/env node
2 +
3 +require('ssb-client')(function (err, sbot, config) {
4 + if (err) throw err
5 + require('.').init(sbot, config)
6 +})

Built with git-ssb-web