Sha256: f73b387ed26fa781fc75073f1c083daa385bef0b88dc8aeb39c60518e5ef4adf
Contents?: true
Size: 1.9 KB
Versions: 2
Compression:
Stored size: 1.9 KB
Contents
module PageletRails::Concerns::Controller extend ActiveSupport::Concern included do # order is important include PageletRails::Concerns::ResponseWrapper include PageletRails::Concerns::Routes include PageletRails::Concerns::Options include PageletRails::Concerns::Cache include PageletRails::Concerns::Placeholder prepend_before_action :merge_original_pagelet_options prepend_before_action :append_pagelet_view_paths layout :layout_name helper_method :pagelet_request? pagelet_options layout: 'container' end def layout_name layout = params[:layout] || pagelet_options.layout "pagelet_rails/#{layout}" end def pagelet_request? request.headers['X-Pagelet'].present? || params[:target_container] end private def append_pagelet_view_paths self.view_paths.unshift 'app/pagelets/' self.view_paths.unshift 'test/dummy/app/pagelets/' if Rails.env.test? # lookup_context.prefixes.clear view = "#{controller_name}/views" if lookup_context.prefixes.exclude?(view) lookup_context.prefixes.unshift "#{controller_name}/views" end # https://github.com/rails/actionpack-action_caching/issues/32 if lookup_context.formats.exclude?(:html) lookup_context.formats.unshift :html end end def merge_original_pagelet_options if params[:original_pagelet_options] opts = PageletRails::Encryptor.decode(params[:original_pagelet_options]) pagelet_options(opts) end end def pagelet_render_remotely? case pagelet_options.remote when :stream render_remotely = true when :turbolinks # render now if request coming from turbolinks is_turbolinks_request = request.headers['Turbolinks-Referrer'].present? render_remotely = !is_turbolinks_request when true, :ajax render_remotely = true else render_remotely = false end render_remotely end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pagelet_rails-0.1.3 | lib/pagelet_rails/concerns/controller.rb |
pagelet_rails-0.1.2 | lib/pagelet_rails/concerns/controller.rb |