18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/support/pageable.rb', line 18
def page(name, path, options = {}, &block)
localize = options.delete(:localize) == false ? false : Fullstack::Cms.config.localize
this_controller_name = "#{self.name.underscore}".gsub("_controller", "")
uid = "#{this_controller_name}##{name}"
parent_uid = if parent_opt = options.delete(:parent)
parent_opt = parent_opt.to_s
if parent_opt.include?("#")
parent_opt
else
"#{this_controller_name}##{parent_opt}"
end
end
resource_type = options.delete(:resource).try(:to_s)
i18n_scope = "pages.#{self.name.underscore.split('/').last}##{name}"
title = options.delete(:title) || I18n.t("#{i18n_scope}.title", :default => "#{name}".humanize)
if Page.table_exists?
if localize
I18n.available_locales.each do |locale|
_page!(uid, _localize_path(path, locale), name, title, parent_uid, resource_type, locale.to_s)
end
else
_page!(uid, path, name, title, parent_uid, resource_type)
end
end
if localize
I18n.available_locales.each do |locale|
map(name, _localize_path(path, locale), options.reverse_merge({:locale => locale.to_s, :as => "#{name}_#{locale}"}), &block)
end
else
map(name, path, options, &block)
end
end
|