Class: Awestruct::Extensions::TagCloud

Inherits:
Object
  • Object
show all
Defined in:
lib/awestruct/extensions/tag_cloud.rb

Instance Method Summary collapse

Constructor Details

#initialize(tagged_items_property, output_path = 'tags', opts = {}) ⇒ TagCloud

Returns a new instance of TagCloud.



5
6
7
8
9
10
# File 'lib/awestruct/extensions/tag_cloud.rb', line 5

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

Instance Method Details

#execute(site) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/awestruct/extensions/tag_cloud.rb', line 12

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