annotate app/helpers/application_helper.rb @ 82:f91e2d00f03f

Reduce title length limit
author nanaya <me@myconan.net>
date Sun, 26 Jun 2016 18:22:05 +0900
parents 448a368f7344
children 0c8a8b390145
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a1c9fadc0904 Initial.
edogawaconan <me@myconan.net>
parents:
diff changeset
1 module ApplicationHelper
15
207917e41964 Add tweets~
edogawaconan <me@myconan.net>
parents: 0
diff changeset
2 include Twitter::Autolink
80
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
3
82
f91e2d00f03f Reduce title length limit
nanaya <me@myconan.net>
parents: 80
diff changeset
4 def ellipsize(text, limit = 30)
80
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
5 if text.length <= limit
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
6 text
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
7 else
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
8 "#{text.first(limit)}..."
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
9 end
448a368f7344 More useful title?
nanaya <me@myconan.net>
parents: 15
diff changeset
10 end
0
a1c9fadc0904 Initial.
edogawaconan <me@myconan.net>
parents:
diff changeset
11 end