Sha256: 10ed28dbca9ad31e564de966b7c0bfd3a65787db397561b9bdb718c0d9e53bce

Contents?: true

Size: 1.07 KB

Versions: 15

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

class Jets::InfoController < Jets::ApplicationController # :nodoc:
  prepend_view_path ActionDispatch::DebugView::RESCUES_TEMPLATE_PATH
  layout -> { request.xhr? ? false : "application" }

  before_action :require_local!

  def index
    redirect_to action: :routes
  end

  def properties
    @info = Jets::Info.to_html
    @page_title = "Properties"
  end

  def routes
    if path = params[:path]
      path = URI::DEFAULT_PARSER.escape path
      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_table = routes_table
      @page_title = "Routes"
    end
  end

  private
    def routes_table
      text = Jets::Router::Help.new(format: "markdown").text
      Kramdown::Document.new(text).to_html
    end

    def match_route
      _routes.routes.filter_map { |route| route.path.spec.to_s if yield route.path }
    end

    def with_leading_slash(path)
      ("/" + path).squeeze("/")
    end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.12 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.11 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.10 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.9 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.8 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.7 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.6 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.5 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.4 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.3 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.2 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.1 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.0 engines/internal/app/controllers/jets/info_controller.rb
jets-5.0.0.beta1 engines/internal/app/controllers/jets/info_controller.rb