Commit f368d537f71a122079630895d2013828a6395e29
convert application to express to fix callbacks
Ev Bogue committed on 8/24/2016, 3:06:00 AMParent: 1503be3557df07c98b78eba410ce650a88778606
Files changed
index.js | changed |
package.json | changed |
index.jade | deleted |
views/index.jade | added |
index.js | ||
---|---|---|
@@ -1,47 +1,45 @@ | ||
1 | +var express = require('express'); | |
2 | +var pull = require('pull-stream'); | |
1 | 3 | var client = require('ssb-client'); |
2 | -var pull = require('pull-stream'); | |
3 | 4 | var avatar = require('ssb-avatar'); |
5 | +var markdown = require('marked'); | |
4 | 6 | 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'); | |
10 | 7 | |
11 | -const me = '@8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=.ed25519'; | |
12 | -const site = 'Evbogue.com'; | |
8 | +var me = '@8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=.ed25519'; | |
13 | 9 | |
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(); | |
20 | 11 | |
21 | -var render = views(__dirname, { ext: 'jade'}); | |
12 | +app.set('view engine', 'jade'); | |
22 | 13 | |
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) { | |
24 | 22 | client(function (err, sbot) { |
25 | 23 | if (err) { |
26 | 24 | throw err; |
27 | 25 | } |
28 | 26 | avatar(sbot, me, me, function (err, avatar){ |
29 | - if (err) { | |
27 | + if (err) { | |
30 | 28 | throw err; |
31 | 29 | } |
32 | 30 | name = avatar.name; |
33 | 31 | image = avatar.image; |
34 | 32 | }) |
35 | 33 | pull( |
36 | 34 | 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) { | |
38 | 36 | post = data; |
39 | 37 | }) |
40 | 38 | ) |
41 | 39 | pull( |
42 | 40 | 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) { | |
44 | 42 | vote = data; |
45 | 43 | pull( |
46 | 44 | sbot.query.read({query: [{$filter: { key: data.value.content.vote.link}}]}), |
47 | 45 | pull.drain(function (reblog) { |
@@ -49,22 +47,27 @@ | ||
49 | 47 | if (err) { |
50 | 48 | throw err; |
51 | 49 | } |
52 | 50 | reauthor = avatar; |
51 | + gotPost(); | |
53 | 52 | }) |
54 | 53 | redo = reblog; |
55 | 54 | }) |
56 | 55 | ) |
57 | 56 | }) |
58 | 57 | ) |
59 | 58 | pull( |
60 | 59 | 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) { | |
62 | 61 | gits = data; |
63 | 62 | }) |
64 | 63 | ) |
65 | 64 | }); |
66 | - this.body = yield render('index', {title: site, moment, markdown}); | |
65 | + function gotPost() { | |
66 | + res.render('index', { title: 'Evbogue.com', markdown, moment}); | |
67 | + } | |
67 | 68 | }); |
68 | 69 | |
69 | -app.listen('7000') | |
70 | 70 | |
71 | +app.listen('8000'); | |
72 | + | |
73 | + |
package.json | ||
---|---|---|
@@ -1,18 +1,14 @@ | ||
1 | 1 | { |
2 | 2 | "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", | |
5 | 5 | "main": "index.js", |
6 | 6 | "dependencies": { |
7 | - "co-views": "^2.1.0", | |
7 | + "express": "^4.14.0", | |
8 | 8 | "jade": "^1.11.0", |
9 | - "koa": "^1.2.1", | |
10 | - "koa-router": "^5.4.0", | |
11 | - "koa-static": "^2.0.0", | |
12 | 9 | "marked": "^0.3.6", |
13 | 10 | "moment": "^2.14.1", |
14 | - "pull-paramap": "^1.1.6", | |
15 | 11 | "pull-stream": "^3.4.3", |
16 | 12 | "ssb-avatar": "^0.1.0", |
17 | 13 | "ssb-client": "^4.0.3" |
18 | 14 | }, |
index.jade | ||
---|---|---|
@@ -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.jade | ||
---|---|---|
@@ -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