Sha256: 6c7d8617457b81211eb525ff089fa22bec8225c4bc620aee836b908fcb57187d

Contents?: true

Size: 1.17 KB

Versions: 30

Compression:

Stored size: 1.17 KB

Contents

module EnjuBookmark
  module BookmarkHelper
    def link_to_tag(tag)
      link_to tag, manifestations_path(:tag => tag.name)
    end

    def render_tag_cloud(tags, options = {})
      # 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
      tags.each do |tag|
        #if options[:max] or options[:min]
        #  max = options[:max].to_i
        #  min = options[:min].to_i
        #end
        max = tag.taggings.size if tag.taggings.size > max
        min = tag.taggings.size if tag.taggings.size < min
      end
      divisor = ((max - min).div(classes.size)) + 1

      content_tag :div, :class => "hTagcloud" do
        content_tag :ul, :class => "popularity" do
          tags.collect do |tag|
            concat(content_tag :li, link_to(tag.name, manifestations_path(:tag => tag.name), :class => classes[(tag.taggings.size - min).div(divisor)]) + "\n")
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
enju_bookmark-0.2.2 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.2.1 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.2.0 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.2.0.beta.5 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.2.0.beta.3 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.2.0.beta.2 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.2.0.beta.1 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.1.3 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.1.2 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.1.2.pre23 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.1.2.pre22 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.1.2.pre21 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.1.2.pre20 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.1.2.pre19 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.1.2.pre18 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.1.2.pre17 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.1.2.pre16 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.1.2.pre15 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.1.2.pre14 lib/enju_bookmark/bookmark_helper.rb
enju_bookmark-0.1.2.pre13 lib/enju_bookmark/bookmark_helper.rb