From 30a8c5cca2dd975a9976fd4819d5c45c1c64a8e1 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Wed, 12 Apr 2017 00:41:23 +0530 Subject: [PATCH] FIX: render emoji in topic title --- app/assets/javascripts/discourse/routes/topic.js.es6 | 2 +- app/serializers/topic_view_serializer.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/routes/topic.js.es6 b/app/assets/javascripts/discourse/routes/topic.js.es6 index 3fcb115fbf4..bcc266dc863 100644 --- a/app/assets/javascripts/discourse/routes/topic.js.es6 +++ b/app/assets/javascripts/discourse/routes/topic.js.es6 @@ -19,7 +19,7 @@ const TopicRoute = Discourse.Route.extend({ titleToken() { const model = this.modelFor('topic'); if (model) { - const result = model.get('title'), + const result = model.get('unicode_title') ? model.get('unicode_title') : model.get('title'), cat = model.get('category'); // Only display uncategorized in the title tag if it was renamed diff --git a/app/serializers/topic_view_serializer.rb b/app/serializers/topic_view_serializer.rb index 848c3e3f02e..802ccad671c 100644 --- a/app/serializers/topic_view_serializer.rb +++ b/app/serializers/topic_view_serializer.rb @@ -3,6 +3,7 @@ require_dependency 'new_post_manager' class TopicViewSerializer < ApplicationSerializer include PostStreamSerializerMixin + include ApplicationHelper def self.attributes_from_topic(*list) [list].flatten.each do |attribute| @@ -58,7 +59,8 @@ class TopicViewSerializer < ApplicationSerializer :message_archived, :tags, :featured_link, - :topic_status_update + :topic_status_update, + :unicode_title # TODO: Split off into proper object / serializer def details @@ -264,4 +266,12 @@ class TopicViewSerializer < ApplicationSerializer object.topic.featured_link end + def include_unicode_title? + !!(object.topic.title =~ /:([\w\-+]*):/) + end + + def unicode_title + gsub_emoji_to_unicode(object.topic.title) + end + end