Sha256: d868531266cc54e5d4eaccc9b0b16ba90cd21d0cec128a8c34c79f44b1f5b3e9

Contents?: true

Size: 711 Bytes

Versions: 11

Compression:

Stored size: 711 Bytes

Contents

# encoding: utf-8

# The class represents all the tags, whereas
# the instance represents each single tag.
class Tag < Ace::Item
  before Ace::TemplateFilter, layout: "tag.html"

  def self.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 self.generate
    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

11 entries across 11 versions & 1 rubygems

Version Path
ace-0.4.9 example/app/tags.rb
ace-0.4.8 example/app/tags.rb
ace-0.4.7 example/app/tags.rb
ace-0.4.6 example/app/tags.rb
ace-0.4.5 example/app/tags.rb
ace-0.4.4 example/app/tags.rb
ace-0.4.3 example/app/tags.rb
ace-0.4.2 example/app/tags.rb
ace-0.4.1 example/app/tags.rb
ace-0.4 example/app/tags.rb
ace-0.3.3 example/app/tags.rb