Sha256: c28b8bef03697009b98be485a649c984d5345810e774a0fffef2977299c131d3

Contents?: true

Size: 944 Bytes

Versions: 4

Compression:

Stored size: 944 Bytes

Contents

module Bulb::Concerns::BulbController
  extend ActiveSupport::Concern

  included do
    helper Rails.application.routes.url_helpers
    helper Bulb::ApplicationHelper
    helper Bulb::TextHelper

    protect_from_forgery with: :exception

    protected
      def set_repository
        @group = Bulb::Group.find_by(slug: params[:group_slug])
        @repository = Bulb::Repository.find_by(group: @group, slug: params[:slug])
      end

      def group_slug
        params[:group_slug]
      end

      def slug
        params[:slug]
      end

      def handle_special_formats
        redirect_formats = [
          "text/css",
          "text/javascript",
          "text/plain",
          "image/svg+xml", "image/png", "image/gif", "image/jpeg", "image/jpg",
          "application/x-yaml",
          "application/xml"
        ]

        request.formats = [:html] if redirect_formats.include?(request.formats.first.to_s)
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bulb-0.5.0 app/controllers/bulb/concerns/bulb_controller.rb
bulb-0.4.0 app/controllers/bulb/concerns/bulb_controller.rb
bulb-0.3.0 app/controllers/bulb/concerns/bulb_controller.rb
bulb-0.2.0 app/controllers/bulb/concerns/bulb_controller.rb