Sha256: 802eab7bde3aac46ae38f153eda1f5227c76794d592f98334b09693766a275a8

Contents?: true

Size: 1.87 KB

Versions: 9

Compression:

Stored size: 1.87 KB

Contents

require 'rails'

require 'jbuilder'
require 'jquery-rails'
require 'net/http/post/multipart'

module ::Scrivito
  class SdkEngine < Rails::Engine
    config.to_prepare do
      Scrivito::Configuration.to_prepare

      unless Rails.application.config.cache_classes
        Scrivito.models.clear_cache
      end
    end

    # make sure our exceptions cause an adequate error page and http status code
    config.action_dispatch.rescue_responses.merge!("Scrivito::ResourceNotFound" => :not_found)

    initializer "scrivito.add_cms_routing_paths", :after => :add_routing_paths do |app|
      cms_route = File.expand_path("cms_routes.rb", paths['config'].to_a.first)
      app.routes_reloader.paths.push(cms_route)
    end

    # Expose Scrivito SDK runtime to controller for logging.
    initializer "scrivito.log_runtime" do |app|
      Scrivito::LogSubscriber.attach_to :scrivito
      ActiveSupport.on_load(:action_controller) do
        include Scrivito::ControllerRuntime
      end
    end

    initializer "scrivito.routing_helpers" do
      ActiveSupport.on_load(:action_controller) do
        if Rails.env == 'test'
          ActionDispatch::TestRequest.__send__(:include, Scrivito::TestRequest)
        end

        include Scrivito::RoutingHelper
      end
    end

    initializer 'scrivito.add_sdk_assets' do |app|
      # Specify which file should be precompiled for packaging
      app.config.assets.precompile += %w[
        scrivito_sdk.css
        scrivito_sdk.js
        scrivito_ui.css
        scrivito_ui.js
      ]
      app.config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
    end

    config.autoload_paths += paths['lib'].to_a
    config.autoload_once_paths += paths['lib'].to_a

    config.app_middleware.use "Scrivito::EditingContextMiddleware"
    config.app_middleware.use "Scrivito::CacheMiddleware"
    config.app_middleware.use "Scrivito::WorkspaceSelectionMiddleware"
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
scrivito_sdk-0.50.1 lib/scrivito/sdk_engine.rb
scrivito_sdk-0.50.0 lib/scrivito/sdk_engine.rb
scrivito_sdk-0.50.0.rc2 lib/scrivito/sdk_engine.rb
scrivito_sdk-0.50.0.rc1 lib/scrivito/sdk_engine.rb
scrivito_sdk-0.42.1 lib/scrivito/sdk_engine.rb
scrivito_sdk-0.42.1.rc3 lib/scrivito/sdk_engine.rb
scrivito_sdk-0.42.1.rc2 lib/scrivito/sdk_engine.rb
scrivito_sdk-0.42.1.rc1 lib/scrivito/sdk_engine.rb
scrivito_sdk-0.42.0 lib/scrivito/sdk_engine.rb