aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/app.js20
-rw-r--r--lib/serve.js28
2 files changed, 48 insertions, 0 deletions
diff --git a/lib/app.js b/lib/app.js
index 10a8a07..d86b4b9 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -12,6 +12,7 @@ var About = require('./about')
var Serve = require('./serve')
var Render = require('./render')
var Git = require('./git')
+var cat = require('pull-cat')
module.exports = App
@@ -380,3 +381,22 @@ App.prototype.createContactStreams = function (id) {
App.prototype.createAboutStreams = function (id) {
return this.about.createAboutStreams(id)
}
+
+App.prototype.streamEmojis = function () {
+ return pull(
+ cat([
+ this.sbot.links({
+ rel: 'mentions',
+ source: this.sbot.id,
+ dest: '&',
+ values: true
+ }),
+ this.sbot.links({rel: 'mentions', dest: '&', values: true})
+ ]),
+ this.unboxMessages(),
+ pull.map(function (msg) { return msg.value.content.mentions }),
+ pull.flatten(),
+ pull.filter('emoji'),
+ pull.unique('link')
+ )
+}
diff --git a/lib/serve.js b/lib/serve.js
index 1b1ab0a..b6a058a 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -268,6 +268,7 @@ Serve.prototype.path = function (url) {
case '/friends': return this.friends(m[2])
case '/live': return this.live(m[2])
case '/compose': return this.compose(m[2])
+ case '/emojis': return this.emojis(m[2])
}
m = /^(\/?[^\/]*)(\/.*)?$/.exec(url)
switch (m[1]) {
@@ -1142,6 +1143,7 @@ Serve.prototype.wrapPage = function (title, searchQ) {
h('a', {href: render.toUrl('/advsearch')}, 'search'), ' ',
h('a', {href: render.toUrl('/live')}, 'live'), ' ',
h('a', {href: render.toUrl('/compose')}, 'compose'), ' ',
+ h('a', {href: render.toUrl('/emojis')}, 'emojis'), ' ',
render.idLink(self.app.sbot.id, done()), ' ',
h('input.search-input', {name: 'q', value: searchQ,
placeholder: 'search'})
@@ -2169,3 +2171,29 @@ Serve.prototype.composer = function (opts, cb) {
}
}
+
+Serve.prototype.emojis = function (path) {
+ var self = this
+ pull(
+ ph('section', [
+ ph('h3', 'Emojis'),
+ ph('ul', {class: 'mentions'}, pull(
+ self.app.streamEmojis(),
+ pull.map(function (emoji) {
+ return ph('li', [
+ ph('a', {href: self.app.render.toUrl('/links/' + emoji.link)},
+ ph('img', {
+ class: 'ssb-emoji',
+ src: self.app.render.imageUrl(emoji.link),
+ size: 32,
+ })
+ ), ' ',
+ u.escapeHTML(emoji.name)
+ ])
+ })
+ ))
+ ]),
+ this.wrapPage('emojis'),
+ this.respondSink(200)
+ )
+}