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.3.0.pre.alpha2 app/controllers/playbook/samples_controller.rb
playbook_ui-6.8.2.pre.alpha1 app/controllers/playbook/samples_controller.rb
playbook_ui-7.0.1.pre.alpha14 app/controllers/playbook/samples_controller.rb
playbook_ui-6.8.1 app/controllers/playbook/samples_controller.rb
playbook_ui-6.8.0 app/controllers/playbook/samples_controller.rb
playbook_ui-6.7.0.pre.alpha1 app/controllers/playbook/samples_controller.rb
playbook_ui-6.7.0 app/controllers/playbook/samples_controller.rb
playbook_ui-6.6.1 app/controllers/playbook/samples_controller.rb
playbook_ui-6.6.0 app/controllers/playbook/samples_controller.rb
playbook_ui-6.5.2 app/controllers/playbook/samples_controller.rb
playbook_ui-7.0.1.pre.alpha12 app/controllers/playbook/samples_controller.rb
playbook_ui-7.0.1.pre.alpha11 app/controllers/playbook/samples_controller.rb
playbook_ui-7.0.1.pre.alpha10 app/controllers/playbook/samples_controller.rb
playbook_ui-7.0.1.pre.alpha9 app/controllers/playbook/samples_controller.rb
playbook_ui-6.5.1 app/controllers/playbook/samples_controller.rb
playbook_ui-6.5.0 app/controllers/playbook/samples_controller.rb
playbook_ui-7.0.1.pre.alpha8 app/controllers/playbook/samples_controller.rb
playbook_ui-7.0.1.pre.alpha7 app/controllers/playbook/samples_controller.rb
playbook_ui-7.0.1.pre.alpha6 app/controllers/playbook/samples_controller.rb
playbook_ui-7.0.1.pre.alpha5 app/controllers/playbook/samples_controller.rb