Sha256: fc499942e4c8d71973e13988a5fbd0ff58555b84079807c313ade87a7349c68a

Contents?: true

Size: 1.72 KB

Versions: 16

Compression:

Stored size: 1.72 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|
      Landable::Seeds.seed(:required) rescue nil
    end

    initializer "landable.create_themes" do |app|
      Theme.create_from_layouts! rescue nil
    end

    initializer 'landable.create_templates' do |app|
      Template.create_from_partials! rescue nil
    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

16 entries across 16 versions & 1 rubygems

Version Path
landable-1.13.1 lib/landable/engine.rb
landable-1.12.3 lib/landable/engine.rb
landable-1.12.2 lib/landable/engine.rb
landable-1.12.1 lib/landable/engine.rb
landable-1.11.1 lib/landable/engine.rb
landable-1.11.0 lib/landable/engine.rb
landable-1.10.0.rc2 lib/landable/engine.rb
landable-1.10.0.rc1 lib/landable/engine.rb
landable-1.9.2 lib/landable/engine.rb
landable-1.9.1 lib/landable/engine.rb
landable-1.9.0 lib/landable/engine.rb
landable-1.9.0.rc2 lib/landable/engine.rb
landable-1.9.0.rc1 lib/landable/engine.rb
landable-1.8.0 lib/landable/engine.rb
landable-1.7.1.rc1 lib/landable/engine.rb
landable-1.7.0 lib/landable/engine.rb