Class: Kuhsaft::Page
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from BrickList
included, #renders_own_childs?, #to_brick_item_id, #to_brick_list_id, #user_can_add_childs?, #user_can_delete?, #user_can_save?
included, #locale_attr
Methods included from Orderable
included
Class Method Details
.arrange_as_array(options = {}, hash = nil) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/models/kuhsaft/page.rb', line 29
def arrange_as_array(options={}, hash=nil)
hash ||= arrange(options)
arr = []
hash.each do |node, children|
arr << node
arr += arrange_as_array(options, children) unless children.empty?
end
arr
end
|
.find_by_url(url) ⇒ Object
41
42
43
|
# File 'app/models/kuhsaft/page.rb', line 41
def find_by_url(url)
send "find_by_#{locale_attr(:url)}", url
end
|
.flat_tree(pages = nil) ⇒ Object
25
26
27
|
# File 'app/models/kuhsaft/page.rb', line 25
def flat_tree(pages = nil)
arrange_as_array
end
|
Instance Method Details
#brick_list_type ⇒ Object
106
107
108
|
# File 'app/models/kuhsaft/page.rb', line 106
def brick_list_type
'Kuhsaft::Page'
end
|
#collect_fulltext ⇒ Object
96
97
98
|
# File 'app/models/kuhsaft/page.rb', line 96
def collect_fulltext
self.fulltext =[super, title.to_s, keywords.to_s, description.to_s].join(' ')
end
|
#create_slug ⇒ Object
91
92
93
94
|
# File 'app/models/kuhsaft/page.rb', line 91
def create_slug
has_slug = title.present? && slug.blank?
self.slug = title.downcase.parameterize if has_slug
end
|
#create_url ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'app/models/kuhsaft/page.rb', line 78
def create_url
return if redirect?
complete_slug = ''
if parent.present?
complete_slug << parent.url.to_s
else
complete_slug = "#{I18n.locale}"
end
complete_slug << "/#{self.slug}" unless navigation?
self.url = complete_slug
end
|
#link ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
|
# File 'app/models/kuhsaft/page.rb', line 66
def link
if bricks.count == 0 && children.count > 0
children.first.link
else
if redirect?
url
else
"/#{url}"
end
end
end
|
#nesting_name ⇒ Object
100
101
102
103
104
|
# File 'app/models/kuhsaft/page.rb', line 100
def nesting_name
num_dashes = parent_pages.size
num_dashes = 0 if num_dashes < 0
"#{'-' * num_dashes} #{self.title}".strip
end
|
#parent_pages ⇒ Object
62
63
64
|
# File 'app/models/kuhsaft/page.rb', line 62
def parent_pages
ancestors
end
|
#to_style_class ⇒ Object
110
111
112
|
# File 'app/models/kuhsaft/page.rb', line 110
def to_style_class
'kuhsaft-page'
end
|
#without_self ⇒ Object
46
47
48
|
# File 'app/models/kuhsaft/page.rb', line 46
def without_self
Kuhsaft::Page.where('id != ?', self.id)
end
|