Skip to content

Instantly share code, notes, and snippets.

@loss-zz
Created September 8, 2011 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loss-zz/1202708 to your computer and use it in GitHub Desktop.
Save loss-zz/1202708 to your computer and use it in GitHub Desktop.
application_helper.rb
module ApplicationHelper
include Twitter::Extractor
def auto_text_link(text)
usernames = extract_mentioned_screen_names(text).uniq
usernames.each do |username|
text.gsub!("@#{username}","@<a href=\"#\">#{username}</a>")
end
auto_link(text, :urls, :rel => "nofollow", :target => "_blank")
end
def simple_format_include_spaces(text, html_options={}, options={})
text = ''.html_safe if text.nil?
start_tag = tag('p', html_options, true)
text = sanitize(text) unless options[:sanitize] == false
text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
text.gsub!(/\n/, '\1<br />') # 1 newline -> br
text.insert 0, start_tag
text.html_safe.safe_concat("</p>")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment