git ssb

3+

ev / sdash



Tree: d722ee9ed13150208b5992caafe81eac10f525a9

Files: d722ee9ed13150208b5992caafe81eac10f525a9 / index.js

1967 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
16var style = fs.readFileSync(__dirname + '/style.css', 'utf8')
17
18exports.name = 'viewer'
19exports.manifest = {}
20exports.version = require('./package').version
21
22exports.init = function (sbot, config) {
23
24 http.createServer(function (req, res){
25 if (req.url === '/') {
26 client(function (err, sbot) {
27 pull(
28 sbot.query.read({query: [{$filter: { value: { author: me, content: {type: 'post'}}}}], limit: 1, reverse: true}),
29 pull.drain(function (data) {
30 post = data
31 gotPost()
32 })
33 )
34 })
35 function gotPost() {
36 res.end(
37 h('html',
38 h('head',
39 h('title', title),
40 h('style', style)
41 ),
42 h('body',
43 h('div.msg',
44 h('script', {src: viewerUrl + encodeURI(post.key) + '.js'})
45 )
46 )
47 ).outerHTML)
48 }
49 }
50 if (req.url === '/invite/') {
51 client(function (err, sbot) {
52 sbot.invite.create(opts, function (err, invite) {
53 if(err) throw err
54 lite = invite
55 gotInvite()
56 })
57 })
58 function gotInvite() {
59 res.end(
60 h('html',
61 h('head',
62 h('title', title)
63 // h('style', fs.readFileSync('./style.css', 'utf8'))
64 ),
65 h('body',
66 h('div.msg',
67 h('p', {innerHTML: '<a href="' + liteURL + '#' + lite + '" rel="nofollow" target="_blank">'+ liteURL + '#' + lite + '</a>'})
68 )
69 )
70 ).outerHTML)
71 }
72 }
73 }).listen(1337)
74
75}
76

Built with git-ssb-web