Files: 746f5afe179f874dc5f6c5608629c805307ecf1c / index.js
1073 bytesRaw
1 | var http = require('http') |
2 | var fs = require('fs') |
3 | var h = require('hyperscript') |
4 | var pull = require('pull-stream') |
5 | var client = require('ssb-client') |
6 | var md = require('ssb-markdown') |
7 | var avatar = require('ssb-avatar') |
8 | var mo = require('moment') |
9 | |
10 | var title = 'sdash' |
11 | var me = '@8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=.ed25519' |
12 | var viewerUrl = 'https://viewer.scuttlebot.io/' |
13 | |
14 | http.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