class Awestruct::Extensions::TagCloud
Public Class Methods
new(tagged_items_property, output_path='tags', opts={})
click to toggle source
# 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' if opts[:template] && Pathname.new(opts[:template]).relative? @template = Pathname.new(::Awestruct::Engine.instance.site.config.dir).join(opts[:template]) else @template = File.join( File.dirname(__FILE__), 'tag_cloud.html.haml' ) end end
Public Instance Methods
execute(site)
click to toggle source
# File lib/awestruct/extensions/tag_cloud.rb, line 17 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