git ssb

3+

ev / sdash



Tree: 3a4d25efb5cc4deb27280b8d8c796052914bb64d

Files: 3a4d25efb5cc4deb27280b8d8c796052914bb64d / index.js

1935 bytesRaw
1var http = require('http')
2var fs = require('fs')
3var h = require('hyperscript')
4var pull = require('pull-stream')
5var client = require('ssb-client')
6var md = require('ssb-markdown')
7
8var title = 'sdash'
9var me = '@8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=.ed25519'
10var viewerUrl = 'http://evbogue.com:8807/'
11
12var liteURL = 'http://ssb.evbogue.com/'
13var opts = {"modern":true,}
14var lite;
15
16exports.name = 'viewer'
17exports.manifest = {}
18exports.version = require('./package').version
19
20exports.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 )
44 )
45 ).outerHTML)
46 }
47 }
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 })
55 })
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 )
67 )
68 ).outerHTML)
69 }
70 }
71 }).listen(1337)
72
73}
74

Built with git-ssb-web