From e01dc54f2aa336658b683032f889b15a130c872e Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 2 Jun 2016 12:29:25 +1000 Subject: [PATCH] UX: we should always simply use emoji codes as opposed to treating as image --- lib/excerpt_parser.rb | 3 +-- lib/onebox/engine/discourse_local_onebox.rb | 2 +- spec/components/pretty_text_spec.rb | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/excerpt_parser.rb b/lib/excerpt_parser.rb index acfa88b88..4a19c337a 100644 --- a/lib/excerpt_parser.rb +++ b/lib/excerpt_parser.rb @@ -14,7 +14,6 @@ class ExcerptParser < Nokogiri::XML::SAX::Document @markdown_images = options[:markdown_images] == true @keep_newlines = options[:keep_newlines] == true @keep_emoji_images = options[:keep_emoji_images] == true - @keep_emoji_codes = options[:keep_emoji_codes] == true @start_excerpt = false end @@ -54,7 +53,7 @@ class ExcerptParser < Nokogiri::XML::SAX::Document if attributes["class"] == 'emoji' if @keep_emoji_images return include_tag(name, attributes) - elsif @keep_emoji_codes + else return characters(attributes["alt"]) end end diff --git a/lib/onebox/engine/discourse_local_onebox.rb b/lib/onebox/engine/discourse_local_onebox.rb index 5e7564037..f0ea5a32d 100644 --- a/lib/onebox/engine/discourse_local_onebox.rb +++ b/lib/onebox/engine/discourse_local_onebox.rb @@ -66,7 +66,7 @@ module Onebox topic = post.topic slug = Slug.for(topic.title) - excerpt = post.excerpt(SiteSetting.post_onebox_maxlength, { keep_emoji_codes: true }) + excerpt = post.excerpt(SiteSetting.post_onebox_maxlength) excerpt.gsub!("\n"," ") # hack to make it render for now excerpt.gsub!("[/quote]", "[quote]") diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 430bf7bad..729c6474c 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -263,7 +263,7 @@ HTML it "should have an option to preserve emoji codes" do emoji_code = ":heart:" - expect(PrettyText.excerpt(emoji_code, 100, { keep_emoji_codes: true })).to eq(":heart:") + expect(PrettyText.excerpt(emoji_code, 100)).to eq(":heart:") end end