aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/serve.js135
1 files changed, 79 insertions, 56 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 6d3786d..d709cbd 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -1469,6 +1469,16 @@ Serve.prototype.phIdLink = function (id) {
)
}
+Serve.prototype.phIdAvatar = function (id) {
+ var self = this
+ return u.readNext(function (cb) {
+ var el = self.app.render.avatarImage(id, function (err) {
+ if (err) return cb(err)
+ cb(null, pull.once(u.toHTML(el)))
+ })
+ })
+}
+
Serve.prototype.friends = function (path) {
var self = this
pull(
@@ -1502,71 +1512,84 @@ Serve.prototype.renderIdsList = function () {
)
}
-Serve.prototype.wrapUserFeed = function (isScrolled, id) {
+Serve.prototype.aboutDescription = function (id) {
var self = this
- var myId = self.app.sbot.id
- var render = self.app.render
- return u.hyperwrap(function (thread, cb) {
+ return u.readNext(function (cb) {
+ self.app.getAbout(id, function (err, about) {
+ if (err) return cb(err)
+ if (!about.description) return cb(null, pull.empty())
+ cb(null, ph('div', self.app.render.markdown(about.description)))
+ })
+ })
+}
+
+Serve.prototype.followInfo = function (id, myId) {
+ var self = this
+ return u.readNext(function (cb) {
var done = multicb({pluck: 1, spread: true})
- self.app.getAbout(id, done())
self.app.getContact(myId, id, done())
self.app.getContact(id, myId, done())
- done(function (err, about, contactToThem, contactFromThem) {
+ done(function (err, contactToThem, contactFromThem) {
if (err) return cb(err)
- var done = multicb({pluck: 1, spread: true})
- done()(null, [
- h('section.ssb-feed',
- h('table', h('tr',
- h('td', self.app.render.avatarImage(id, done())),
- h('td.feed-about',
- h('h3.feed-name',
- h('strong', self.app.render.idLink(id, done()))),
- h('code', h('small', id)),
- about.description ? h('div',
- {innerHTML: self.app.render.markdown(about.description)}) : ''
- )),
- h('tr',
- h('td'),
- h('td',
- h('a', {href: render.toUrl('/contacts/' + id)}, 'contacts'), ' ',
- h('a', {href: render.toUrl('/about/' + id)}, 'about')
- )
- ),
- h('tr',
- h('td'),
- h('td',
- h('form', {action: render.toUrl('/advsearch'), method: 'get'},
- h('input', {type: 'hidden', name: 'source', value: id}),
- h('input', {type: 'text', name: 'text', placeholder: 'text'}),
- h('input', {type: 'submit', value: 'search'})
- )
- )
- ),
- isScrolled ? '' : [
- id === myId ? '' : h('tr',
- h('td'),
- h('td.follow-info', h('form', {action: '', method: 'post'},
- contactFromThem ? contactToThem ? 'friend ' : 'follows you ' :
- contactFromThem === false ? 'blocks you ' : '',
- h('input', {type: 'hidden', name: 'action', value: 'contact'}),
- h('input', {type: 'hidden', name: 'contact', value: id}),
- h('input', {type: 'submit',
- name: contactToThem ? 'unfollow' : 'follow',
- value: contactToThem ? 'unfollow' : 'follow'}), ' ',
- h('input', {type: 'submit',
- name: contactToThem === false ? 'unblock' : 'block',
- value: contactToThem === false ? 'unblock' : 'block'})
- ))
- )
- ]
- )),
- thread
- ])
- done(cb)
+ cb(null, ph('form', {action: '', method: 'post'}, [
+ contactFromThem ? contactToThem ? 'friend ' : 'follows you ' :
+ contactFromThem === false ? 'blocks you ' : '',
+ ph('input', {type: 'hidden', name: 'action', value: 'contact'}),
+ ph('input', {type: 'hidden', name: 'contact', value: id}),
+ ph('input', {type: 'submit',
+ name: contactToThem ? 'unfollow' : 'follow',
+ value: contactToThem ? 'unfollow' : 'follow'}), ' ',
+ ph('input', {type: 'submit',
+ name: contactToThem === false ? 'unblock' : 'block',
+ value: contactToThem === false ? 'unblock' : 'block'})
+ ]))
})
})
}
+Serve.prototype.wrapUserFeed = function (isScrolled, id) {
+ var self = this
+ var myId = self.app.sbot.id
+ var render = self.app.render
+ return function (thread) {
+ return cat([
+ ph('section', {class: 'ssb-feed'}, ph('table', [
+ isScrolled ? '' : ph('tr', [
+ ph('td', self.phIdAvatar(id)),
+ ph('td', {class: 'feed-about'}, [
+ ph('h3', {class: 'feed-name'},
+ ph('strong', self.phIdLink(id))),
+ ph('code', ph('small', id)),
+ self.aboutDescription(id)
+ ])
+ ]),
+ ph('tr', [
+ ph('td'),
+ ph('td', [
+ ph('a', {href: render.toUrl('/contacts/' + id)}, 'contacts'), ' ',
+ ph('a', {href: render.toUrl('/about/' + id)}, 'about')
+ ])
+ ]),
+ ph('tr', [
+ ph('td'),
+ ph('td',
+ ph('form', {action: render.toUrl('/advsearch'), method: 'get'}, [
+ ph('input', {type: 'hidden', name: 'source', value: id}),
+ ph('input', {type: 'text', name: 'text', placeholder: 'text'}),
+ ph('input', {type: 'submit', value: 'search'})
+ ])
+ )
+ ]),
+ isScrolled || id === myId ? '' : ph('tr', [
+ ph('td'),
+ ph('td', {class: 'follow-info'}, self.followInfo(id, myId))
+ ])
+ ])),
+ thread
+ ])
+ }
+}
+
Serve.prototype.git = function (url) {
var m = /^\/?([^\/]*)\/?(.*)?$/.exec(url)
switch (m[1]) {