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
69
|
# File 'app/helpers/rails_admin/navigation_helper.rb', line 30
def admin_back_home
if request.path =~ CMSViewableEdit
viewable = ($1, $2)
view_path, name, type = viewable.slice(:view_path, :unique_key_name, :viewable_type).values
if type == 'Viewable::Page'
path = viewable.url
elsif name =~ CMSPageUUID
path = Viewable::Page.find_by_uuid($1).url
else
case view_path
when CMSPageType, CMSPageFormType, CMSFormType
path = main_app.try "#{$1}_path"
when /\/(\w+)\/index$/
resources = $1
if resources.singularize == resources
path = main_app.try "#{resources}_index_path"
else
path = main_app.try "#{resources}_path"
end
when /\/\w+\/show$/
scopes = view_path.split('/')
scopes.pop
resource = scopes.pop.singularize
namespace = scopes.map(&:camelize).join('::')
first_object = "#{namespace}::#{resource.camelize}".constantize.first
if first_object
path = main_app.try "#{resource}_path", first_object
end
end
end
end
path ||= main_app.root_path
content_tag :li do
link_to t('admin.home.name'), path
end
end
|