git ssb

3+

ev / sdash



Tree: 9c55bfe9756f66db6349ef96874c993dd8dd1466

Files: 9c55bfe9756f66db6349ef96874c993dd8dd1466 / index.js

1009 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 = 'https://viewer.evbogue.com/'
11
12http.createServer(function (req, res){
13 if (req.url === '/') {
14 client(function (err, sbot) {
15 pull(
16 sbot.query.read({query: [{$filter: { value: { author: me, content: {type: 'post'}}}}], limit: 1, reverse: true}),
17 pull.drain(function (data) {
18 post = data
19 gotPost()
20 })
21 )
22 })
23 function gotPost() {
24 res.end(
25 h('html',
26 h('head',
27 h('title', title),
28 h('style', fs.readFileSync('style.css', 'utf8'))
29 ),
30 h('body',
31 h('div.msg',
32 h('script', {src: viewerUrl + encodeURI(post.key) + '.js'})
33 )
34 )
35 ).outerHTML)
36 }
37 }
38}).listen(1337)
39

Built with git-ssb-web