Sha256: 797e321218a310cf2385eb3289fc42591cec65ab7fc480cf3eaf75eca56773aa

Contents?: true

Size: 939 Bytes

Versions: 12

Compression:

Stored size: 939 Bytes

Contents

module Awestruct
  module Extensions
    class TagCloud

      def initialize(tagged_items_property, output_path='tags', opts={})
        @tagged_items_property = tagged_items_property
        @output_path = output_path
        @layout = opts[:layout].to_s
        @title  = opts[:title] || 'Tags'
        @template = opts[:template] || File.join( File.dirname( __FILE__ ), 'tag_cloud.html.haml' )
      end

      def execute(site)
        page = site.engine.load_page( @template )
        page.output_path = File.join( @output_path )
        page.layout = @layout
        page.title  = @title
        page.tags = site.send( "#{@tagged_items_property}_tags" ) || []
        site.pages << page
        site.send( "#{@tagged_items_property}_tag_cloud=", LazyPage.new( page ) )
      end

    end

    class LazyPage
      def initialize(page)
        @page = page
      end
      def to_s
        @page.content
      end
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
awestruct-0.5.7.RC2 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.5.7.RC1 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.5.6 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.5.6.beta9 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.5.6.beta8 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.5.6.beta7 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.5.6.beta6 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.5.6.beta5 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.5.6.beta4 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.5.6.beta3 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.5.6.beta2 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.5.6.beta lib/awestruct/extensions/tag_cloud.rb