Sha256: fc0d5f7f930fc1999952770146ab29550a08fa2f66ce7e356e3db86e5a1d488d

Contents?: true

Size: 1.8 KB

Versions: 2

Compression:

Stored size: 1.8 KB

Contents

require 'rack/cors'
require 'active_model_serializers'
require 'carrierwave'
require 'rake'

module Landable
  class Engine < ::Rails::Engine
    isolate_namespace Landable

    config.generators do |g|
      g.test_framework :rspec
      g.fixture_replacement :factory_girl, dir: 'spec/factories'
    end

    initializer 'landable.enable_cors' do |app|
      config = Landable.configuration
      if config.cors.enabled?
        app.middleware.insert 0, Rack::Cors do
          allow do
            origins config.cors.origins
            resource "#{config.api_namespace}/*",
                     methods: [:get, :post, :put, :patch, :delete],
                     headers: :any,
                     expose: 'X-Landable-Media-Type',
                     credentials: false,
                     max_age: 15.minutes
          end
        end
      end
    end

    initializer 'landable.json_schema' do |app|
      if ENV['LANDABLE_VALIDATE_JSON']
        require 'rack/schema'
        app.middleware.use Rack::Schema
      end
    end

    initializer 'landable.seed_required' do |_app|
      suppress(StandardError) { Landable::Seeds.seed(:required) }
    end

    initializer 'landable.create_themes' do |_app|
      suppress(StandardError) { Theme.create_from_layouts! }
    end

    initializer 'landable.create_templates' do |_app|
      suppress(StandardError) { Template.create_from_partials! }
    end

    initializer 'landable.action_controller' do
      ActiveSupport.on_load :action_controller do
        # includes
        include Landable::Traffic
        include Landable::VariablesConcern

        # helpers
        helper Landable::PagesHelper

        # tracking
        if Landable.configuration.traffic_enabled
          prepend_around_action :track_with_landable!
        end

        # end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
landable-1.14.0 lib/landable/engine.rb
landable-1.13.2 lib/landable/engine.rb