diff options
author | cel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519> | 2020-06-16 11:36:42 -0400 |
---|---|---|
committer | cel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519> | 2020-06-16 11:36:42 -0400 |
commit | 06ecfbd12372fae439762d4610b0b7b4b97068d4 (patch) | |
tree | 616bfa8ba3133b33bfbea80f89da1a16b07662ec | |
parent | 31a4c41338cc7e76dddf93aae3d5c8ebd019cb53 (diff) | |
download | patchfoo-06ecfbd12372fae439762d4610b0b7b4b97068d4.tar.gz patchfoo-06ecfbd12372fae439762d4610b0b7b4b97068d4.zip |
Remove proprietary emoji
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | lib/render.js | 12 | ||||
-rw-r--r-- | lib/serve.js | 41 | ||||
-rw-r--r-- | package.json | 2 |
4 files changed, 3 insertions, 53 deletions
@@ -114,7 +114,6 @@ To make config options persistent, set them in `~/.ssb/config`, e.g.: - `base`: base url that the app is running at. default: `/` - `blob_base`: base url for links to ssb blobs. default: same as `base` - `img_base`: base url for blobs embedded as images. default: same as `base` -- `emoji_base`: base url for emoji images. default: same as `base` - `encode_msgids`: whether to URL-encode message ids in local links. default: `true` - `auth`: HTTP auth password. default: `null` (no password required) - `allowAddresses`: Array of IP addresses allowed to connect. default: `null` (allow any to connect). Note if host is `localhost` then this setting is useless. diff --git a/lib/render.js b/lib/render.js index 7f6cba5..228eed0 100644 --- a/lib/render.js +++ b/lib/render.js @@ -6,7 +6,6 @@ var paramap = require('pull-paramap') var h = require('hyperscript') var ph = require('pull-hyperscript') var marked = require('ssb-marked') -var emojis = require('emoji-named-characters') var qs = require('querystring') var u = require('./util') var multicb = require('multicb') @@ -162,15 +161,6 @@ Render.prototype.emoji = function (emoji) { title: name, }) } - if (emoji in emojis) { - return h('img.ssb-emoji', { - src: this.opts.emoji_base + emoji + '.png', - alt: name, - height: 17, - align: 'absmiddle', - title: name, - }) - } return name } @@ -303,7 +293,7 @@ Render.prototype.toUrl = function (href) { } Render.prototype.lockIcon = function () { - return this.emoji('lock') + return '🔒' } Render.prototype.avatarImage = function (link, cb) { diff --git a/lib/serve.js b/lib/serve.js index d292158..c7065bc 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -6,7 +6,6 @@ var paramap = require('pull-paramap') var sort = require('ssb-sort') var crypto = require('crypto') var toPull = require('stream-to-pull-stream') -var serveEmoji = require('emoji-server')() var u = require('./util') var cat = require('pull-cat') var h = require('hyperscript') @@ -19,7 +18,6 @@ var mime = require('mime-types') var ident = require('pull-identify-filetype') var htime = require('human-time') var ph = require('pull-hyperscript') -var emojis = require('emoji-named-characters') var jpeg = require('jpeg-autorotate') var Catch = require('pull-catch') var Diff = require('diff') @@ -30,7 +28,6 @@ var Url = require('url') module.exports = Serve -var emojiDir = path.join(require.resolve('emoji-named-characters'), '../pngs') var hlCssDir = path.join(require.resolve('highlight.js'), '../../styles') var urlIdRegex = /^(?:\/+(([%&@]|%25|%26)(?:[A-Za-z0-9\/+]|%2[Ff]|%2[Bb]){43}(?:=|%3D)\.(?:sha256|ed25519))([^?]*)?|(\/.*?))(?:\?(.*))?$/ @@ -539,7 +536,6 @@ Serve.prototype.path = function (url) { case '/type': return this.type(m[2]) case '/links': return this.links(m[2]) case '/static': return this.static(m[2]) - case '/emoji': return this.emoji(m[2]) case '/highlight': return this.highlight(m[2]) case '/contacts': return this.contacts(m[2]) case '/about': return this.about(m[2]) @@ -2066,10 +2062,6 @@ Serve.prototype.static = function (file) { this.file(path.join(__dirname, '../static', file)) } -Serve.prototype.emoji = function (emoji) { - serveEmoji(this.req, this.res, emoji) -} - Serve.prototype.highlight = function (dirs) { this.file(path.join(hlCssDir, dirs)) } @@ -4345,12 +4337,6 @@ Serve.prototype.composer = function (opts, cb) { var id = formEmojiNames[name] if (id) return {name: name, id: id} // 2. TODO: check user's preferred emoji-image mapping - // 3. check builtin emoji - var link = self.getBuiltinEmojiLink(name) - if (link) { - return {name: name, id: link.link} - blobs[id] = {type: link.type, size: link.size} - } // 4. check recently seen emoji id = self.app.getReverseEmojiNameSync(name) return {name: name, id: id} @@ -4529,15 +4515,8 @@ Serve.prototype.composer = function (opts, cb) { if (mention.emoji) { mention.link = formEmojiNames[mention.name] if (!mention.link) { - var link = self.getBuiltinEmojiLink(mention.name) - if (link) { - mention.link = link.link - mention.size = link.size - mention.type = link.type - } else { - mention.link = self.app.getReverseEmojiNameSync(mention.name) - if (!mention.link) return false - } + mention.link = self.app.getReverseEmojiNameSync(mention.name) + if (!mention.link) return false } } var blob = blobs[mention.link] @@ -4887,22 +4866,6 @@ function hashBuf(buf) { return '&' + hash.digest('base64') + '.sha256' } -Serve.prototype.getBuiltinEmojiLink = function (name) { - if (!(name in emojis)) return - var file = path.join(emojiDir, name + '.png') - var fileBuf = fs.readFileSync(file) - var id = hashBuf(fileBuf) - // seed the builtin emoji - pull(pull.once(fileBuf), this.app.sbot.blobs.add(id, function (err) { - if (err) console.error('error adding builtin emoji as blob', err) - })) - return { - link: id, - type: 'image/png', - size: fileBuf.length, - } -} - Serve.prototype.getMsgDecryptedMaybeOoo = function (key, cb) { var self = this if (this.useOoo) this.app.getMsgDecryptedOoo(key, next) diff --git a/package.json b/package.json index ef8b4c7..4ce3e31 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,6 @@ "base64-url": "^2.0.0", "busboy": "^0.2.14", "diff": "^3.3.1", - "emoji-named-characters": "^1.0.2", - "emoji-server": "^1.0.0", "hashlru": "^2.1.0", "highlight.js": "^9.12.0", "human-time": "^0.0.1", |