Commit ad8d04a7591f3ca236501670e47c9260019c5ffe
Committed by
Antonio Terceiro
1 parent
086a90b6
Exists in
master
and in
29 other branches
Created short_title on article and used it on button
(ActionItem1625)
Showing
3 changed files
with
12 additions
and
1 deletions
Show diff stats
app/models/article.rb
... | ... | @@ -189,6 +189,11 @@ class Article < ActiveRecord::Base |
189 | 189 | name |
190 | 190 | end |
191 | 191 | |
192 | + include ActionView::Helpers::TextHelper | |
193 | + def short_title | |
194 | + truncate self.title, 15, '...' | |
195 | + end | |
196 | + | |
192 | 197 | def belongs_to_blog? |
193 | 198 | self.parent and self.parent.blog? |
194 | 199 | end | ... | ... |
app/views/content_viewer/view_page.rhtml
... | ... | @@ -66,7 +66,7 @@ |
66 | 66 | |
67 | 67 | <% if @page.parent && !@page.parent.path.blank? %> |
68 | 68 | <div id="article-parent"> |
69 | - <%= button(:back, _('Go back to %s') % @page.parent.title, @page.parent.url) %> | |
69 | + <%= button(:back, _('Go back to %s') % @page.parent.short_title, @page.parent.url) %> | |
70 | 70 | </div> |
71 | 71 | <% end %> |
72 | 72 | ... | ... |
test/unit/article_test.rb
... | ... | @@ -873,4 +873,10 @@ class ArticleTest < Test::Unit::TestCase |
873 | 873 | assert_no_match /[<>]/, article.name |
874 | 874 | end |
875 | 875 | |
876 | + should 'return truncated title in short_title' do | |
877 | + article = Article.new | |
878 | + article.name = 'a123456789abcdefghij' | |
879 | + assert_equal 'a123456789ab...', article.short_title | |
880 | + end | |
881 | + | |
876 | 882 | end | ... | ... |