var http = require('http') var fs = require('fs') var h = require('hyperscript') var pull = require('pull-stream') var client = require('ssb-client') var md = require('ssb-markdown') var avatar = require('ssb-avatar') var mo = require('moment') var title = 'sdash' var me = '@8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=.ed25519' var viewerUrl = 'https://viewer.scuttlebot.io/' http.createServer(function (req, res){ if (req.url === '/') { client(function (err, sbot) { pull( sbot.query.read({query: [{$filter: { value: { author: me, content: {type: 'post'}}}}], limit: 1, reverse: true}), pull.drain(function (data) { post = data gotPost() }) ) }) function gotPost() { res.end( h('html', h('head', h('title', title), h('style', fs.readFileSync('style.css', 'utf8')) ), h('body', h('div.msg', h('script', {src: viewerUrl + encodeURI(post.key) + '.js'}) ) ) ).outerHTML) } } }).listen(1337)