aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/app.js5
-rw-r--r--lib/render.js18
-rw-r--r--lib/serve.js61
3 files changed, 54 insertions, 30 deletions
diff --git a/lib/app.js b/lib/app.js
index da41459..643b317 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -56,6 +56,7 @@ function App(sbot, config) {
this.render = new Render(this, this.opts)
this.git = new Git(this)
+ this.contacts = new Contacts(this.sbot)
this.monitorBlobWants()
}
@@ -464,10 +465,6 @@ App.prototype.streamMyChannels = function (id, opts) {
)
}
-App.prototype.createContactStreams = function (id) {
- return new Contacts(this.sbot).createContactStreams(id)
-}
-
function compareVoted(a, b) {
return b.value - a.value
}
diff --git a/lib/render.js b/lib/render.js
index ed011bb..95c8c50 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -562,3 +562,21 @@ Render.prototype.npmPrebuildMention = function (link, opts, cb) {
]))
})
}
+
+Render.prototype.friendsList = function (prefix) {
+ prefix = prefix || '/'
+ var self = this
+ return pull(
+ paramap(function (id, cb) {
+ self.app.getAbout(id, function (err, about) {
+ var name = about && about.name || id.substr(0, 8) + '…'
+ cb(null, h('a', {href: self.toUrl(prefix + id)}, name))
+ })
+ }, 8),
+ pull.map(function (el) {
+ return [el, ' ']
+ }),
+ pull.flatten(),
+ pull.map(u.toHTML)
+ )
+}
diff --git a/lib/serve.js b/lib/serve.js
index 5b6aeff..c100f40 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -794,41 +794,29 @@ Serve.prototype.channels = function (ext) {
)
}
+function renderFriendsList(app) {
+}
+
Serve.prototype.contacts = function (path) {
var self = this
var id = String(path).substr(1)
- var contacts = self.app.createContactStreams(id)
-
- function renderFriendsList() {
- return pull(
- paramap(function (id, cb) {
- self.app.getAbout(id, function (err, about) {
- var name = about && about.name || id.substr(0, 8) + '…'
- cb(null, h('a', {href: self.app.render.toUrl('/contacts/' + id)}, name))
- })
- }, 8),
- pull.map(function (el) {
- return [el, ' ']
- }),
- pull.flatten(),
- pull.map(u.toHTML)
- )
- }
+ var contacts = self.app.contacts.createContactStreams(id)
+ var render = self.app.render
pull(
cat([
ph('section', {}, [
ph('h3', {}, ['Contacts: ', self.phIdLink(id)]),
ph('h4', {}, 'Friends'),
- renderFriendsList()(contacts.friends),
+ render.friendsList('/contacts/')(contacts.friends),
ph('h4', {}, 'Follows'),
- renderFriendsList()(contacts.follows),
+ render.friendsList('/contacts/')(contacts.follows),
ph('h4', {}, 'Followers'),
- renderFriendsList()(contacts.followers),
+ render.friendsList('/contacts/')(contacts.followers),
ph('h4', {}, 'Blocks'),
- renderFriendsList()(contacts.blocks),
+ render.friendsList('/contacts/')(contacts.blocks),
ph('h4', {}, 'Blocked by'),
- renderFriendsList()(contacts.blockers)
+ render.friendsList('/contacts/')(contacts.blockers)
])
]),
this.wrapPage('contacts: ' + id),
@@ -1537,6 +1525,21 @@ Serve.prototype.followInfo = function (id, myId) {
})
}
+Serve.prototype.friendInfo = function (id, myId) {
+ var first = false
+ return pull(
+ this.app.contacts.createFollowedFollowersStream(myId, id),
+ this.app.render.friendsList(),
+ pull.map(function (html) {
+ if (!first) {
+ first = true
+ return 'followed by your friends: ' + html
+ }
+ return html
+ })
+ )
+}
+
Serve.prototype.wrapUserFeed = function (isScrolled, id) {
var self = this
var myId = self.app.sbot.id
@@ -1581,10 +1584,16 @@ Serve.prototype.wrapUserFeed = function (isScrolled, id) {
])
)
]),
- isScrolled || id === myId ? '' : ph('tr', [
- ph('td'),
- ph('td', {class: 'follow-info'}, self.followInfo(id, myId))
- ])
+ isScrolled || id === myId ? '' : [
+ ph('tr', [
+ ph('td'),
+ ph('td', {class: 'follow-info'}, self.followInfo(id, myId))
+ ]),
+ ph('tr', [
+ ph('td'),
+ ph('td', self.friendInfo(id, myId))
+ ])
+ ]
])),
thread
])