diff --git a/.ruby-version b/.ruby-version index f90b1af..0bee604 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.2 +2.3.3 diff --git a/Gemfile b/Gemfile index aa05482..feab6f3 100644 --- a/Gemfile +++ b/Gemfile @@ -14,3 +14,6 @@ gemspec # To use a debugger # gem 'byebug', group: [:development, :test] + +# Avoid the 'multiple sources' confusion +gem 'rails-assets-tether', :source => 'http://rails-assets.org/' diff --git a/Gemfile.lock b/Gemfile.lock index b1a98cc..a38bc96 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,6 +4,7 @@ PATH abraham (1.0.0) jquery-rails rails (~> 5.0.0, >= 5.0.0.1) + rails-assets-js-cookie (~> 2.1) rails-assets-shepherd.js (~> 1.8) sass-rails (~> 5.0) @@ -51,7 +52,7 @@ GEM arel (7.1.4) ast (2.3.0) builder (3.2.2) - concurrent-ruby (1.0.2) + concurrent-ruby (1.0.3) erubis (2.7.0) globalid (0.3.7) activesupport (>= 4.1.0) @@ -69,7 +70,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mini_portile2 (2.1.0) - minitest (5.9.1) + minitest (5.10.1) nio4r (1.2.1) nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) @@ -91,9 +92,10 @@ GEM bundler (>= 1.3.0, < 2.0) railties (= 5.0.0.1) sprockets-rails (>= 2.0.0) + rails-assets-js-cookie (2.1.3) rails-assets-shepherd.js (1.8.1) rails-assets-tether (>= 1.0.1, < 2) - rails-assets-tether (1.3.7) + rails-assets-tether (1.4.0) rails-dom-testing (2.0.1) activesupport (>= 4.2.0, < 6.0) nokogiri (~> 1.6.0) @@ -106,7 +108,7 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.1.0) - rake (11.3.0) + rake (12.0.0) rubocop (0.45.0) parser (>= 2.3.1.1, < 3.0) powerpack (~> 0.1) @@ -129,7 +131,7 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.3.12) - thor (0.19.1) + thor (0.19.4) thread_safe (0.3.5) tilt (2.0.5) tzinfo (1.2.2) @@ -144,6 +146,7 @@ PLATFORMS DEPENDENCIES abraham! + rails-assets-tether! rubocop sqlite3 diff --git a/README.md b/README.md index 1028e2d..9d79a74 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,10 @@ $ bundle install $ rails generate abraham:install ``` -Require Shepherd.js in `app/assets/javascripts/application.js` +Require `abraham` in `app/assets/javascripts/application.js` ``` -//= require shepherd.js.js +//= require abraham ``` Require a Shepherd.js CSS theme in `app/assets/stylesheets/application.scss` @@ -117,3 +117,11 @@ Abraham takes care of which buttons should appear with each step: ### Testing your tours Abraham loads tour definitions once when you start your server. Restart your server to see tour changes. + +If you'd like to run JavaScript integrations tests without the Abraham tours getting in the way, clear the Abraham configuration in your test helper, e.g. + +``` +Rails.application.configure do + config.abraham.tours = {} +end +``` diff --git a/abraham.gemspec b/abraham.gemspec index 68745aa..aac7376 100644 --- a/abraham.gemspec +++ b/abraham.gemspec @@ -10,9 +10,9 @@ Gem::Specification.new do |s| s.version = Abraham::VERSION s.authors = ['Jonathan Abbett'] s.email = ['jonathan@act.md'] - s.homepage = 'http://getabraham.com' - s.summary = 'Trackable application tours for Rails with i18n support.' - s.description = 'Guide your users in the one true path.' + s.homepage = 'https://github.com/actmd/abraham' + s.summary = 'Trackable application tours for Rails with i18n support, based on Shepherd.js.' + s.description = 'Trackable application tours for Rails with i18n support, based on Shepherd.js.' s.license = 'MIT' s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md'] @@ -20,6 +20,7 @@ Gem::Specification.new do |s| s.add_dependency 'rails', '~> 5.0.0', '>= 5.0.0.1' s.add_dependency 'sass-rails', '~> 5.0' s.add_dependency 'rails-assets-shepherd.js', '~> 1.8' + s.add_dependency 'rails-assets-js-cookie', '~> 2.1' s.add_development_dependency 'sqlite3' s.add_development_dependency 'rubocop' diff --git a/app/assets/javascripts/abraham/index.js b/app/assets/javascripts/abraham/index.js new file mode 100644 index 0000000..f16e3f7 --- /dev/null +++ b/app/assets/javascripts/abraham/index.js @@ -0,0 +1,10 @@ +//= require jquery +//= require jquery_ujs +//= require js-cookie +//= require tether +//= require shepherd.js.js + +$(document).on('turbolinks:before-cache', function() { + // Remove visible product tours + $(".shepherd-step").remove(); +}); diff --git a/app/views/application/_abraham.html.erb b/app/views/application/_abraham.html.erb index cb6df8c..9b34c20 100644 --- a/app/views/application/_abraham.html.erb +++ b/app/views/application/_abraham.html.erb @@ -20,6 +20,10 @@ }); }); + tour.on("cancel", function() { + Cookies.set('abraham-<%= controller_name %>-<%= action_name %>-<%= tour_name %>', 'later'); + }); + <% steps.each_with_index do |(key, step), index| %> tour.addStep('step-<%= key %>', { <% if step.key?('title') %> @@ -45,5 +49,8 @@ }); <% end %> - tour.start(); + // Don't start the tour if the user dismissed it once this session + if (!Cookies.get('abraham-<%= controller_name %>-<%= action_name %>-<%= tour_name %>')) { + tour.start(); + } diff --git a/lib/abraham/engine.rb b/lib/abraham/engine.rb index b1aed73..94d287d 100644 --- a/lib/abraham/engine.rb +++ b/lib/abraham/engine.rb @@ -2,6 +2,7 @@ require 'rubygems' require 'rails-assets-shepherd.js' require 'jquery-rails' +require 'rails-assets-js-cookie' module Abraham class Engine < ::Rails::Engine diff --git a/lib/abraham/version.rb b/lib/abraham/version.rb index 89740f8..0a8df9d 100644 --- a/lib/abraham/version.rb +++ b/lib/abraham/version.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true module Abraham - VERSION = '1.0.0' + VERSION = '1.1.0' end diff --git a/test/dummy/app/assets/javascripts/application.js b/test/dummy/app/assets/javascripts/application.js index 79a314e..5c68c7d 100644 --- a/test/dummy/app/assets/javascripts/application.js +++ b/test/dummy/app/assets/javascripts/application.js @@ -10,8 +10,5 @@ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // -//= require jquery -//= require jquery_ujs -//= require tether -//= require shepherd.js.js +//= require abraham //= require_tree . diff --git a/test/dummy/db/development.sqlite3 b/test/dummy/db/development.sqlite3 index ad2b360..2b24f4f 100644 Binary files a/test/dummy/db/development.sqlite3 and b/test/dummy/db/development.sqlite3 differ