Sha256: 967b58cd30fb390e93fa799cc4560c25fc4529a0cc145caa764471f6aecc31e5

Contents?: true

Size: 902 Bytes

Versions: 13

Compression:

Stored size: 902 Bytes

Contents

module Locomotive::Steam
  module Middlewares

    # When rendering the page, the developer can stop it at anytime by
    # raising an PageNotFoundException exception.
    # Instead of the page, the 404 not found page will be rendered.
    #
    # This is particularly helpful with the dynamic routing feature
    # to avoid duplicated page content (different urls, same HTTP 200 code but same blank page).
    #
    class PageNotFound < ThreadSafe

      include Concerns::Helpers
      include Concerns::Rendering

      def _call
        begin
          self.next
        rescue Locomotive::Steam::PageNotFoundException => e
          # fetch the 404 error page...
          env['steam.page'] = page_finder.find('404')

          # ... and render it instead
          render_page
        end
      end

      private

      def page_finder
        services.page_finder
      end

    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 lib/locomotive/steam/middlewares/page_not_found.rb
locomotivecms_steam-1.8.0.alpha1 lib/locomotive/steam/middlewares/page_not_found.rb
locomotivecms_steam-1.7.1 lib/locomotive/steam/middlewares/page_not_found.rb
locomotivecms_steam-1.7.0 lib/locomotive/steam/middlewares/page_not_found.rb
locomotivecms_steam-1.6.1 lib/locomotive/steam/middlewares/page_not_found.rb
locomotivecms_steam-1.6.0 lib/locomotive/steam/middlewares/page_not_found.rb
locomotivecms_steam-1.6.0.rc1 lib/locomotive/steam/middlewares/page_not_found.rb
locomotivecms_steam-1.6.0.beta1 lib/locomotive/steam/middlewares/page_not_found.rb
locomotivecms_steam-1.5.3 lib/locomotive/steam/middlewares/page_not_found.rb
locomotivecms_steam-1.5.2 lib/locomotive/steam/middlewares/page_not_found.rb
locomotivecms_steam-1.5.1 lib/locomotive/steam/middlewares/page_not_found.rb
locomotivecms_steam-1.5.0 lib/locomotive/steam/middlewares/page_not_found.rb
locomotivecms_steam-1.5.0.rc1 lib/locomotive/steam/middlewares/page_not_found.rb