diff --git a/share/js/metadata.js b/share/js/metadata.js index 675b0d2..daf734a 100644 --- a/share/js/metadata.js +++ b/share/js/metadata.js @@ -53,16 +53,36 @@ function Metadata(modules) { ])]; } + function getContent(descendant) { + return descendant.content.replace(/:([^: ]+):/g, function(pattern, shortcode) { + var emoji = descendant.emojis.find(function(e) {return e.shortcode == shortcode;}); + if(emoji) { + return [ + ', shortcode, ' + ].join('"'); + } else { + return pattern; + } + }); + } + function render(comments) { return comments.descendants.map(function(descendant) { return modules.dom.make('li', {}, [ + modules.dom.make('a', {href: descendant.account.url}, [ + modules.dom.make('img', { + src: descendant.account.avatar, + alt: descendant.account.username + "'s profile picture" + }) + ]), modules.dom.make('div', { + class: "metadata", innerHTML: modules.template.render('metadata', { author: author(descendant.account.url, descendant.account.username), date: date(descendant.created_at) }) }), - modules.dom.make('div', {innerHTML: descendant.content}) + modules.dom.make('div', {innerHTML: getContent(descendant)}) ]); }); } @@ -103,6 +123,7 @@ function Metadata(modules) { function get(key) { return modules.dom.make('div', { + class: "metadata", innerHTML: modules.template.render('metadata', { author: author(key), date: date(key),