Module: Mumuki::Laboratory::Controllers::EmbeddedMode

Extended by:
ActiveSupport::Concern
Included in:
ApplicationController
Defined in:
lib/mumuki/laboratory/controllers/embedded_mode.rb

Overview

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:

  • ‘embedded_mode?` / `standalone_mode?`, which are helpers aimed to be used by views

    and change very specific rendering details in one or the other mode
    
  • ‘enable_embedded_rendering`, which is designed to be called from main-views controller-methods that

    actually support embedded mode.
    

Instance Method Summary collapse

Instance Method Details

#embedded_mode?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/mumuki/laboratory/controllers/embedded_mode.rb', line 26

def embedded_mode?
  @embedded_mode ||= params[:embed] == 'true' && Organization.current.embeddable?
end

#enable_embedded_renderingObject



34
35
36
37
38
# 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?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/mumuki/laboratory/controllers/embedded_mode.rb', line 30

def standalone_mode?
  !embedded_mode?
end