git ssb

3+

ev / sdash



Tree: 746f5afe179f874dc5f6c5608629c805307ecf1c

Files: 746f5afe179f874dc5f6c5608629c805307ecf1c / index.js

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

Built with git-ssb-web