class Yarrow::Web::Manifest

Attributes

assets[R]
documents[R]
graph[R]

Public Class Methods

build(graph) click to toggle source
# File lib/yarrow/web/manifest.rb, line 4
def self.build(graph)
  manifest = new
  manifest.set_graph(graph)

  graph.n(:collection).each do |collection|
    # TODO: raise error if both content_only and index_only are set
    index = nil

    # If the collection is tagged :index_only then skip adding individual documents
    unless collection.props[:index_only]
      collection.out(:entity).each do |entity|
        #if item[:entity].status.to_sym == :published
        if entity.props[:resource].name == "index"
          index = entity
        else
          manifest.add_document(entity_context(entity))
        end
        #end
      end
    end

    # If the collection is tagged :content_only then skip top level listing/index
    unless collection.props[:content_only]
      if index
        manifest.add_document(collection_index_context(collection, index))
      else
        manifest.add_document(collection_context(collection))
      end
    end
  end

  manifest
end
collection_context(collection) click to toggle source
# File lib/yarrow/web/manifest.rb, line 58
def self.collection_context(collection)
  # TODO: debug log
  # puts "collection_context"
  # p collection.props[:resource].title
  # p collection
  IndexDocument.new(collection, nil, true)
end
collection_index_context(collection, entity) click to toggle source
# File lib/yarrow/web/manifest.rb, line 66
def self.collection_index_context(collection, entity)
  # TODO: debug log
  # puts "collection_index_context"
  # p collection.props[:resource].title
  # p entity.props[:resource].title
  IndexDocument.new(collection, entity, false)
end
entity_context(entity) click to toggle source
# File lib/yarrow/web/manifest.rb, line 74
def self.entity_context(entity)
  Document.new(entity, false)
end
new() click to toggle source
# File lib/yarrow/web/manifest.rb, line 40
def initialize
  @documents = []
  @assets = []
end

Public Instance Methods

add_asset(asset) click to toggle source
# File lib/yarrow/web/manifest.rb, line 54
def add_asset(asset)
  @assets << asset
end
add_document(document) click to toggle source
# File lib/yarrow/web/manifest.rb, line 50
def add_document(document)
  @documents << document
end
set_graph(graph) click to toggle source

Used for dot debugging

# File lib/yarrow/web/manifest.rb, line 46
def set_graph(graph)
  @graph = graph
end