Browse Source

Tidied POI descriptions for Layar: truncate where necessary, strip HTML, decode HTML entities

master
Adrian Short 12 years ago
parent
commit
19200aff71
3 changed files with 13 additions and 1 deletions
  1. +1
    -0
      Gemfile
  2. +2
    -0
      Gemfile.lock
  3. +10
    -1
      app/helpers/posts_helper.rb

+ 1
- 0
Gemfile View File

@@ -41,3 +41,4 @@ gem 'bson_ext'
gem 'haml-rails'
gem 'mm-multi-parameter-attributes'
gem 'feedzirra'
gem 'htmlentities'

+ 2
- 0
Gemfile.lock View File

@@ -61,6 +61,7 @@ GEM
haml (~> 3.0)
railties (~> 3.0)
hike (1.2.1)
htmlentities (4.3.1)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.0.2)
@@ -142,6 +143,7 @@ DEPENDENCIES
coffee-rails (~> 3.2.1)
feedzirra
haml-rails
htmlentities
jquery-rails
mm-multi-parameter-attributes
mongo_mapper


+ 10
- 1
app/helpers/posts_helper.rb View File

@@ -13,7 +13,7 @@ module PostsHelper
},
:text => {
:title => post.title,
:description => post.summary,
:description => clean_description(post.summary),
:footnote => "From #{post.feed.title}"
},
:actions => [
@@ -27,4 +27,13 @@ module PostsHelper
]
}
end
def clean_description(s)
if s.size > 137
s = s[0..136] + '...'
end
coder = HTMLEntities.new
coder.decode(s.gsub(/<.+?>/, ''))
end
end

Loading…
Cancel
Save