January, 2009

Awesome Truncation in Rails (2009-01-30)

For a project I’m working on, we’d like to have the rails truncate helper truncate strings at word boundaries rather than at the in the middle of a word after exactly a certain number of characters.

Daniel Morrison’s awesome_truncate provides the basic idea, but it has a few problems:

  • it’s not compatible with Ruby 1.9
  • it doesn’t support the new Rails 2.2 calling convention for truncate, in which options are passed as a hash rather than a list
  • you have to replace your calls to truncate with calls to awesome_truncate

In addition, our client asked us to ensure that there is never a single word on a line by itself at the end of the truncated string.

Read more… View Comments

Are people in the media starting to “get it”? (2009-01-16)

If you’re even remotely interested in such matters, you’ve probably already heard about Al Jazeera’s Creative Commons-licensed repository of footage from Gaza.

Read more… View Comments