Files: 9c55bfe9756f66db6349ef96874c993dd8dd1466 / index.js
1009 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 | |
8 | var title = 'sdash' |
9 | var me = '@8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=.ed25519' |
10 | var viewerUrl = 'https://viewer.evbogue.com/' |
11 | |
12 | http.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