Sha256: b8eb21f96282c8e9e199bfc7ffb4d461c05c437e6b96048e8ad929996de02c57

Contents?: true

Size: 966 Bytes

Versions: 93

Compression:

Stored size: 966 Bytes

Contents

# frozen_string_literal: true

require_dependency "playbook/application_controller"
require "yaml"

module Playbook
  class SamplesController < ApplicationController
    before_action :set_sample, only: %i[sample_show_rails sample_show_react]

    layout "playbook/samples"

    def samples
      params[:type] ||= "rails"
      @type = params[:type]
    end

    def sample_show_rails
      params[:type] ||= "rails"
      @type = params[:type]
      render template: "playbook/samples/sample_show"
    end

    def sample_show_react
      params[:type] ||= "react"
      @type = params[:type]
      render template: "playbook/samples/sample_show"
    end

  private

    def set_sample
      menu = MENU["samples"].map { |link| link.is_a?(Hash) ? link.first.last : link }
      if menu.flatten.include?(params[:name])
        @sample = params[:name]
      else
        redirect_to root_path, flash: { error: "That kit does not exist" }
      end
    end
  end
end

Version data entries

93 entries across 93 versions & 1 rubygems

Version Path
playbook_ui-7.0.1.pre.alpha4 app/controllers/playbook/samples_controller.rb
playbook_ui-7.0.1.pre.alpha3 app/controllers/playbook/samples_controller.rb
playbook_ui-7.0.1.pre.alpha2 app/controllers/playbook/samples_controller.rb
playbook_ui-6.4.2 app/controllers/playbook/samples_controller.rb
playbook_ui-7.0.1.pre.alpha1 app/controllers/playbook/samples_controller.rb
playbook_ui-6.4.1 app/controllers/playbook/samples_controller.rb
playbook_ui-6.4.0 app/controllers/playbook/samples_controller.rb
playbook_ui-6.3.1 app/controllers/playbook/samples_controller.rb
playbook_ui-6.3.0 app/controllers/playbook/samples_controller.rb
playbook_ui-6.2.1 app/controllers/playbook/samples_controller.rb
playbook_ui-6.2.0 app/controllers/playbook/samples_controller.rb
playbook_ui-6.1.0.pre.alpha5 app/controllers/playbook/samples_controller.rb
playbook_ui-6.1.0.pre.alpha4 app/controllers/playbook/samples_controller.rb
playbook_ui-6.1.0.pre.alpha3 app/controllers/playbook/samples_controller.rb
playbook_ui-6.1.0.pre.alpha2 app/controllers/playbook/samples_controller.rb
playbook_ui-6.1.0.pre.alpha1 app/controllers/playbook/samples_controller.rb
playbook_ui-6.1.0 app/controllers/playbook/samples_controller.rb
playbook_ui-6.0.1.pre.alpha6 app/controllers/playbook/samples_controller.rb
playbook_ui-6.0.1.pre.alpha5 app/controllers/playbook/samples_controller.rb
playbook_ui-6.0.1.pre.alpha4 app/controllers/playbook/samples_controller.rb