Created
September 8, 2011 05:38
-
-
Save loss-zz/1202708 to your computer and use it in GitHub Desktop.
application_helper.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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