Merge branch 'release/2.2.0'

This commit is contained in:
Jonathan Abbett 2021-04-15 16:12:10 -04:00
commit d199dc1892
16 changed files with 153 additions and 27 deletions

View File

@ -1,9 +1,9 @@
language: ruby language: ruby
env: env:
- 'RAILS_VERSION=5.1' - 'RAILS_VERSION=5.2.0'
- 'RAILS_VERSION=5.2' - 'RAILS_VERSION=6.0.0'
- 'RAILS_VERSION=6.0' - 'RAILS_VERSION=6.1.0'
before_script: before_script:
- 'yarn' - 'yarn'
@ -11,4 +11,4 @@ before_script:
- 'RAILS_ENV=test bundle exec rake db:create' - 'RAILS_ENV=test bundle exec rake db:create'
- 'RAILS_ENV=test bundle exec rake db:migrate' - 'RAILS_ENV=test bundle exec rake db:migrate'
script: 'RAILS_ENV=test bundle exec rails test' script: 'RAILS_ENV=test bundle exec rake test'

View File

@ -11,7 +11,7 @@ end
rails_version = ENV['RAILS_VERSION'] || 'default' rails_version = ENV['RAILS_VERSION'] || 'default'
rails = case rails_version rails = case rails_version
when 'default' when 'default'
'~> 5.1' '~> 5.2'
when 'master' when 'master'
{github: 'rails/rails'} {github: 'rails/rails'}
else else

View File

@ -15,7 +15,8 @@ Abraham injects dynamically-generated [Shepherd](https://shepherdjs.dev/) JavaSc
## Requirements ## Requirements
Abraham needs to know the current user to track tour views, e.g. `current_user` from Devise. * Abraham needs to know the current user to track tour views, e.g. `current_user` from Devise.
* Abraham is tested on Rails 5.2, 6.0, and 6.1
## Installation ## Installation
@ -95,7 +96,7 @@ NB: You must specify a locale in the filename, even if you're only supporting on
### Tour content ### Tour content
A tour is composed of a series of steps. A step may have a title and must have a description. You may attach a step to a particular element on the page, and place the callout to the left, right, top, or bottom. A tour is composed of a series of steps. A step may have a title and must have a description. You may attach a step to a particular element on the page, and place the callout in a particular position (see below).
```yaml ```yaml
intro: intro:
@ -122,6 +123,18 @@ Abraham takes care of which buttons should appear with each step:
* "Exit" and "Next" buttons on intermediate steps * "Exit" and "Next" buttons on intermediate steps
* "Done" button on the last step * "Done" button on the last step
When you specify an `attachTo` element, use the `placement` option to choose where the callout should appear relative to that element:
* `bottom` / `bottom center`
* `bottom left`
* `bottom right`
* `center` / `middle` / `middle center`
* `left` / `middle left'
* `right` / `middle right`
* `top` / `top center`
* `top left`
* `top right`
Abraham tries to be helpful when your tour steps attach to page elements that are missing: Abraham tries to be helpful when your tour steps attach to page elements that are missing:
* If your first step is attached to a particular element, and that element is not present on the page, the tour won't start. ([#28](https://github.com/actmd/abraham/issues/28)) * If your first step is attached to a particular element, and that element is not present on the page, the tour won't start. ([#28](https://github.com/actmd/abraham/issues/28))
@ -161,10 +174,26 @@ If you have any trouble at all, please [submit an issue](https://github.com/actm
Contributions are welcome! Contributions are welcome!
Create a feature branch (using git-flow) and submit as a pull request. Create a feature branch (using git-flow) and submit as a pull request (with a base branch of `develop`).
Everyone interacting in Abraham's codebase, issue tracker, etc. is expected to follow the [Contributor Covenent Code of Conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct). Everyone interacting in Abraham's codebase, issue tracker, etc. is expected to follow the [Contributor Covenent Code of Conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct).
### Getting started with the source code
Abraham uses `rvm` with a gemset to ensure the appropriate version of Ruby and its dependencies. Make sure that's installed before you get started.
```
~ git clone git@github.com:actmd/abraham.git
Cloning into 'abraham'...
~ cd abraham
ruby-2.5.3 - #gemset created /Users/jon/.rvm/gems/ruby-2.5.3@abraham
ruby-2.5.3 - #generating abraham wrappers - please wait
~ bundle install
Bundle complete! 13 Gemfile dependencies, 73 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
~ yarn install
```
### Testing ### Testing
#### Testing locally #### Testing locally
@ -183,7 +212,7 @@ gem 'abraham', path: '~/Workspace/abraham'
#### Automated testing #### Automated testing
We use TravisCI to automatically test this engine with Rails 5.1, 5.2, and 6.0. For test history, venture over to [TravisCI](https://travis-ci.com/actmd/abraham). We use TravisCI to automatically test this engine with Rails 5.2, 6.0, and 6.1. For test history, venture over to [TravisCI](https://travis-ci.com/actmd/abraham).
### Releasing ### Releasing

View File

@ -26,10 +26,10 @@ require "bundler/gem_tasks"
require "rake/testtask" require "rake/testtask"
Rake::TestTask.new(:test) do |t| Rake::TestTask.new(:test) do |t|
t.libs << "lib"
t.libs << "test" t.libs << "test"
t.pattern = "test/**/*_test.rb" t.pattern = "test/**/*_test.rb"
t.verbose = false t.verbose = false
t.warning = false
end end
task default: :test task default: :test

View File

@ -1,8 +1,7 @@
//= require jquery
//= require js-cookie/src/js.cookie //= require js-cookie/src/js.cookie
//= require shepherd.js/dist/js/shepherd //= require shepherd.js/dist/js/shepherd
$(document).on('turbolinks:before-cache', function() { document.addEventListener('turbolinks:before-cache', function() {
// Remove visible product tours // Remove visible product tours
$(".shepherd-step").remove(); document.querySelectorAll(".shepherd-element").forEach(function(el) { el.remove() });
}); });

View File

@ -15,7 +15,6 @@ class AbrahamHistoriesController < ApplicationController
private private
# Never trust parameters from the scary internet, only allow the white list through.
def abraham_history_params def abraham_history_params
params.require(:abraham_history).permit(:controller_name, :action_name, :tour_name) params.require(:abraham_history).permit(:controller_name, :action_name, :tour_name)
end end

View File

@ -2,13 +2,11 @@
var tour = new Shepherd.Tour(<%= Rails.configuration.abraham.tour_options.html_safe unless Rails.configuration.abraham.tour_options.nil? %>); var tour = new Shepherd.Tour(<%= Rails.configuration.abraham.tour_options.html_safe unless Rails.configuration.abraham.tour_options.nil? %>);
tour.on("complete", function() { tour.on("complete", function() {
// ajax // Make AJAX call to save history of tour completion
return $.ajax({ return fetch("/abraham_histories/", {
url: "/abraham_histories/", method: "POST",
type: "POST", headers: { 'Content-Type': 'application/json' },
dataType: "json", body: JSON.stringify({
contentType: "application/json",
data: JSON.stringify({
authenticity_token: '<%= form_authenticity_token %>', authenticity_token: '<%= form_authenticity_token %>',
controller_name: '<%= controller_name %>', controller_name: '<%= controller_name %>',
action_name: '<%= action_name %>', action_name: '<%= action_name %>',

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module Abraham module Abraham
VERSION = "2.1.2" VERSION = "2.2.0"
end end

View File

@ -2,7 +2,6 @@
"name": "abraham", "name": "abraham",
"private": true, "private": true,
"dependencies": { "dependencies": {
"jquery": "^3.4.0",
"js-cookie": "^2.2.0", "js-cookie": "^2.2.0",
"shepherd.js": "^6.0.0-beta" "shepherd.js": "^6.0.0-beta"
} }

View File

@ -3,5 +3,6 @@
class DashboardController < ApplicationController class DashboardController < ApplicationController
def home; end def home; end
def other; end def other; end
def placement; end
def missing; end def missing; end
end end

View File

@ -0,0 +1,22 @@
<h1>Dashboard#placement</h1>
<p>Find me in app/views/dashboard/placement.html.erb</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae leo sagittis, sodales ante tincidunt, tincidunt tellus. Integer rutrum id quam maximus pellentesque. Morbi non justo ac dui mollis commodo nec sit amet neque. Sed et nunc quis nibh sagittis facilisis. Vivamus pharetra mauris in leo pulvinar, hendrerit pharetra eros mattis. Praesent eleifend convallis purus in facilisis. Donec molestie turpis sed ligula hendrerit malesuada. Curabitur porttitor eros ex, mattis malesuada ligula ullamcorper a. Donec accumsan at turpis ac tristique. Fusce finibus metus at lacinia sollicitudin. In efficitur mauris ante, nec lacinia nunc fermentum sit amet.</p>
<p>Cras a ullamcorper nisl, sed vulputate nisi. In hac habitasse platea dictumst. Sed pulvinar diam ultricies leo accumsan efficitur. Nullam pharetra velit risus, in vestibulum tortor finibus eget. Phasellus varius, ante sed maximus placerat, lectus nisl tempus ligula, sed tincidunt nulla odio ut augue. Phasellus dignissim, lacus non faucibus cursus, purus quam euismod mi, eu porta mi dui quis diam. Pellentesque in vulputate sem, a suscipit nunc. Etiam non elementum felis. Suspendisse rutrum, odio finibus rutrum ornare, orci quam consectetur massa, id bibendum lorem sem ut nulla. Nunc euismod varius ipsum quis commodo. Maecenas massa arcu, gravida a odio sed, tristique placerat nisl. In eget ligula tempor, iaculis felis at, ultricies augue. Praesent ac tellus sed risus dignissim ornare a at erat. Donec id finibus tortor, eget semper ante. Cras sed erat ultricies, pellentesque arcu vel, egestas ex.</p>
<p>Proin viverra arcu ut purus maximus gravida. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras rhoncus leo sit amet lacus gravida, vitae viverra nunc aliquam. Suspendisse porttitor neque ac libero mollis, ac fermentum enim iaculis. Suspendisse malesuada, diam eget elementum maximus, ex dolor dapibus diam, sed scelerisque urna nisi luctus odio. Sed sed porttitor elit, et gravida sapien. Ut mattis vehicula iaculis. Sed pretium lorem id erat gravida dapibus. Etiam vitae faucibus arcu, ac fermentum lorem.</p>
<div class="notice-me" style="width: 300px; height: 300px; margin-left: 400px; background-color: whitesmoke;">
a content with room for placement all around
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae leo sagittis, sodales ante tincidunt, tincidunt tellus. Integer rutrum id quam maximus pellentesque. Morbi non justo ac dui mollis commodo nec sit amet neque. Sed et nunc quis nibh sagittis facilisis. Vivamus pharetra mauris in leo pulvinar, hendrerit pharetra eros mattis. Praesent eleifend convallis purus in facilisis. Donec molestie turpis sed ligula hendrerit malesuada. Curabitur porttitor eros ex, mattis malesuada ligula ullamcorper a. Donec accumsan at turpis ac tristique. Fusce finibus metus at lacinia sollicitudin. In efficitur mauris ante, nec lacinia nunc fermentum sit amet.</p>
<p>Cras a ullamcorper nisl, sed vulputate nisi. In hac habitasse platea dictumst. Sed pulvinar diam ultricies leo accumsan efficitur. Nullam pharetra velit risus, in vestibulum tortor finibus eget. Phasellus varius, ante sed maximus placerat, lectus nisl tempus ligula, sed tincidunt nulla odio ut augue. Phasellus dignissim, lacus non faucibus cursus, purus quam euismod mi, eu porta mi dui quis diam. Pellentesque in vulputate sem, a suscipit nunc. Etiam non elementum felis. Suspendisse rutrum, odio finibus rutrum ornare, orci quam consectetur massa, id bibendum lorem sem ut nulla. Nunc euismod varius ipsum quis commodo. Maecenas massa arcu, gravida a odio sed, tristique placerat nisl. In eget ligula tempor, iaculis felis at, ultricies augue. Praesent ac tellus sed risus dignissim ornare a at erat. Donec id finibus tortor, eget semper ante. Cras sed erat ultricies, pellentesque arcu vel, egestas ex.</p>
<p>Proin viverra arcu ut purus maximus gravida. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras rhoncus leo sit amet lacus gravida, vitae viverra nunc aliquam. Suspendisse porttitor neque ac libero mollis, ac fermentum enim iaculis. Suspendisse malesuada, diam eget elementum maximus, ex dolor dapibus diam, sed scelerisque urna nisi luctus odio. Sed sed porttitor elit, et gravida sapien. Ut mattis vehicula iaculis. Sed pretium lorem id erat gravida dapibus. Etiam vitae faucibus arcu, ac fermentum lorem.</p>
<p>Sed mollis lectus a tellus interdum efficitur. Maecenas et mauris neque. Aliquam erat volutpat. Cras vehicula mollis varius. Aenean quis pretium libero, sit amet sodales urna. Maecenas a elementum neque. Maecenas quis pharetra ex. Maecenas at lorem odio. Etiam malesuada non justo non porta. Donec massa lectus, suscipit non leo nec, vulputate tincidunt turpis. Integer ullamcorper, diam id pharetra tempor, erat arcu semper ex, eu rhoncus libero mauris sed ipsum. Duis bibendum dui ipsum, at fringilla sapien gravida eget. Nam finibus blandit dui.</p>
<p>Integer accumsan enim eget leo placerat, at imperdiet libero porta. Nam in cursus sapien. Maecenas nunc enim, posuere a nulla bibendum, convallis aliquet odio. Curabitur a magna dolor. Vestibulum sed eros quis nisl aliquet condimentum. Phasellus ut odio a enim molestie gravida. Praesent sagittis mi sit amet lacus varius, vitae fermentum lorem iaculis. Ut fringilla turpis nec est fringilla finibus. Nullam accumsan tortor non massa tincidunt egestas. Nunc ac eros dignissim, mattis dui sed, mattis enim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec purus dolor, consectetur in dui vitae, aliquet aliquam orci. Nulla iaculis lorem et sem gravida, in sollicitudin elit dictum. Vestibulum consectetur sapien sed vestibulum venenatis. Cras id libero vel risus ullamcorper cursus in sit amet erat. </p>

View File

@ -13,6 +13,9 @@ module Dummy
# Application configuration should go into files in config/initializers # Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded.
# For Rails 5.2 - 6.0, we need to set this configuration
if (Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1) || (Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR < 1)
config.active_record.sqlite3.represent_boolean_as_integer = true config.active_record.sqlite3.represent_boolean_as_integer = true
end end
end
end end

View File

@ -3,6 +3,7 @@
Rails.application.routes.draw do Rails.application.routes.draw do
get "dashboard/home" get "dashboard/home"
get "dashboard/other" get "dashboard/other"
get "dashboard/placement"
get "dashboard/missing" get "dashboard/missing"
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html

View File

@ -0,0 +1,77 @@
intro:
steps:
1:
text: "bottom"
attachTo:
element: ".notice-me"
placement: "bottom"
2:
text: "bottom center"
attachTo:
element: ".notice-me"
placement: "bottom center"
3:
text: "bottom left"
attachTo:
element: ".notice-me"
placement: "bottom left"
4:
text: "bottom right"
attachTo:
element: ".notice-me"
placement: "bottom right"
5:
text: "center"
attachTo:
element: ".notice-me"
placement: "center"
6:
text: "left"
attachTo:
element: ".notice-me"
placement: "left"
7:
text: "middle"
attachTo:
element: ".notice-me"
placement: "middle"
8:
text: "middle center"
attachTo:
element: ".notice-me"
placement: "middle center"
9:
text: "middle left"
attachTo:
element: ".notice-me"
placement: "middle left"
10:
text: "middle right"
attachTo:
element: ".notice-me"
placement: "middle right"
11:
text: "right"
attachTo:
element: ".notice-me"
placement: "right"
12:
text: "top"
attachTo:
element: ".notice-me"
placement: "top"
13:
text: "top center"
attachTo:
element: ".notice-me"
placement: "top center"
14:
text: "top left"
attachTo:
element: ".notice-me"
placement: "top left"
15:
text: "top right"
attachTo:
element: ".notice-me"
placement: "top right"

View File

@ -1,5 +1,3 @@
# frozen_string_literal: true
# This file is auto-generated from the current state of the database. Instead # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to # of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition. # incrementally modify your database, and then regenerate this schema definition.