Class: Yarrow::Web::BaseDocument
- Inherits:
-
Object
- Object
- Yarrow::Web::BaseDocument
- Defined in:
- lib/yarrow/web/document.rb
Direct Known Subclasses
Instance Method Summary collapse
- #body ⇒ Object
-
#breadcrumbs ⇒ Object
TODO: manage behaviour with and without current item TODO: link to manifest.
-
#index ⇒ Object
TODO: confirm this can be deleted.
-
#index_body ⇒ Object
TODO: confirm this can be deleted.
- #name ⇒ Object
- #resource ⇒ Object
- #title ⇒ Object
- #type ⇒ Object
- #url ⇒ Object
Instance Method Details
#body ⇒ Object
52 53 54 55 |
# File 'lib/yarrow/web/document.rb', line 52 def body return @resource.body.to_html if @resource.respond_to?(:body) "" end |
#breadcrumbs ⇒ Object
TODO: manage behaviour with and without current item TODO: link to manifest
TODO: replace @item and @collection with @node internally and in class interface
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/yarrow/web/document.rb', line 31 def 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 |
#index ⇒ Object
TODO: confirm this can be deleted
13 14 15 16 17 18 19 20 |
# File 'lib/yarrow/web/document.rb', line 13 def index _index = @item.out_e(:index) unless _index.first.nil? _index.first.to.props else nil end end |
#index_body ⇒ Object
TODO: confirm this can be deleted
23 24 25 |
# File 'lib/yarrow/web/document.rb', line 23 def index_body @item.props[:index_body] end |
#name ⇒ Object
44 45 46 |
# File 'lib/yarrow/web/document.rb', line 44 def name @resource.name end |
#resource ⇒ Object
4 5 6 |
# File 'lib/yarrow/web/document.rb', line 4 def resource @resource end |
#title ⇒ Object
48 49 50 |
# File 'lib/yarrow/web/document.rb', line 48 def title @resource.title end |
#type ⇒ Object
8 9 10 |
# File 'lib/yarrow/web/document.rb', line 8 def type @type end |
#url ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/yarrow/web/document.rb', line 57 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 |