git ssb

3+

ev / sdash



Tree: 6ee08c886d159cf6ec378309b83e8df76e5b24d9

Files: 6ee08c886d159cf6ec378309b83e8df76e5b24d9 / index.js

2967 bytesRaw
1var express = require('express');
2var pull = require('pull-stream');
3var client = require('ssb-client');
4var avatar = require('ssb-avatar');
5var markdown = require('marked');
6var favicon = require('serve-favicon');
7var moment = require('moment');
8
9var me = '@8Qee0I/DwI5DHSCi3p5fsl6FyLGArrnDz3ox9qZr5Qc=.ed25519';
10
11var bloburl = 'http://localhost:8989/blobs/get/';
12
13var app = express();
14
15app.set('views', './layouts')
16app.set('view engine', 'jade');
17
18app.use(express.static('static'));
19app.use(favicon(__dirname + '/static/favicon.ico'));
20
21app.get('/:key', function (req, res) {
22 client(function (err, sbot) {
23 if (err) {
24 throw err;
25 }
26 avatar(sbot, me, req.params.key, function (err, avatar){
27 if (err) {
28 throw err;
29 }
30 key = req.params.key;
31 pull(
32 sbot.query.read({query: [{$filter: { value: { author: key, content: {type: 'post'}}}}], limit: 1, reverse: true}),
33 pull.drain(function (data) {
34 post = data;
35 gotPost()
36 })
37 )
38 function gotPost() {
39 res.render('profile', {avatar, bloburl, key, markdown, moment});
40 }
41 })
42 })
43});
44
45app.get('/', function (req, res) {
46 client(function (err, sbot) {
47 if (err) {
48 throw err;
49 }
50 avatar(sbot, me, me, function (err, avatar){
51 if (err) {
52 throw err;
53 }
54 name = avatar.name;
55 image = avatar.image;
56 })
57 pull(
58 sbot.query.read({query: [{$filter: { value: { author: me, content: {type: 'pin'}}}}], limit: 1, reverse: true}),
59 pull.drain(function (data) {
60 getpin = data;
61 pull(
62 sbot.query.read({query: [{$filter: { key: getpin.value.content.link}}]}),
63 pull.drain(function (data) {
64 pinned = data;
65 })
66 )
67 })
68 )
69 pull(
70 sbot.query.read({query: [{$filter: { value: { author: me, content: {type: 'post'}}}}], limit: 1, reverse: true}),
71 pull.drain(function (data) {
72 post = data;
73 })
74 )
75 pull(
76 sbot.query.read({query: [{$filter: { value: { author: me, content: {type: 'vote'}}}}], limit: 1, reverse: true}),
77 pull.drain(function (data) {
78 vote = data;
79 pull(
80 sbot.query.read({query: [{$filter: { key: data.value.content.vote.link}}]}),
81 pull.drain(function (reblog) {
82 avatar(sbot, me, reblog.value.author, function (err, avatar){
83 if (err) {
84 throw err;
85 }
86 reauthor = avatar;
87 gotPost();
88 })
89 redo = reblog;
90 })
91 )
92 })
93 )
94 pull(
95 sbot.query.read({query: [{$filter: { value: { author: me, content: {type: 'git-update'}}}}], limit: 1, reverse: true}),
96 pull.drain(function (data) {
97 gits = data;
98 })
99 )
100 });
101 function gotPost() {
102 res.render('index', { title: 'Evbogue.com', markdown, moment, bloburl});
103 }
104});
105
106app.listen('7000');
107

Built with git-ssb-web