Class: Yarrow::LegacyWeb::BaseDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/yarrow/web/document.rb

Direct Known Subclasses

Document, IndexDocument

Instance Method Summary collapse

Instance Method Details

#bodyObject



73
74
75
76
# File 'lib/yarrow/web/document.rb', line 73

def body
  return @resource.body.to_html if @resource.respond_to?(:body)
  ""
end

TODO: manage behaviour with and without current item TODO: link to manifest

TODO: replace @item and @collection with @node internally and in class interface



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/yarrow/web/document.rb', line 52

def breadcrumbs
  path = []

  current_parent = @node.in(:collection)

  while !current_parent.first.nil?
    path << current_parent.first.props[:resource]
    current_parent = current_parent.in(:collection)
  end

  path.reverse
end

#indexObject

TODO: confirm this can be deleted



34
35
36
37
38
39
40
41
# File 'lib/yarrow/web/document.rb', line 34

def index
  _index = @item.out_e(:index)
  unless _index.first.nil?
    _index.first.to.props
  else
    nil
  end
end

#index_bodyObject

TODO: confirm this can be deleted



44
45
46
# File 'lib/yarrow/web/document.rb', line 44

def index_body
  @item.props[:index_body]
end

#nameObject



65
66
67
# File 'lib/yarrow/web/document.rb', line 65

def name
  @resource.name
end

#resourceObject



25
26
27
# File 'lib/yarrow/web/document.rb', line 25

def resource
  @resource
end

#titleObject



69
70
71
# File 'lib/yarrow/web/document.rb', line 69

def title
  @resource.title
end

#typeObject



29
30
31
# File 'lib/yarrow/web/document.rb', line 29

def type
  @type
end

#urlObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/yarrow/web/document.rb', line 78

def url
  if @parent.nil?
    "/"
  else
    segments = [@resource.name]
    current = @parent

    until current.in(:collection).first.nil? do
      segments << current.props[:resource].name
      current = current.in(:collection).first
    end

    suffix = @is_index ? "/" : ""

    "/" + segments.reverse.join("/") + suffix
  end
end