Sha256: 24c465d14ec867dfa6fa183aecea37620839c2da3a962ecb79372475476f6056

Contents?: true

Size: 790 Bytes

Versions: 7

Compression:

Stored size: 790 Bytes

Contents

module Locomotive::Steam
  module Middlewares

    # Retrieve a page from the path and the locale previously
    # fetched from the request.
    #
    class Page < ThreadSafe

      include Helpers

      def _call
        if page = fetch_page
          if !page.not_found?
            log "Found page \"#{page.title}\" [#{page.fullpath}]"
          else
            log "Page not found, rendering the 404 page.".magenta
          end
        end

        env['steam.page'] = page
      end

      protected

      def fetch_page
        services.page_finder.match(path).tap do |pages|
          if pages.size > 1
            self.log "Found multiple pages: #{pages.map(&:title).join(', ')}"
          end
        end.first || services.page_finder.find('404')
      end

    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.0.pre.beta.3 lib/locomotive/steam/middlewares/page.rb
locomotivecms_steam-1.0.0.pre.beta.2 lib/locomotive/steam/middlewares/page.rb
locomotivecms_steam-1.0.0.pre.beta.1 lib/locomotive/steam/middlewares/page.rb
locomotivecms_steam-1.0.0.pre.alpha.3 lib/locomotive/steam/middlewares/page.rb
locomotivecms_steam-1.0.0.pre.alpha.2 lib/locomotive/steam/middlewares/page.rb
locomotivecms_steam-1.0.0.pre.alpha.1 lib/locomotive/steam/middlewares/page.rb
locomotivecms_steam-1.0.0.pre.alpha lib/locomotive/steam/middlewares/page.rb