Class: Kuhsaft::Page
Constant Summary
Constants included
from Searchable
Searchable::DICTIONARIES
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Searchable
#update_fulltext
Methods included from BrickList
#brick_types, #collect_fulltext, included, #renders_own_childs?, #to_brick_item_id, #to_brick_list_id, #uploader?, #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
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/models/kuhsaft/page.rb', line 54
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
|
.flat_tree(pages = nil) ⇒ Object
50
51
52
|
# File 'app/models/kuhsaft/page.rb', line 50
def flat_tree(pages = nil)
arrange_as_array
end
|
Instance Method Details
#allowed_brick_types ⇒ Object
144
145
146
|
# File 'app/models/kuhsaft/page.rb', line 144
def allowed_brick_types
Kuhsaft::BrickType.enabled.pluck(:class_name) - ['Kuhsaft::AccordionItemBrick']
end
|
#brick_list_type ⇒ Object
136
137
138
|
# File 'app/models/kuhsaft/page.rb', line 136
def brick_list_type
'Kuhsaft::Page'
end
|
#create_slug ⇒ Object
125
126
127
128
|
# File 'app/models/kuhsaft/page.rb', line 125
def create_slug
has_slug = title.present? && slug.blank?
self.slug = title.downcase.parameterize if has_slug
end
|
#create_url ⇒ Object
121
122
123
|
# File 'app/models/kuhsaft/page.rb', line 121
def create_url
self.url = url_with_locale[1..-1]
end
|
#link ⇒ Object
95
96
97
98
99
100
101
|
# File 'app/models/kuhsaft/page.rb', line 95
def link
if bricks.count == 0 && children.count > 0
children.first.link
else
url_with_locale
end
end
|
#nesting_name ⇒ Object
130
131
132
133
134
|
# File 'app/models/kuhsaft/page.rb', line 130
def nesting_name
num_dashes = parent_pages.size
num_dashes = 0 if num_dashes < 0
"#{'-' * num_dashes} #{self.title}".strip
end
|
#parent_pages ⇒ Object
91
92
93
|
# File 'app/models/kuhsaft/page.rb', line 91
def parent_pages
ancestors
end
|
#path_segments ⇒ Object
TODO: needs naming and routing refactoring (url/locale/path/slug)
104
105
106
107
108
|
# File 'app/models/kuhsaft/page.rb', line 104
def path_segments
paths = parent.present? ? parent.path_segments : []
paths << slug unless navigation?
paths
end
|
#state_class ⇒ Object
75
76
77
78
79
80
81
|
# File 'app/models/kuhsaft/page.rb', line 75
def state_class
if published?
'published'
else
'unpublished'
end
end
|
#to_style_class ⇒ Object
140
141
142
|
# File 'app/models/kuhsaft/page.rb', line 140
def to_style_class
'kuhsaft-page'
end
|
#url_with_locale ⇒ Object
114
115
116
117
118
119
|
# File 'app/models/kuhsaft/page.rb', line 114
def url_with_locale
opts = { :locale => I18n.locale }
url = url_without_locale
opts[:url] = url if url.present?
page_path(opts)
end
|
#url_without_locale ⇒ Object
110
111
112
|
# File 'app/models/kuhsaft/page.rb', line 110
def url_without_locale
path_segments.join('/')
end
|
#without_self ⇒ Object
67
68
69
|
# File 'app/models/kuhsaft/page.rb', line 67
def without_self
Kuhsaft::Page.where('id != ?', self.id)
end
|