FIX: supports emojis in pinned topic excerpt

This commit is contained in:
Joffrey JAFFEUX 2017-09-07 11:06:04 +02:00 committed by GitHub
parent c9912fcc37
commit dd27c0c80e
3 changed files with 13 additions and 1 deletions

View File

@ -407,6 +407,10 @@ const Topic = RestModel.extend({
}); });
}, },
@computed('excerpt')
escapedExcerpt(excerpt) {
return emojiUnescape(excerpt);
},
hasExcerpt: Em.computed.notEmpty('excerpt'), hasExcerpt: Em.computed.notEmpty('excerpt'),

View File

@ -1,6 +1,6 @@
{{#if topic.hasExcerpt}} {{#if topic.hasExcerpt}}
<div class="topic-excerpt"> <div class="topic-excerpt">
{{{topic.excerpt}}} {{{topic.escapedExcerpt}}}
{{#if topic.excerptTruncated}} {{#if topic.excerptTruncated}}
<a href="{{topic.url}}">{{i18n 'read_more'}}</a> <a href="{{topic.url}}">{{i18n 'read_more'}}</a>
{{/if}} {{/if}}

View File

@ -75,3 +75,11 @@ QUnit.test('fancyTitle', assert => {
`<img src='/images/emoji/emoji_one/smile.png?v=${v}' title='smile' alt='smile' class='emoji'> with all <img src='/images/emoji/emoji_one/slight_smile.png?v=${v}' title='slight_smile' alt='slight_smile' class='emoji'> the emojis <img src='/images/emoji/emoji_one/pear.png?v=${v}' title='pear' alt='pear' class='emoji'><img src='/images/emoji/emoji_one/peach.png?v=${v}' title='peach' alt='peach' class='emoji'>`, `<img src='/images/emoji/emoji_one/smile.png?v=${v}' title='smile' alt='smile' class='emoji'> with all <img src='/images/emoji/emoji_one/slight_smile.png?v=${v}' title='slight_smile' alt='slight_smile' class='emoji'> the emojis <img src='/images/emoji/emoji_one/pear.png?v=${v}' title='pear' alt='pear' class='emoji'><img src='/images/emoji/emoji_one/peach.png?v=${v}' title='peach' alt='peach' class='emoji'>`,
"supports emojis"); "supports emojis");
}); });
QUnit.test('excerpt', assert => {
var topic = Topic.create({ excerpt: "This is a test topic :smile:", pinned: true });
assert.equal(topic.get('escapedExcerpt'),
`This is a test topic <img src='/images/emoji/emoji_one/smile.png?v=${v}' title='smile' alt='smile' class='emoji'>`,
"supports emojis");
});