git ssb

3+

ev / sdash



Commit f368d537f71a122079630895d2013828a6395e29

convert application to express to fix callbacks

Ev Bogue committed on 8/24/2016, 3:06:00 AM
Parent: 1503be3557df07c98b78eba410ce650a88778606

Files changed

index.jschanged
package.jsonchanged
index.jadedeleted
views/index.jadeadded
index.jsView
@@ -1,47 +1,45 @@
1+var express = require('express');
2+var pull = require('pull-stream');
13 var client = require('ssb-client');
2-var pull = require('pull-stream');
34 var avatar = require('ssb-avatar');
5+var markdown = require('marked');
46 var moment = require('moment');
5-var markdown = require('marked');
6-var app = require('koa')();
7-var router = require('koa-router')();
8-var serve = require('koa-static');
9-var views = require('co-views');
107
11-const me = '@8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=.ed25519';
12-const site = 'Evbogue.com';
8+var me = '@8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=.ed25519';
139
14-app.use(router.routes())
15-app.use(serve(__dirname + '/static'))
16-app.use(serve(__dirname + './../books/build'))
17-app.use(serve(__dirname + './../site/build'))
18-app.use(serve(__dirname + './../site/static'))
19-app.use(serve(__dirname + './../boot/'))
10+var app = express();
2011
21-var render = views(__dirname, { ext: 'jade'});
12+app.set('view engine', 'jade');
2213
23-router.get('/', function *(next) {
14+
15+app.use(express.static('static'));
16+app.use(express.static('../../books/build'));
17+app.use(express.static('../../site/build'));
18+app.use(express.static('../../site/static'));
19+app.use(express.static('../../boot'));
20+
21+app.get('/', function (req, res) {
2422 client(function (err, sbot) {
2523 if (err) {
2624 throw err;
2725 }
2826 avatar(sbot, me, me, function (err, avatar){
29- if (err) {
27+ if (err) {
3028 throw err;
3129 }
3230 name = avatar.name;
3331 image = avatar.image;
3432 })
3533 pull(
3634 sbot.query.read({query: [{$filter: { value: { author: me, content: {type: 'post'}}}}], limit: 1, reverse: true}),
37- pull.drain(function (data) {
35+ pull.drain(function (data) {
3836 post = data;
3937 })
4038 )
4139 pull(
4240 sbot.query.read({query: [{$filter: { value: { author: me, content: {type: 'vote'}}}}], limit: 1, reverse: true}),
43- pull.drain(function (data) {
41+ pull.drain(function (data) {
4442 vote = data;
4543 pull(
4644 sbot.query.read({query: [{$filter: { key: data.value.content.vote.link}}]}),
4745 pull.drain(function (reblog) {
@@ -49,22 +47,27 @@
4947 if (err) {
5048 throw err;
5149 }
5250 reauthor = avatar;
51+ gotPost();
5352 })
5453 redo = reblog;
5554 })
5655 )
5756 })
5857 )
5958 pull(
6059 sbot.query.read({query: [{$filter: { value: { author: me, content: {type: 'git-update'}}}}], limit: 1, reverse: true}),
61- pull.drain(function (data) {
60+ pull.drain(function (data) {
6261 gits = data;
6362 })
6463 )
6564 });
66- this.body = yield render('index', {title: site, moment, markdown});
65+ function gotPost() {
66+ res.render('index', { title: 'Evbogue.com', markdown, moment});
67+ }
6768 });
6869
69-app.listen('7000')
7070
71+app.listen('8000');
72+
73+
package.jsonView
@@ -1,18 +1,14 @@
11 {
22 "name": "sdash",
3- "version": "0.0.1",
4- "description": "grab your latest sbot post and put it on your website using an iFrame",
3+ "version": "1.1.0",
4+ "description": "express app for grabbing sbot posts and tossing them onto your site",
55 "main": "index.js",
66 "dependencies": {
7- "co-views": "^2.1.0",
7+ "express": "^4.14.0",
88 "jade": "^1.11.0",
9- "koa": "^1.2.1",
10- "koa-router": "^5.4.0",
11- "koa-static": "^2.0.0",
129 "marked": "^0.3.6",
1310 "moment": "^2.14.1",
14- "pull-paramap": "^1.1.6",
1511 "pull-stream": "^3.4.3",
1612 "ssb-avatar": "^0.1.0",
1713 "ssb-client": "^4.0.3"
1814 },
index.jadeView
@@ -1,33 +1,0 @@
1-doctype html
2-html
3- head
4- title= title
5- meta(charset='utf8')
6- link(rel='stylesheet' href='https://evbogue.com/reserva/reserva.css')
7- link(rel='stylesheet' href='https://evbogue.com/style.css')
8- link(rel='stylesheet' href='/sdash.css')
9- body
10- .contain
11- .eight.col.off-two
12- a(href='/'): h1= title
13- hr
14- div(class='message')
15- img(src='https://evbogue.com/ws/blobs/get/#{image}' class='avatar')
16- p <a href='http://evbogue.com/' target='_parent'>@#{name}</a>
17- != markdown(post.value.content.text)
18- span.date #{moment(post.value.timestamp).fromNow()}
19- div(class='message')
20- img(src='https://evbogue.com/ws/blobs/get/#{image}' class='avatar')
21- p <a href='http://evbogue.com/' target='_parent'>@#{name}</a> dug #{vote.value.content.vote.link}
22- span.date #{moment(vote.value.timestamp).fromNow()}
23- div.message
24- img(src='https://evbogue.com/ws/blobs/get/#{reauthor.image}' class='avatar')
25- p @<a href='#{redo.value.author}'>#{reauthor.name}</a>
26- != markdown(redo.value.content.text)
27- span.date #{moment(redo.value.timestamp).fromNow()}
28- div(class='message')
29- img(src='https://evbogue.com/ws/blobs/get/#{image}' class='avatar')
30- p <a href='http://evbogue.com/' target='_parent'>@#{name}</a> pushed a git commit to #{gits.value.content.repo}<br />
31- span.date #{moment(gits.value.timestamp).fromNow()}
32- hr
33- p(style='font-size: .8em') <a href='mailto:ev@evbogue.com'>ev@evbogue.com</a> | <a href='/minimalist'>The Art of Being Minimalist</a> | <a href='/node'>Minimal Node</a> | <a href='https://gitmx.com/%408Qee0I%2FDwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc%3D.ed25519'>GitMX</a> | Mexico City
views/index.jadeView
@@ -1,0 +1,32 @@
1+doctype html
2+html
3+ head
4+ title= title
5+ meta(charset='utf8')
6+ link(rel='stylesheet' href='https://evbogue.com/reserva/reserva.css')
7+ link(rel='stylesheet' href='https://evbogue.com/style.css')
8+ body
9+ .contain
10+ .eight.col.off-two
11+ a(href='/'): h1= title
12+ hr
13+ div(class='message')
14+ img(src='https://evbogue.com/ws/blobs/get/#{image}' class='avatar')
15+ p <a href='http://evbogue.com/' target='_parent'>@#{name}</a>
16+ != markdown(post.value.content.text)
17+ span.date #{moment(post.value.timestamp).fromNow()}
18+ div(class='message')
19+ img(src='https://evbogue.com/ws/blobs/get/#{image}' class='avatar')
20+ p <a href='http://evbogue.com/' target='_parent'>@#{name}</a> dug #{vote.value.content.vote.link}
21+ span.date #{moment(vote.value.timestamp).fromNow()}
22+ div.message
23+ img(src='https://evbogue.com/ws/blobs/get/#{reauthor.image}' class='avatar')
24+ p @<a href='#{redo.value.author}'>#{reauthor.name}</a>
25+ != markdown(redo.value.content.text)
26+ span.date #{moment(redo.value.timestamp).fromNow()}
27+ div(class='message')
28+ img(src='https://evbogue.com/ws/blobs/get/#{image}' class='avatar')
29+ p <a href='http://evbogue.com/' target='_parent'>@#{name}</a> pushed a git commit to #{gits.value.content.repo}<br />
30+ span.date #{moment(gits.value.timestamp).fromNow()}
31+ hr
32+ p(style='font-size: .8em') <a href='mailto:ev@evbogue.com'>ev@evbogue.com</a> | <a href='/minimalist'>The Art of Being Minimalist</a> | <a href='/node'>Minimal Node</a> | <a href='https://gitmx.com/%408Qee0I%2FDwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc%3D.ed25519'>GitMX</a> | Mexico City

Built with git-ssb-web