Guest User

Untitled

a guest
Jan 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. module ApplicationHelper
  2. include Twitter::Extractor
  3.  
  4. def auto_text_link(text)
  5. usernames = extract_mentioned_screen_names(text).uniq
  6. usernames.each do |username|
  7. text.gsub!("@#{username}","@<a href=\"#\">#{username}</a>")
  8. end
  9.  
  10. auto_link(text, :urls, :rel => "nofollow", :target => "_blank")
  11. end
  12.  
  13. def simple_format_include_spaces(text, html_options={}, options={})
  14. text = ''.html_safe if text.nil?
  15. start_tag = tag('p', html_options, true)
  16. text = sanitize(text) unless options[:sanitize] == false
  17. text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
  18. text.gsub!(/\n/, '\1<br />') # 1 newline -> br
  19. text.insert 0, start_tag
  20. text.html_safe.safe_concat("</p>")
  21. end
  22. end
Add Comment
Please, Sign In to add comment