Sha256: 14148515515b3604a49c61d37525da67bb5fc835ed5aac8c67d8bf1b716d08ad

Contents?: true

Size: 636 Bytes

Versions: 1

Compression:

Stored size: 636 Bytes

Contents

# encoding: utf-8

class Tag < Ace::Item
  before Ace::TemplateFilter, layout: "tag.html"
end

class TagPagesGenerator
  def tags
    Post.instances.inject(Hash.new) do |buffer, post|
      if tags = post.metadata[:tags]
        tags.each do |tag|
          buffer[tag] ||= Array.new
          buffer[tag] << post
        end
      end
      buffer
    end
  end

  def run
    self.tags.each do |tag_title, items|
      tag_name = tag_title.downcase.gsub(" ", "-")
      metadata = {title: tag_title, timestamp: Time.now}
      tag = Tag.create(metadata, items)
      tag.output_path = "output/tags/#{tag_name}.html"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ace-0.3.2 example/app/tags.rb