Sha256: f1df61522efc8255a8d78b210f3574a66bb40e19bda5b83e03b3ee5be28ee41b
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
module DisplayHelper def scrap_word(text, char_count_limit, more_text = nil, more_link = nil,style='') # remove HTML tags text = text.to_s.gsub(/<\/?[^>]*>/, " ") # remove additional spaces text = text.to_s.gsub(/[ ]+/, " ") if text.length < char_count_limit return text end teaser = "" words = text.split(/ /) words.each do |word| if word.length > 0 if (teaser + word).length > char_count_limit if more_text && more_link teaser = teaser + " " + link_to(more_text, more_link,:style=>style, :target=>"_blank") else teaser = teaser.strip + "..." end break; else teaser = teaser + word + " " end end end return teaser end def display_time(disp_time, class_name = nil) return distance_of_time_in_words_to_now(disp_time) + " ago" # return_str = "" # if ((Time.now - disp_time) < (6*24*60*60)) # return_str = distance_of_time_in_words_to_now(disp_time) + " ago" # else # return_str = "#{disp_time.strftime('%m/%d/%y')}" # end # # return content_tag("span", return_str, :class => (class_name.nil? ? "text-color-grey" : class_name)) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
humdrum-rails-0.1.1 | lib/rails/generators/humdrum/layout/templates/helpers/display_helper.rb |
humdrum-rails-0.0.9 | lib/rails/generators/humdrum/layout/templates/helpers/display_helper.rb |