Class: Broadway::Post
- Inherits:
-
Object
show all
- Includes:
- Assetable, Configurable, Convertible, Hierarchical, Layoutable, Processable, Publishable, Readable, Resourceful, Sluggable, Sortable, Taggable, Themeable, Comparable
- Defined in:
- lib/broadway/resources/post.rb
Instance Attribute Summary
Attributes included from Themeable
#template
Attributes included from Layoutable
#layout
Instance Method Summary
collapse
Methods included from Themeable
#template_extensions, #theme
included
included
Methods included from Assetable
included
Methods included from Taggable
included
Methods included from Sortable
included
Methods included from Sluggable
included
included
Methods included from Readable
included
included
included
included
Instance Method Details
#body ⇒ Object
46
47
48
|
# File 'lib/broadway/resources/post.rb', line 46
def body
read
end
|
#description ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/broadway/resources/post.rb', line 50
def description
unless @description
if data["description"]
@description = data["description"]
else
@description = "" end
end
@description
end
|
39
40
41
|
# File 'lib/broadway/resources/post.rb', line 39
def format
extension
end
|
#gallery ⇒ Object
87
88
89
|
# File 'lib/broadway/resources/post.rb', line 87
def gallery
data["gallery"] || nil
end
|
91
92
93
|
# File 'lib/broadway/resources/post.rb', line 91
def
data["menu_title"] || title
end
|
#parent_path ⇒ Object
99
100
101
|
# File 'lib/broadway/resources/post.rb', line 99
def parent_path
("/" + categories.join("/")).squeeze("/")
end
|
#self_and_siblings ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/broadway/resources/post.rb', line 62
def self_and_siblings
if parent
parent.children.blank? ? nil : parent.children
else
nil
end
end
|
#sluggify ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/broadway/resources/post.rb', line 19
def sluggify
{
"year" => "", "month" => "", "day" => "", "title" => kind == "page" ? "" : slug.value,
"categories" => categories.join('/') }
end
|
70
71
72
73
74
75
|
# File 'lib/broadway/resources/post.rb', line 70
def
return nil if data["submenu"].blank?
data["submenu"].map do |path|
site.find_post_by_path(path)
end.compact
end
|
#subpages ⇒ Object
77
78
79
80
81
82
83
84
85
|
# File 'lib/broadway/resources/post.rb', line 77
def subpages
(self_and_siblings || || children).sort do |a, b|
if a.data["position"] && b.data["position"]
a.data["position"].to_i <=> b.data["position"]
else
a <=> b
end
end
end
|
#subtitle ⇒ Object
95
96
97
|
# File 'lib/broadway/resources/post.rb', line 95
def subtitle
data["subtitle"] || nil
end
|
#to_hash ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/broadway/resources/post.rb', line 29
def to_hash
{ "title" => self.title,
"url" => self.url,
"date" => self.date,
"id" => self.id,
"categories" => self.categories,
"tags" => self.tags,
"content" => self.content }.deep_merge(self.data)
end
|
#updated_at ⇒ Object
Also known as:
created_at
42
43
44
|
# File 'lib/broadway/resources/post.rb', line 42
def updated_at
date
end
|