aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-30 12:17:45 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-30 12:17:45 -1000
commit47d16b17caff9dabdb02e246a9869527c06a6a92 (patch)
treeed718dab1f10478f37f2c1cc7400189ce68ed931 /lib
parent04e050fadf375a002f0bb294bab795a4f9389e42 (diff)
downloadpatchfoo-47d16b17caff9dabdb02e246a9869527c06a6a92.tar.gz
patchfoo-47d16b17caff9dabdb02e246a9869527c06a6a92.zip
Add custom emojis list page
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)
+ )
+}