From 47d16b17caff9dabdb02e246a9869527c06a6a92 Mon Sep 17 00:00:00 2001 From: cel Date: Tue, 30 May 2017 12:17:45 -1000 Subject: Add custom emojis list page --- lib/app.js | 20 ++++++++++++++++++++ lib/serve.js | 28 ++++++++++++++++++++++++++++ static/styles.css | 2 +- 3 files changed, 49 insertions(+), 1 deletion(-) 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) + ) +} diff --git a/static/styles.css b/static/styles.css index 3d513f2..4497f90 100644 --- a/static/styles.css +++ b/static/styles.css @@ -16,12 +16,12 @@ section { .ssb-post img { max-width: 100%; - background-color: #eee; } img.ssb-emoji { height: 1em; width: auto; + border: none; } .nav-bar { -- cgit v1.2.3