Module: SearchHistoriesHelper

Defined in:
app/helpers/search_histories_helper.rb

Instance Method Summary collapse

Instance Method Details

#reverse_tag_cloud(query_and_numbers) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/search_histories_helper.rb', line 2

def reverse_tag_cloud(query_and_numbers)
  return nil if query_and_numbers.nil?
  # TODO: add options to specify different limits and sorts
  #tags = Tag.all(:limit => 100, :order => 'taggings_count DESC').sort_by(&:name)

  # TODO: add option to specify which classes you want and overide this if you want?
  classes = %w(popular v-popular vv-popular vvv-popular vvvv-popular)

  max, min = 0, 0
  query_and_numbers.each do |query|
    #if options[:max] or options[:min]
    #  max = options[:max].to_i
    #  min = options[:min].to_i
    #end
    max = query[1] if query[1].to_i > max
    min = query[1] if query[1].to_i < min
  end
  divisor = ((max - min).div(classes.size)) + 1

   :div, :class => "hTagcloud" do
     :ul, :class => "popularity" do
      query_and_numbers.each do |query|
         :li do
          link_to(h(query[0]), manifestations_url(:query => query[0]), :class => classes[(query[1] - min).div(divisor)])
        end
      end
    end
  end
end