Class: Locomotive::Steam::Middlewares::Page

Inherits:
ThreadSafe
  • Object
show all
Includes:
Helpers
Defined in:
lib/locomotive/steam/middlewares/page.rb

Overview

Retrieve a page from the path and the locale previously fetched from the request.

Instance Attribute Summary

Attributes inherited from ThreadSafe

#env

Instance Method Summary collapse

Methods included from Helpers

#decorate_entry, #default_liquid_context, #default_locale, #html?, #json?, #liquid_assigns, #live_editing?, #locale, #locales, #log, #make_local_path, #modify_path, #mounted_on, #page, #params, #path, #redirect_to, #render_response, #repositories, #request, #services, #site

Methods inherited from ThreadSafe

#call, #next

Instance Method Details

#_callObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/locomotive/steam/middlewares/page.rb', line 11

def _call
  return env['steam.page'] if env['steam.page']

  if page = fetch_page
    if !page.not_found?
      log "Found page \"#{page.title}\" [#{page.fullpath}]"
    else
      ActiveSupport::Notifications.instrument('steam.render.page_not_found', path: path, locale: locale, default_locale: default_locale)
      log "Page not found, rendering the 404 page.".magenta
    end
  end

  env['steam.page'] = page
end