lib/pagelet_rails/concerns/controller.rb in pagelet_rails-0.1.3 vs lib/pagelet_rails/concerns/controller.rb in pagelet_rails-0.1.4

- old
+ new

@@ -10,13 +10,17 @@ include PageletRails::Concerns::Placeholder prepend_before_action :merge_original_pagelet_options prepend_before_action :append_pagelet_view_paths + append_view_path 'app/pagelets/' + append_view_path 'test/dummy/app/pagelets/' if Rails.env.test? + layout :layout_name helper_method :pagelet_request? + helper_method :pagelet_encoded_original_options pagelet_options layout: 'container' end def layout_name @@ -30,13 +34,10 @@ 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 @@ -52,18 +53,25 @@ opts = PageletRails::Encryptor.decode(params[:original_pagelet_options]) pagelet_options(opts) end end + def pagelet_encoded_original_options + encode_data = pagelet_options.original_options.to_h.except('remote') + PageletRails::Encryptor.encode(encode_data) + 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 + when :ssi render_remotely = true else render_remotely = false end