Skip to content

Commit

Permalink
moving basic htmlization of post content into the model.
Browse files Browse the repository at this point in the history
two immediate benefits:
1. we can test Post output in a unit test
2. we can easily support new storage formats (like markdown and raw
   html) without writing new view logic
  • Loading branch information
flavorjones committed Oct 28, 2008
1 parent 72338a2 commit 5e3487f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions app/helpers/application_helper.rb
Expand Up @@ -34,9 +34,8 @@ def twitterize(string)
end

def clean_content_for(post)
text = post.content
text = post.to_html
text.gsub!(/<(script|noscript|object|embed|style|frameset|frame|iframe)[>\s\S]*<\/\1>/, '') if post.from_feed?
text = RedCloth.new(text, [:filter_styles, :no_span_caps]).to_html
text = spanify_links(text)
end

Expand Down
6 changes: 6 additions & 0 deletions app/models/post.rb
Expand Up @@ -45,4 +45,10 @@ def deleted?
def link(root='')
"#{root}/#{type.tableize}/#{to_param}"
end

def to_html
text = content
text = RedCloth.new(text, [:filter_styles, :no_span_caps]).to_html
end

end

0 comments on commit 5e3487f

Please sign in to comment.