module Mumuki::Laboratory::Controllers::EmbeddedMode

This mixin provides support for implementing the embedded mode - as opposed to the standalone mode -in which the mumuki pages

* are displayed used a simplified layout, called `embedded.html.erb`
* are served using `X-Frame-Options` that allow them to be used within
  an iframe

Not all organizations can be emedded - only those that have the `embeddable?` setting set.

This mixin provides two sets of methods:

Public Instance Methods

embedded_mode?() click to toggle source
# File lib/mumuki/laboratory/controllers/embedded_mode.rb, line 26
def embedded_mode?
  @embedded_mode ||= params[:embed] == 'true' && Organization.current.embeddable?
end
enable_embedded_rendering() click to toggle source
# File lib/mumuki/laboratory/controllers/embedded_mode.rb, line 34
def enable_embedded_rendering
  return unless embedded_mode?
  allow_parent_iframe!
  render layout: 'embedded'
end
standalone_mode?() click to toggle source
# File lib/mumuki/laboratory/controllers/embedded_mode.rb, line 30
def standalone_mode?
  !embedded_mode?
end

Private Instance Methods

allow_parent_iframe!() click to toggle source
# File lib/mumuki/laboratory/controllers/embedded_mode.rb, line 42
def allow_parent_iframe!
  response.delete_header 'X-Frame-Options'
end