2013-12-16 00:52:40 -05:00
|
|
|
require 'rails/application_controller'
|
2012-07-01 23:00:10 -04:00
|
|
|
require 'action_dispatch/routing/inspector'
|
2012-05-22 19:23:17 -04:00
|
|
|
|
2013-12-16 00:52:40 -05:00
|
|
|
class Rails::InfoController < Rails::ApplicationController # :nodoc:
|
2012-12-17 15:26:46 -05:00
|
|
|
prepend_view_path ActionDispatch::DebugExceptions::RESCUES_TEMPLATE_PATH
|
2013-12-16 00:52:40 -05:00
|
|
|
layout -> { request.xhr? ? false : 'application' }
|
2012-05-22 19:23:17 -04:00
|
|
|
|
2014-05-27 18:08:23 -04:00
|
|
|
before_action :require_local!
|
2012-05-22 19:23:17 -04:00
|
|
|
|
|
|
|
def index
|
2013-01-05 08:52:04 -05:00
|
|
|
redirect_to action: :routes
|
2012-05-22 19:23:17 -04:00
|
|
|
end
|
|
|
|
|
2006-03-29 10:11:47 -05:00
|
|
|
def properties
|
2012-05-22 19:23:17 -04:00
|
|
|
@info = Rails::Info.to_html
|
2013-11-21 20:02:57 -05:00
|
|
|
@page_title = 'Properties'
|
2012-05-22 19:23:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def routes
|
2015-02-23 11:51:30 -05:00
|
|
|
if path = params[:path]
|
2015-05-05 00:13:15 -04:00
|
|
|
path = URI.parser.escape path
|
2015-02-23 11:51:30 -05:00
|
|
|
normalized_path = with_leading_slash path
|
|
|
|
render json: {
|
|
|
|
exact: match_route {|it| it.match normalized_path },
|
|
|
|
fuzzy: match_route {|it| it.spec.to_s.match path }
|
|
|
|
}
|
|
|
|
else
|
|
|
|
@routes_inspector = ActionDispatch::Routing::RoutesInspector.new(_routes.routes)
|
|
|
|
@page_title = 'Routes'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def match_route
|
|
|
|
_routes.routes.select {|route|
|
|
|
|
yield route.path
|
|
|
|
}.map {|route| route.path.spec.to_s }
|
|
|
|
end
|
|
|
|
|
|
|
|
def with_leading_slash(path)
|
|
|
|
('/' + path).squeeze('/')
|
2006-03-19 13:45:26 -05:00
|
|
|
end
|
2006-03-29 10:11:47 -05:00
|
|
|
end
|