FIX: render emoji in topic title

This commit is contained in:
Arpit Jalan 2017-04-12 00:41:23 +05:30
parent 3a235d1241
commit 1c1b36ad14
2 changed files with 12 additions and 2 deletions

View File

@ -19,7 +19,7 @@ const TopicRoute = Discourse.Route.extend({
titleToken() { titleToken() {
const model = this.modelFor('topic'); const model = this.modelFor('topic');
if (model) { if (model) {
const result = model.get('title'), const result = model.get('unicode_title') ? model.get('unicode_title') : model.get('title'),
cat = model.get('category'); cat = model.get('category');
// Only display uncategorized in the title tag if it was renamed // Only display uncategorized in the title tag if it was renamed

View File

@ -3,6 +3,7 @@ require_dependency 'new_post_manager'
class TopicViewSerializer < ApplicationSerializer class TopicViewSerializer < ApplicationSerializer
include PostStreamSerializerMixin include PostStreamSerializerMixin
include ApplicationHelper
def self.attributes_from_topic(*list) def self.attributes_from_topic(*list)
[list].flatten.each do |attribute| [list].flatten.each do |attribute|
@ -58,7 +59,8 @@ class TopicViewSerializer < ApplicationSerializer
:message_archived, :message_archived,
:tags, :tags,
:featured_link, :featured_link,
:topic_status_update :topic_status_update,
:unicode_title
# TODO: Split off into proper object / serializer # TODO: Split off into proper object / serializer
def details def details
@ -264,4 +266,12 @@ class TopicViewSerializer < ApplicationSerializer
object.topic.featured_link object.topic.featured_link
end end
def include_unicode_title?
!!(object.topic.title =~ /:([\w\-+]*):/)
end
def unicode_title
gsub_emoji_to_unicode(object.topic.title)
end
end end