changeset 80:448a368f7344

More useful title?
author nanaya <me@myconan.net>
date Sun, 26 Jun 2016 18:18:54 +0900
parents 04ccd0632a71
children fe5ea9b86091
files app/helpers/application_helper.rb app/views/tweets/show.atom.builder
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/app/helpers/application_helper.rb	Sun Jun 26 18:05:41 2016 +0900
+++ b/app/helpers/application_helper.rb	Sun Jun 26 18:18:54 2016 +0900
@@ -1,3 +1,11 @@
 module ApplicationHelper
   include Twitter::Autolink
+
+  def ellipsize(text, limit = 60)
+    if text.length <= limit
+      text
+    else
+      "#{text.first(limit)}..."
+    end
+  end
 end
--- a/app/views/tweets/show.atom.builder	Sun Jun 26 18:05:41 2016 +0900
+++ b/app/views/tweets/show.atom.builder	Sun Jun 26 18:18:54 2016 +0900
@@ -4,7 +4,7 @@
 
   @tweets.each do |tweet|
     feed.entry tweet, :url => tweet.uri, :updated => tweet.created_at do |entry|
-      entry.title tweet.created_at.rfc2822
+      entry.title ellipsize(tweet.text)
       entry.content render(:partial => "tweet", :formats => :html, :locals => { :tweet => tweet }), :type => "html"
       entry.author do |author|
         author.name tweet.user.screen_name