Sha256: 3d50192dba5d602133bb9f84774dff3f4ff07527ebd3032ca608359c59bf92ae

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

module MuckRakerHelper

  def tag_cloud(tag_list, classes)
    tag_list.split(',').each_slice(2){|tag,index| yield tag, classes[index.to_i]}
  end
  
  def tag_link(tag, filter, css_class)
     link_to h(tag), "/resources/tags/#{filter.nil? ? '' : filter + '/'}#{tag}", :class => css_class
  end
  
  def results_status
    if @tag_filter.nil?
        t('muck.raker.search_results_status', 
        :first => @offset+1, 
        :last => (@offset + @per_page) < @hit_count ? (@offset + @per_page) : @hit_count,
        :total => @hit_count,
        :filter => @tag_filter,
        :terms => URI.unescape(@term_list))
    else
        t('muck.raker.browse_results_status', 
        :first => @offset+1, 
        :last => (@offset + @per_page) < @hit_count ? (@offset + @per_page) : @hit_count,
        :total => @hit_count,
        :filter => @tag_filter,
        :terms => @tag_filter.split('/').join('</b>, <b>'))
    end
  end
  
  def round(flt)
    return (((flt.to_f*100).to_i.round).to_f)/100.0
  end

  def truncate_on_word(text, length = 270, end_string = ' ...')
    if text.length > length
      stop_index = text.rindex(' ', length)
      stop_index = length - 10 if stop_index < length-10
      text[0,stop_index] + (text.length > 260 ? end_string : '')
    else
      text
    end
  end
  
  def truncate_words(text, length = 40, end_string = ' ...')
    words = text.split()
    words[0..(length-1)].join(' ') + (words.length > length ? end_string : '')
  end
  
  def feed_query_uri(feed)
    "/search/results?terms=feed_id:" + feed.id.to_s + "&locale=en"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
muck-raker-0.1.9 app/helpers/muck_raker_helper.rb
muck-raker-0.1.10 app/helpers/muck_raker_helper.rb