Sha256: 6fd44c870f2ad2effb7ff7b6d03e717adf93594309685490c6297507fc0e6f8d

Contents?: true

Size: 889 Bytes

Versions: 17

Compression:

Stored size: 889 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'
      end

      def execute(site)
        page = site.engine.load_page( File.join( File.dirname( __FILE__ ), 'tag_cloud.html.haml' ) )
        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

17 entries across 17 versions & 1 rubygems

Version Path
awestruct-0.2.11 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.2.10 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.2.9 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.2.8 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.2.7 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.2.6 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.2.5 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.2.4 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.2.3 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.2.2 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.2.1 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.2.0 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.1.9 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.1.8 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.1.7 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.1.6 lib/awestruct/extensions/tag_cloud.rb
awestruct-0.1.5 lib/awestruct/extensions/tag_cloud.rb