diff --git a/app/views/paloma/_hook.html.erb b/app/views/paloma/_hook.html.erb index 58063a2..b69a96d 100644 --- a/app/views/paloma/_hook.html.erb +++ b/app/views/paloma/_hook.html.erb @@ -3,7 +3,6 @@
diff --git a/lib/paloma/action_controller_extension.rb b/lib/paloma/action_controller_extension.rb index e68660e..23e649f 100644 --- a/lib/paloma/action_controller_extension.rb +++ b/lib/paloma/action_controller_extension.rb @@ -12,7 +12,7 @@ module Paloma prepend_view_path "#{Paloma.root}/app/views/" before_filter :track_paloma_request - after_filter :append_paloma_hook, :if => :html_is_rendered? + after_filter :append_paloma_hook, :if => :not_redirect? end end @@ -138,9 +138,8 @@ module Paloma end - def html_is_rendered? - not_redirect = self.status != 302 - [nil, 'text/html'].include?(response.content_type) && not_redirect + def not_redirect? + self.status != 302 end diff --git a/paloma.gemspec b/paloma.gemspec index 145db7f..41dbc80 100644 --- a/paloma.gemspec +++ b/paloma.gemspec @@ -17,4 +17,6 @@ Gem::Specification.new do |s| s.add_development_dependency 'rspec-rails', ['~> 2.0'] s.add_development_dependency 'capybara', ['~> 1.0'] s.add_development_dependency 'jasmine-rails', ['~> 0.4.5'] + s.add_development_dependency 'turbolinks', ['~> 2.2.2'] + s.add_development_dependency 'execjs', ['~> 2.1.0'] end diff --git a/test_app/app/assets/javascripts/application.js b/test_app/app/assets/javascripts/application.js index 9fd060e..added85 100644 --- a/test_app/app/assets/javascripts/application.js +++ b/test_app/app/assets/javascripts/application.js @@ -12,6 +12,7 @@ // //= require jquery //= require jquery_ujs +//= require turbolinks //= require paloma //= require_tree . diff --git a/test_app/app/views/layouts/application.html.erb b/test_app/app/views/layouts/application.html.erb index d4557d8..7bc31c2 100644 --- a/test_app/app/views/layouts/application.html.erb +++ b/test_app/app/views/layouts/application.html.erb @@ -1,12 +1,28 @@ - TestApp + Paloma Test App <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> +

Paloma Test App

+ + + +
<%= yield %> diff --git a/test_app/spec/spec_helper.rb b/test_app/spec/spec_helper.rb index 96161bc..a24fe16 100644 --- a/test_app/spec/spec_helper.rb +++ b/test_app/spec/spec_helper.rb @@ -33,5 +33,5 @@ end def request - page.evaluate_script 'Paloma.engine.lastRequest' + page.evaluate_script 'Paloma.engine.getRequest()' end \ No newline at end of file diff --git a/vendor/assets/javascripts/paloma/engine.js b/vendor/assets/javascripts/paloma/engine.js index 2dd22a3..3b78467 100644 --- a/vendor/assets/javascripts/paloma/engine.js +++ b/vendor/assets/javascripts/paloma/engine.js @@ -2,31 +2,41 @@ var Engine = function(config){ this.factory = config.factory; - this.lastRequest = null; + this._request = null; }; - - Engine.prototype.request = function(resource, action, params){ - this.lastRequest = null; - - var Controller = this.factory.get(resource); + Engine.prototype.start = function(){ + var resource = this._request['controller'], + Controller = this.factory.get(resource); if (!Controller){ return Paloma.warn('Paloma: undefined controller -> ' + resource); } - var controller = new Controller(params); + var controller = new Controller( this._request['params'] ), + action = this._request['action'], + params = this._request['params']; if (!controller[action]){ return Paloma.warn('Paloma: undefined action <' + action + '> for <' + resource + '> controller'); } + Paloma.log('Paloma: Execute ' + resource + '#' + action + ' with'); Paloma.log(params); - controller[action](); - this.lastRequest = {controller: resource, action: action, params: params}; + controller[ this._request['action'] ](); + }; + + + Engine.prototype.setRequest = function(resource, action, params){ + this._request = {controller: resource, action: action, params: params}; + }; + + + Engine.prototype.getRequest = function(key){ + return (!key ? this._request : this._request[key]); };