git ssb

3+

ev / sdash



Commit 7cae0a97948f39b9e86bf0871d3396bb6d193929

rerewrite app in koa because hyperscript wasn't working quite doing what I wanted

Ev Bogue committed on 8/13/2016, 4:24:12 PM
Parent: d36ab22a6c54370a48ffd9901a0f11a1512c2461

Files changed

index.jschanged
index.jadeadded
index.jsView
@@ -1,14 +1,14 @@
1-var http = require('http');
21 var client = require('ssb-client');
32 var pull = require('pull-stream');
43 var moment = require('moment');
5-var h = require('hyperscript');
6-var {html, head, body, p, title } = require('hyperscript-helpers')(h);
4+var app = require('koa')();
5+var router = require('koa-router')();
6+var views = require('co-views');
77
8-var message;
98 var port = 1337;
109 var me = '@8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=.ed25519'
10+var message = 'I said nothing';
1111
1212 client(function (err, sbot) {
1313 if (err) {
1414 throw err;
@@ -18,41 +18,32 @@
1818 limit: 1,
1919 reverse: true
2020 }),
2121 pull.drain(function printMessage(msg) {
22- if (msg.value.content.type === 'post') {
23- message = (msg.value.content.text + ' - <span class="date">' + moment(msg.value.timestamp).fromNow() + '</span>')
22+ date = moment(msg.value.timestamp).fromNow()
23+ if (msg.value.content.type === 'post') {
24+ message = (msg.value.content.text)
2425 }
25- else if (msg.value.content.type === 'vote') {
26- message = ('I dug ' + msg.value.content.vote.link + ' - <span class="date">' + moment(msg.value.timestamp).fromNow() + '</span>')
26+ else if (msg.value.content.type === 'vote') {
27+ message = ('I dug ' + msg.value.content.vote.link)
2728 }
28- else if (msg.value.content.type === 'about') {
29- message = ('I identified ' + msg.value.content.about + ' as ' + msg.value.content.name + ' - <span class="date">' + moment(msg.value.timestamp).fromNow() + '</span>')
29+ else if (msg.value.content.type === 'about') {
30+ message = ('I identified ' + msg.value.content.about + ' as ' + msg.value.content.name)
3031 }
31- else if (msg.value.content.type === 'git-update') {
32- message = ('I pushed a git commit to <a href="http://gitmx.com/">gitmx.com</a> - <span class="date">' + moment(msg.value.timestamp).fromNow() + '</span>')
32+ else if (msg.value.content.type === 'git-update') {
33+ message = ('I pushed a commit ')
3334 }
34- else {
35- message = ('I sent a private message - <span class="date">' + moment(msg.value.timestamp).fromNow() + '</span>')
35+ else {
36+ message = ('I sent a private message ')
3637 }
3738 }));
38- var site = function () {
39- var layout =
40- html(
41- head(
42- title('Latest Sbot Post')
43- ),
44- body(
45- p(message)
46- )
47- );
48- return layout.outerHTML;
49- };
50- http.createServer(function (req, res) {
51- res.end(site());
52- }).listen(port, function () {
53- console.log(`Server running at http://localhost:${port}/`);
39+ app.use(router.routes())
40+ app.use(router.allowedMethods())
41+
42+ var render = views(__dirname, { ext: 'jade'});
43+
44+ router.get('/', function *(next) {
45+ this.body = yield render('index', {title: 'sdash', message, date});
5446 });
47+ app.listen(port);
5548 });
5649
57-
58-
index.jadeView
@@ -1,0 +1,9 @@
1+doctype html
2+html
3+ head
4+ title= title
5+ meta(charset='utf8')
6+ link(rel='stylesheet' href='http://evbogue.com/reserva/reserva.css')
7+ link(rel='stylesheet' href='http://evbogue.com/style.css')
8+ body
9+ p #{message} #{date} on <a href='https://gitmx.com/%25s9mSFATE4RGyJx9wgH22lBrvD4CgUQW4yeguSWWjtqc%3D.sha256' target='_new'>Patchbay</a>

Built with git-ssb-web