FIX: unescape emojis in digests

This commit is contained in:
Régis Hanol 2015-10-15 09:59:29 +02:00
parent 03f9668d60
commit 73e345fe8f
3 changed files with 14 additions and 2 deletions

View File

@ -74,6 +74,10 @@ module ApplicationHelper
end end
end end
def unescape_emoji(title)
PrettyText.unescape_emoji(title)
end
def with_format(format, &block) def with_format(format, &block)
old_formats = formats old_formats = formats
self.formats = [format] self.formats = [format]

View File

@ -20,7 +20,7 @@
<%- @featured_topics.each_with_index do |t, i| %> <%- @featured_topics.each_with_index do |t, i| %>
<div class='featured-topic'> <div class='featured-topic'>
<%= link_to t.title, "#{Discourse.base_url}#{t.relative_url}" %> <a href='<%= Discourse.base_url + t.relative_url %>'><%= raw unescape_emoji(t.title) %></a>
<br/> <br/>
<%= category_badge(t.category, inline_style: true, absolute_url: true) %> <%= category_badge(t.category, inline_style: true, absolute_url: true) %>
</div> </div>
@ -43,7 +43,7 @@
<%- @new_topics.each do |t| %> <%- @new_topics.each do |t| %>
<ul> <ul>
<li> <li>
<%= link_to t.title, "#{Discourse.base_url}#{t.relative_url}" %> <a href='<%= Discourse.base_url + t.relative_url %>'><%= raw unescape_emoji(t.title) %></a>
<span class='post-count'><%= t.posts_count %></span> <span class='post-count'><%= t.posts_count %></span>
<%= category_badge(t.category, inline_style: true, absolute_url: true) %> <%= category_badge(t.category, inline_style: true, absolute_url: true) %>
</li> </li>

View File

@ -226,6 +226,14 @@ module PrettyText
end end
end end
def self.unescape_emoji(title)
protect do
v8["title"] = title
decorate_context(v8)
v8.eval("Discourse.Emoji.unescape(title)")
end
end
def self.cook(text, opts={}) def self.cook(text, opts={})
options = opts.dup options = opts.dup