From bf146b14e02f6e1188a8c37b70a29f882f0c75e1 Mon Sep 17 00:00:00 2001 From: cel Date: Wed, 4 Jul 2018 16:23:35 -1000 Subject: Add tags page --- lib/app.js | 10 ++++++++++ lib/serve.js | 19 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/app.js b/lib/app.js index 31ef492..ca9b6b2 100644 --- a/lib/app.js +++ b/lib/app.js @@ -500,6 +500,16 @@ App.prototype.streamMyChannels = function (id, opts) { ) } +App.prototype.streamTags = function () { + return pull( + this.sbot.messagesByType({type: 'tag', reverse: true}), + this.unboxMessages(), + pull.filter(function (msg) { + return !msg.value.content.message + }) + ) +} + function compareVoted(a, b) { return b.value - a.value } diff --git a/lib/serve.js b/lib/serve.js index 3c9334f..db99b49 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -352,6 +352,7 @@ Serve.prototype.path = function (url) { case '/peers': return this.peers(m[2]) case '/status': return this.status(m[2]) case '/channels': return this.channels(m[2]) + case '/tags': return this.tags(m[2]) case '/friends': return this.friends(m[2]) case '/live': return this.live(m[2]) case '/compose': return this.compose(m[2]) @@ -849,7 +850,22 @@ Serve.prototype.channels = function (ext) { ) } -function renderFriendsList(app) { +Serve.prototype.tags = function (path) { + var self = this + var seen = {} + pull( + ph('section', [ + ph('h3', 'Tags'), + pull( + self.app.streamTags(), + pull.map(function (msg) { + return [self.phIdLink(msg.key), ' '] + }) + ) + ]), + this.wrapPage('tags'), + this.respondSink(200) + ) } Serve.prototype.contacts = function (path) { @@ -1508,6 +1524,7 @@ Serve.prototype.wrapPage = function (title, searchQ) { self.app.sbot.status ? [h('a', {href: render.toUrl('/status')}, 'status'), ' '] : '', h('a', {href: render.toUrl('/channels')}, 'channels') , ' ', + h('a', {href: render.toUrl('/tags')}, 'tags') , ' ', h('a', {href: render.toUrl('/friends')}, 'friends'), ' ', h('a', {href: render.toUrl('/advsearch')}, 'search'), ' ', h('a', {href: render.toUrl('/live')}, 'live'), ' ', -- cgit v1.2.3