Sha256: 8c60f9b469e18c7d98a146254adba97c7f928893f10779c58073fa5518daeaff

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require 'rack/session/moneta'
require 'rack/builder'
require 'rack/lint'
require 'dragonfly/middleware'

module Locomotive
  module Steam
    module Middlewares

      class Stack

        def initialize(options)
          @options = prepare_options(options)
        end

        def create
          options = @options

          Rack::Builder.new do
            use Rack::Lint

            use Middlewares::Favicon

            if options[:serve_assets]
              use Middlewares::StaticAssets, {
                urls: ['/images', '/fonts', '/samples', '/media']
              }

              use Middlewares::DynamicAssets
            end

            use ::Dragonfly::Middleware, :steam

            use Rack::Session::Moneta, options[:moneta]

            use Middlewares::Logging

            use Middlewares::EntrySubmission

            use Middlewares::Path
            use Middlewares::Locale
            use Middlewares::Timezone

            use Middlewares::Page
            use Middlewares::TemplatizedPage

            run Middlewares::Renderer.new
          end
        end

        protected

        def prepare_options(options)
          {
            serve_assets: false,
            moneta: {
              store: Moneta.new(:Memory, :expires => true)
            }
          }.merge(options)
        end

      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
locomotivecms_steam-0.1.1 lib/locomotive/steam/middlewares/stack.rb