changeset 174:d35dbc09bd83

Less double escaping for actual content Ends up rather confusing.
author nanaya <me@nanaya.pro>
date Thu, 09 Aug 2018 19:31:22 +0900
parents aa78d1eeb6e5
children 52252ae4b580
files app/views/tweets/_tweet.html.erb config/initializers/ext_twitter_tweet.rb
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/app/views/tweets/_tweet.html.erb	Wed Aug 08 20:38:29 2018 +0900
+++ b/app/views/tweets/_tweet.html.erb	Thu Aug 09 19:31:22 2018 +0900
@@ -13,11 +13,11 @@
 
   <p>
     <%# FIXME: Twitter gem doesn't support extended mode when writing this %>
-    <%= auto_link(html_escape(expand_url(
-          tweet.unescaped_text,
+    <%= auto_link(expand_url(
+          tweet.full_text_extended,
           tweet.attrs[:entities][:urls],
           tweet.attrs[:entities][:media]
-        )))
+        ))
         .gsub("\n", "<br />")
         .html_safe
       %>
--- a/config/initializers/ext_twitter_tweet.rb	Wed Aug 08 20:38:29 2018 +0900
+++ b/config/initializers/ext_twitter_tweet.rb	Thu Aug 09 19:31:22 2018 +0900
@@ -1,7 +1,11 @@
 class Twitter::Tweet
+  def full_text_extended
+    attrs[:full_text].printable
+  end
+  memoize :full_text_extended
+
   def unescaped_text
-    CGI.unescapeHTML attrs[:full_text].printable
+    CGI.unescapeHTML full_text_extended
   end
-
   memoize :unescaped_text
 end