diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 452ebb3..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,7 +0,0 @@ -version: 2 -updates: -- package-ecosystem: bundler - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml deleted file mode 100644 index 4fcd2fa..0000000 --- a/.github/workflows/ruby.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Ruby - -on: - push: - branches: [ master, develop ] - pull_request: - branches: "*" - -jobs: - test: - - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - include: - - rails-version: "5.2.0" - - rails-version: "6.0.0" - - rails-version: "6.1.0" - - env: - RAILS_VERSION: ${{ matrix.rails-version }} - - steps: - - uses: actions/checkout@v2 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - - name: Generate lockfile - run: bundle lock - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: vendor/bundle - key: bundle-${{ hashFiles('Gemfile.lock') }} - - name: Install dependencies - run: | - bundle config path vendor/bundle - gem install bundler --conservative - bundle check || bundle install - - name: Install JS dependencies - run: yarn - - name: Create database - run: bundle exec rake db:create db:migrate - - name: Run tests - run: bundle exec rake test \ No newline at end of file diff --git a/.ruby-gemset b/.ruby-gemset index dc1d287..1c0873b 100644 --- a/.ruby-gemset +++ b/.ruby-gemset @@ -1 +1 @@ -abraham +walter diff --git a/.ruby-version b/.ruby-version index aedc15b..57cf282 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.5.3 +2.6.5 diff --git a/Gemfile b/Gemfile index 43849c9..3282bf9 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ rails = case rails_version end gem 'rails', rails -# Declare your gem's dependencies in abraham.gemspec. +# Declare your gem's dependencies in walter.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec diff --git a/README.md b/README.md index 0b395e2..0877c82 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,31 @@ -# Abraham +# Walter -[![Build Status](https://travis-ci.com/actmd/abraham.svg?branch=master)](https://travis-ci.com/actmd/abraham) +[![Build Status](https://travis-ci.com/actmd/walter.svg?branch=master)](https://travis-ci.com/actmd/walter) -_Guide your users in the one true path._ +_Product tours like a badass._ ![Watercolor Sheep](https://upload.wikimedia.org/wikipedia/commons/e/e4/Watercolor_Sheep_Drawing.jpg) -Abraham makes it easy to show guided tours to users of your Rails application. When Abraham shows a tour, it keeps track of whether the user has completed it (so it doesn't get shown again) or dismissed it for later (so it reappears in a future user session). +Walter makes it easy to show guided tours to users of your Rails application. When Walter shows a tour, it keeps track of whether the user has completed it (so it doesn't get shown again) or dismissed it for later (so it reappears in a future user session). * Define tour content with simple YAML files, in any/many languages. * Organize tours by controller and action. * Trigger tours automatically on page load or manually via JavaScript method. * Built with the [Shepherd JS](https://shepherdjs.dev/) library. Plays nicely with Turbolinks. * Ships with two basic CSS themes (default & dark) — or write your own +* Show video/html content in your ## Requirements -* 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 +* Walter needs to know the current user to track tour views, e.g. `current_user` from Devise. +* Walter is tested on Rails 5.2, 6.0, and 6.1 ## Installation -Add `abraham` to your Gemfile: +Add `walter` to your Gemfile: ``` -gem 'abraham' +gem 'walter' ``` @@ -32,7 +33,7 @@ Install the gem and run the installer: ``` $ bundle install -$ rails generate abraham:install +$ rails generate walter:install $ rails db:migrate ``` @@ -42,24 +43,24 @@ Install the JavaScript dependencies: $ yarn add js-cookie@^2.2.0 shepherd.js@^6.0.0-beta ``` -Require `abraham` in `app/assets/javascripts/application.js` +Require `walter` in `app/assets/javascripts/application.js` ``` -//= require abraham +//= require walter ``` Require a CSS theme in `app/assets/stylesheets/application.scss` ``` -*= require abraham/theme-default +*= require walter/theme-default ``` -Abraham provides the following themes: +Walter provides the following themes: - `theme-default` - `theme-dark` -Update `config/abraham.yml` if you choose a different theme: +Update `config/walter.yml` if you choose a different theme: ``` defaults: &defaults @@ -68,17 +69,17 @@ defaults: &defaults You can also [write your own Shepherd theme](https://shepherdjs.dev/docs/tutorial-03-styling.html) based on Shepherd's [default CSS](https://github.com/shipshapecode/shepherd/releases/download/v6.0.0-beta.1/shepherd.css). -Tell Abraham where to insert its generated JavaScript in `app/views/layouts/application.html.erb`, just before the closing `body` tag: +Tell Walter where to insert its generated JavaScript in `app/views/layouts/application.html.erb`, just before the closing `body` tag: ```erb -<%= abraham_tour %> +<%= walter_tour %> ``` ## Defining your tours -Define your tours in the `config/tours` directory corresponding to the views defined in your application. Its directory structure mirrors your application's controllers, and the tour files mirror your actions/views. (As of version 2.4.0, Abraham respects controllers organized into modules.) +Define your tours in the `config/tours` directory corresponding to the views defined in your application. Its directory structure mirrors your application's controllers, and the tour files mirror your actions/views. (As of version 2.4.0, Walter respects controllers organized into modules.) ``` config/ @@ -125,7 +126,7 @@ intro: placement: "bottom" ``` -Abraham takes care of which buttons should appear with each step: +Walter takes care of which buttons should appear with each step: * "Later" and "Continue" buttons on the first step * "Exit" and "Next" buttons on intermediate steps @@ -143,14 +144,14 @@ When you specify an `attachTo` element, use the `placement` option to choose whe * `top left` * `top right` -Abraham tries to be helpful when your tour steps attach to page elements that are missing: +Walter 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 tour has an intermediate step attached to a missing element, Abraham will skip that step and automatically show the next. ([#6](https://github.com/actmd/abraham/issues/6)) +* 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/walter/issues/28)) +* If your tour has an intermediate step attached to a missing element, Walter will skip that step and automatically show the next. ([#6](https://github.com/actmd/walter/issues/6)) ### Automatic vs. manual tours -By default, Abraham will automatically start a tour that the current user hasn't seen yet. +By default, Walter will automatically start a tour that the current user hasn't seen yet. You can instead define a tour to be triggered manually using the `trigger` option: ```yml @@ -161,14 +162,14 @@ walkthrough: text: "This walkthrough will show you how to..." ``` -This tour will not start automatically; instead, use the `Abraham.startTour` method with the tour name: +This tour will not start automatically; instead, use the `Walter.startTour` method with the tour name: ``` ``` @@ -177,50 +178,50 @@ This tour will not start automatically; instead, use the `Abraham.startTour` met ``` ``` ### Testing your tours -Abraham loads tour definitions once when you start your server. Restart your server to see tour changes. +Walter 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. +If you'd like to run JavaScript integrations tests without the Walter tours getting in the way, clear the Walter configuration in your test helper, e.g. ``` Rails.application.configure do - config.abraham.tours = {} + config.walter.tours = {} end ``` ## Full example -We provide a [small example app](https://github.com/actmd/abraham-example) that implements Abraham, so you can see it in action. +We provide a [small example app](https://github.com/actmd/walter-example) that implements Walter, so you can see it in action. ## Upgrading ### From version 2.3.0 or earlier -Abraham 2.4.0 introduced an updated initializer that supports controllers organized into modules. +Walter 2.4.0 introduced an updated initializer that supports controllers organized into modules. Rerun the generator with these options to replace the old initializer: ``` -$ rails generate abraham:install --skip-migration --skip-config +$ rails generate walter:install --skip-migration --skip-config ``` ### From version 1 -Abraham v1 was built using Shepherd 1.8, v2 now uses Shepherd 6 – quite a jump, yes. +Walter v1 was built using Shepherd 1.8, v2 now uses Shepherd 6 – quite a jump, yes. -If you were using Abraham v1, you'll want to take the following steps to upgrade: +If you were using Walter v1, you'll want to take the following steps to upgrade: 1. Update your gem to the latest version 1. Fix your yarn dependencies to use the right versions -1. Shepherd no longer provides a set of themes. Abraham maintains two of the legacy themes: default and dark. You'll want to choose one of those or migrate your theme to the new Shepherd structure. -1. Abraham now exposes the entire Shepherd configuration object, so your `abraham.yml` file should now fully define the `tour_options` value instead of `default_theme` -1. There's been a slight change to `initializers/abraham.rb`. Replace yours with [the latest](https://github.com/actmd/abraham/blob/master/lib/generators/abraham/templates/initializer.rb). +1. Shepherd no longer provides a set of themes. Walter maintains two of the legacy themes: default and dark. You'll want to choose one of those or migrate your theme to the new Shepherd structure. +1. Walter now exposes the entire Shepherd configuration object, so your `walter.yml` file should now fully define the `tour_options` value instead of `default_theme` +1. There's been a slight change to `initializers/walter.rb`. Replace yours with [the latest](https://github.com/actmd/walter/blob/master/lib/generators/walter/templates/initializer.rb). -If you have any trouble at all, please [submit an issue](https://github.com/actmd/abraham/issues) for assistance! +If you have any trouble at all, please [submit an issue](https://github.com/actmd/walter/issues) for assistance! ## Contributing @@ -228,18 +229,18 @@ Contributions are welcome! 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 Walter'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. +Walter 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 +~ git clone git@github.com:actmd/walter.git +Cloning into 'walter'... +~ cd walter +ruby-2.5.3 - #gemset created /Users/jon/.rvm/gems/ruby-2.5.3@walter +ruby-2.5.3 - #generating walter 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. @@ -256,10 +257,10 @@ Please note that if you change anything in the `lib/generators` folder (i.e. con Final testing should be done in a standalone Rails app, following the README instructions. -To install the `abraham` gem with a local path: +To install the `walter` gem with a local path: ``` -gem 'abraham', path: '~/Workspace/abraham' +gem 'walter', path: '~/Workspace/walter' ``` #### Automated testing @@ -274,13 +275,13 @@ Create a git-flow release: $ git flow release start VERSION_NUMBER ``` -Edit `lib/abraham/version.rb` and increase the version number. +Edit `lib/walter/version.rb` and increase the version number. Build the gem and push to Rubygems: ``` $ rake build -$ gem push pkg/abraham-VERSION_NUMBER.gem +$ gem push pkg/walter-VERSION_NUMBER.gem ``` Finish the git-flow release and push to GitHub: diff --git a/Rakefile b/Rakefile index 981577e..5409348 100644 --- a/Rakefile +++ b/Rakefile @@ -10,7 +10,7 @@ require "rdoc/task" RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = "rdoc" - rdoc.title = "Abraham" + rdoc.title = "Walter" rdoc.options << "--line-numbers" rdoc.rdoc_files.include("README.md") rdoc.rdoc_files.include("lib/**/*.rb") diff --git a/app/assets/config/abraham_manifest.js b/app/assets/config/walter_manifest.js similarity index 100% rename from app/assets/config/abraham_manifest.js rename to app/assets/config/walter_manifest.js diff --git a/app/assets/javascripts/abraham/index.js b/app/assets/javascripts/abraham/index.js deleted file mode 100644 index 0a539eb..0000000 --- a/app/assets/javascripts/abraham/index.js +++ /dev/null @@ -1,28 +0,0 @@ -//= require js-cookie/src/js.cookie -//= require shepherd.js/dist/js/shepherd - -var Abraham = new Object(); - -Abraham.tours = {}; -Abraham.incompleteTours = []; -Abraham.startTour = function(tourName) { - if (!Shepherd.activeTour) { - Abraham.tours[tourName].start(); - } -}; -Abraham.startNextIncompleteTour = function() { - if (Abraham.incompleteTours.length) { - Abraham.tours[Abraham.incompleteTours[0]].checkAndStart(); - } -}; - -document.addEventListener("DOMContentLoaded", Abraham.startNextIncompleteTour); -document.addEventListener("turbolinks:load", Abraham.startNextIncompleteTour); - -document.addEventListener('turbolinks:before-cache', function() { - // Remove visible product tours - document.querySelectorAll(".shepherd-element").forEach(function(el) { el.remove() }); - // Clear Abraham data - Abraham.tours = {}; - Abraham.incompleteTours = []; -}); diff --git a/app/assets/javascripts/abraham/.keep b/app/assets/javascripts/walter/.keep similarity index 100% rename from app/assets/javascripts/abraham/.keep rename to app/assets/javascripts/walter/.keep diff --git a/app/assets/javascripts/walter/index.js b/app/assets/javascripts/walter/index.js new file mode 100644 index 0000000..0e0a5e0 --- /dev/null +++ b/app/assets/javascripts/walter/index.js @@ -0,0 +1,28 @@ +//= require js-cookie/src/js.cookie +//= require shepherd.js/dist/js/shepherd + +var Walter = new Object(); + +Walter.tours = {}; +Walter.incompleteTours = []; +Walter.startTour = function(tourName) { + if (!Shepherd.activeTour) { + Walter.tours[tourName].start(); + } +}; +Walter.startNextIncompleteTour = function() { + if (Walter.incompleteTours.length) { + Walter.tours[Walter.incompleteTours[0]].checkAndStart(); + } +}; + +document.addEventListener("DOMContentLoaded", Walter.startNextIncompleteTour); +document.addEventListener("turbolinks:load", Walter.startNextIncompleteTour); + +document.addEventListener('turbolinks:before-cache', function() { + // Remove visible product tours + document.querySelectorAll(".shepherd-element").forEach(function(el) { el.remove() }); + // Clear Walter data + Walter.tours = {}; + Walter.incompleteTours = []; +}); diff --git a/app/assets/stylesheets/abraham/.keep b/app/assets/stylesheets/walter/.keep similarity index 100% rename from app/assets/stylesheets/abraham/.keep rename to app/assets/stylesheets/walter/.keep diff --git a/app/assets/stylesheets/abraham/_common.scss b/app/assets/stylesheets/walter/_common.scss similarity index 99% rename from app/assets/stylesheets/abraham/_common.scss rename to app/assets/stylesheets/walter/_common.scss index 2ebfc0a..8c56ed3 100644 --- a/app/assets/stylesheets/abraham/_common.scss +++ b/app/assets/stylesheets/walter/_common.scss @@ -108,7 +108,7 @@ .shepherd-element { border-radius: 5px; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); - max-width: 400px; + //max-width: 600px; outline: none; z-index: 9999; line-height: 1.2; @@ -191,4 +191,4 @@ .shepherd-modal-overlay-container.shepherd-modal-is-visible path { pointer-events: all; -} \ No newline at end of file +} diff --git a/app/assets/stylesheets/walter/shepherd.css b/app/assets/stylesheets/walter/shepherd.css new file mode 100644 index 0000000..c1ab480 --- /dev/null +++ b/app/assets/stylesheets/walter/shepherd.css @@ -0,0 +1,117 @@ +.shepherd-button:hover { + background: #16202D; + color: #ffffff; +} + +.shepherd-button.shepherd-button-secondary { + background: #CAD5D5; +} + +.shepherd-button.shepherd-button-secondary:hover { + color: #CAD5D5; + background: #16202D; +} + +.shepherd-cancel-icon { + font-family: "GT Pressura", sans-serif; +} + +.shepherd-element { + border: solid 4px #16202D; +} + +.shepherd-element, +.shepherd-header, +.shepherd-footer { + border-radius: 0; +} + +.shepherd-element .shepherd-arrow { + border-width: 0; + height: auto; + width: auto; +} + +.shepherd-arrow::before { + display: none; +} + +.shepherd-element .shepherd-arrow:after { + content: url('../assets/img/arrow.svg'); + display: inline-block; +} + +.shepherd-element[data-popper-placement^='top'] .shepherd-arrow, +.shepherd-element.shepherd-pinned-top .shepherd-arrow { + bottom: -35px; +} + +.shepherd-element[data-popper-placement^='top'] .shepherd-arrow:after, +.shepherd-element.shepherd-pinned-top .shepherd-arrow:after { + transform: rotate(270deg); +} + +.shepherd-element[data-popper-placement^='bottom'] .shepherd-arrow { + top: -35px; +} + +.shepherd-element[data-popper-placement^='bottom'] .shepherd-arrow:after { + transform: rotate(90deg); +} + +.shepherd-element[data-popper-placement^='left'] .shepherd-arrow, +.shepherd-element.shepherd-pinned-left .shepherd-arrow { + right: -35px; +} + +.shepherd-element[data-popper-placement^='left'] .shepherd-arrow:after, +.shepherd-element.shepherd-pinned-left .shepherd-arrow:after { + transform: rotate(180deg); +} + +.shepherd-element[data-popper-placement^='right'] .shepherd-arrow, +.shepherd-element.shepherd-pinned-right .shepherd-arrow { + left: -35px; +} + +.shepherd-footer { + padding: 0; +} + +.shepherd-footer button:not(:last-of-type) { + border-right: solid 4px #16202D; +} + +.shepherd-has-title .shepherd-content .shepherd-cancel-icon { + margin-top: -7px; +} + +.shepherd-has-title .shepherd-content .shepherd-header { + background: transparent; + font-family: "GT Pressura", sans-serif; + padding-bottom: 0; + padding-left: 2rem; +} + +.shepherd-has-title .shepherd-content .shepherd-header .shepherd-title { + font-size: 1.2rem; + text-transform: uppercase; +} + +.shepherd-text { + font-size: 1.2rem; + padding: 2rem; +} + +.shepherd-text a, .shepherd-text a:visited, +.shepherd-text a:active { + border-bottom: 1px dotted; + border-bottom-color: rgba(0, 0, 0, 0.75); + color: rgba(0, 0, 0, 0.75); + text-decoration: none; +} + +.shepherd-text a:hover, .shepherd-text a:visited:hover, +.shepherd-text a:active:hover { + border-bottom-style: solid; +} diff --git a/app/assets/stylesheets/abraham/theme-dark.scss b/app/assets/stylesheets/walter/theme-dark.scss similarity index 100% rename from app/assets/stylesheets/abraham/theme-dark.scss rename to app/assets/stylesheets/walter/theme-dark.scss diff --git a/app/assets/stylesheets/abraham/theme-default.scss b/app/assets/stylesheets/walter/theme-default.scss similarity index 99% rename from app/assets/stylesheets/abraham/theme-default.scss rename to app/assets/stylesheets/walter/theme-default.scss index 68f6663..3d18a84 100755 --- a/app/assets/stylesheets/abraham/theme-default.scss +++ b/app/assets/stylesheets/walter/theme-default.scss @@ -37,4 +37,4 @@ &.shepherd-pinned-left .shepherd-arrow { border-left-color: #fff; } -} \ No newline at end of file +} diff --git a/app/controllers/abraham_histories_controller.rb b/app/controllers/abraham_histories_controller.rb deleted file mode 100644 index 0b76042..0000000 --- a/app/controllers/abraham_histories_controller.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AbrahamHistoriesController < ApplicationController - def create - @abraham_history = AbrahamHistory.new(abraham_history_params) - @abraham_history.creator_id = current_user.id - respond_to do |format| - if @abraham_history.save - format.json { render json: @abraham_history, status: :created } - else - format.json { render json: @abraham_history.errors, status: :unprocessable_entity } - end - end - end - - private - - def abraham_history_params - params.require(:abraham_history).permit(:controller_name, :action_name, :tour_name) - end -end diff --git a/app/controllers/walter_histories_controller.rb b/app/controllers/walter_histories_controller.rb new file mode 100644 index 0000000..f74e9de --- /dev/null +++ b/app/controllers/walter_histories_controller.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class WalterHistoriesController < ApplicationController + def create + @walter_history = WalterHistory.new(walter_history_params) + @walter_history.creator_id = current_user.id + respond_to do |format| + if @walter_history.save + format.json { render json: @walter_history, status: :created } + else + format.json { render json: @walter_history.errors, status: :unprocessable_entity } + end + end + end + + private + + def walter_history_params + params.require(:walter_history).permit(:controller_name, :action_name, :tour_name) + end +end diff --git a/app/helpers/abraham_helper.rb b/app/helpers/walter_helper.rb similarity index 62% rename from app/helpers/abraham_helper.rb rename to app/helpers/walter_helper.rb index 7d4db7b..b1be79d 100644 --- a/app/helpers/abraham_helper.rb +++ b/app/helpers/walter_helper.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -module AbrahamHelper - def abraham_tour +module WalterHelper + def walter_tour # Do we have tours for this controller/action in the user's locale? - tours = Rails.configuration.abraham.tours["#{controller_path}.#{action_name}.#{I18n.locale}"] + tours = Walter.tours["#{controller_path}.#{action_name}.#{I18n.locale}"] # Otherwise, default to the default locale - tours ||= Rails.configuration.abraham.tours["#{controller_path}.#{action_name}.#{I18n.default_locale}"] + tours ||= Walter.tours["#{controller_path}.#{action_name}.#{I18n.default_locale}"] if tours # Have any automatic tours been completed already? - completed = AbrahamHistory.where( + completed = WalterHistory.where( creator_id: current_user.id, controller_name: controller_path, action_name: action_name @@ -21,19 +21,18 @@ module AbrahamHelper tour_html = '' tour_keys.each do |key| - tour_html += render(partial: "application/abraham", + tour_html += (render(partial: "application/shepherd", locals: { tour_name: key, tour_completed: tour_keys_completed.include?(key), trigger: tours[key]["trigger"], - steps: tours[key]["steps"] }) + steps: tours[key]["steps"] })) end - tour_html.html_safe end end - def abraham_cookie_prefix - "abraham-#{fetch_application_name.to_s.underscore}-#{current_user.id}-#{controller_path}-#{action_name}" + def walter_cookie_prefix + "walter-#{fetch_application_name.to_s.underscore}-#{current_user.id}-#{controller_path}-#{action_name}" end def fetch_application_name @@ -44,7 +43,7 @@ module AbrahamHelper end end - def abraham_domain + def walter_domain request.host end end diff --git a/app/models/abraham_history.rb b/app/models/abraham_history.rb deleted file mode 100644 index b400a14..0000000 --- a/app/models/abraham_history.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -class AbrahamHistory < ActiveRecord::Base -end diff --git a/app/models/walter_history.rb b/app/models/walter_history.rb new file mode 100644 index 0000000..235c87c --- /dev/null +++ b/app/models/walter_history.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class WalterHistory < ActiveRecord::Base +end diff --git a/app/views/application/_abraham.html.erb b/app/views/application/_abraham.html.erb deleted file mode 100644 index 51d24b4..0000000 --- a/app/views/application/_abraham.html.erb +++ /dev/null @@ -1,75 +0,0 @@ - diff --git a/app/views/application/_shepherd.html.erb b/app/views/application/_shepherd.html.erb new file mode 100644 index 0000000..d52538e --- /dev/null +++ b/app/views/application/_shepherd.html.erb @@ -0,0 +1,85 @@ + diff --git a/bin/rails b/bin/rails index 70f3634..3a20bd1 100755 --- a/bin/rails +++ b/bin/rails @@ -5,7 +5,7 @@ # installed from the root of your application. ENGINE_ROOT = File.expand_path("..", __dir__) -ENGINE_PATH = File.expand_path("../lib/abraham/engine", __dir__) +ENGINE_PATH = File.expand_path("../lib/walter/engine", __dir__) # Set up gems listed in the Gemfile. ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) diff --git a/config/locales/en.yml b/config/locales/en.yml index 8cc28ea..2ea2451 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,7 +1,8 @@ en: - abraham: + walter: later: "Later" continue: "Continue" exit: "Exit" done: "Done" next: "Next" + back: "Back" diff --git a/config/locales/es.yml b/config/locales/es.yml index d1933c7..db7dbe2 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1,5 +1,5 @@ es: - abraham: + walter: later: "Luego" continue: "Continuar" exit: "Dejar" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 734108f..a6b5ebd 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1,5 +1,5 @@ fr: - abraham: + walter: later: "Plus tard" continue: "Continuer" exit: "Quitter" diff --git a/config/routes.rb b/config/routes.rb index bda83df..367aaec 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true Rails.application.routes.draw do - resources :abraham_histories, only: :create + resources :walter_histories, only: :create end diff --git a/lib/abraham.rb b/lib/abraham.rb deleted file mode 100644 index d413b79..0000000 --- a/lib/abraham.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -require "abraham/engine" - -module Abraham -end diff --git a/lib/generators/abraham/templates/initializer.rb b/lib/generators/abraham/templates/initializer.rb deleted file mode 100644 index b5bbe26..0000000 --- a/lib/generators/abraham/templates/initializer.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -Rails.application.configure do - tours = {} - tours_root = Pathname.new(Rails.root.join("config/tours")) - - if Rails.root.join("config/tours").exist? - Dir.glob(Rails.root.join("config/tours/**/*.yml")).each do |yml| - relative_filename = Pathname.new(yml).relative_path_from(tours_root) - # `controller_path` is either "controller_name" or "module_name/controller_name" - controller_path, filename = relative_filename.split - file_parts = filename.to_s.split(".") - action = file_parts[0] - locale = file_parts[1] - t = YAML.load_file(yml) - tours["#{controller_path}.#{action}.#{locale}"] = t - end - end - - abraham_config = Rails.application.config_for :abraham - config.abraham = ActiveSupport::OrderedOptions.new - config.abraham.tour_options = abraham_config[:tour_options] - config.abraham.tours = tours -end diff --git a/lib/generators/abraham/install_generator.rb b/lib/generators/walter/install_generator.rb similarity index 80% rename from lib/generators/abraham/install_generator.rb rename to lib/generators/walter/install_generator.rb index 03ee440..fa5cbb1 100644 --- a/lib/generators/abraham/install_generator.rb +++ b/lib/generators/walter/install_generator.rb @@ -3,7 +3,7 @@ require "rails/generators" require "rails/generators/active_record" -module Abraham +module Walter module Generators class InstallGenerator < ActiveRecord::Generators::Base argument :name, type: :string, default: "random_name" @@ -18,19 +18,19 @@ module Abraham def copy_files return if options["skip-migration"] - migration_template "migration.rb", "db/migrate/create_abraham_histories.rb" + migration_template "migration.rb", "db/migrate/create_walter_histories.rb" end def create_initializer return if options["skip-initializer"] - copy_file "initializer.rb", "config/initializers/abraham.rb" + copy_file "initializer.rb", "config/initializers/walter.rb" end def create_config return if options["skip-config"] - copy_file "abraham.yml", "config/abraham.yml" + copy_file "walter.yml", "config/walter.yml" end end end diff --git a/lib/generators/walter/templates/initializer.rb b/lib/generators/walter/templates/initializer.rb new file mode 100644 index 0000000..8fb7be2 --- /dev/null +++ b/lib/generators/walter/templates/initializer.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +Rails.application.configure do + tours_path ="app/tours" + walter_config = Rails.application.config_for :walter + config.walter = ActiveSupport::OrderedOptions.new + config.walter.tour_options = walter_config[:tour_options] + config.walter.tours_path = tours_path + Walter::Tourguide.load_tours(tours_path) +end diff --git a/lib/generators/abraham/templates/migration.rb b/lib/generators/walter/templates/migration.rb similarity index 69% rename from lib/generators/abraham/templates/migration.rb rename to lib/generators/walter/templates/migration.rb index ad7d5b0..c02c107 100644 --- a/lib/generators/abraham/templates/migration.rb +++ b/lib/generators/walter/templates/migration.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -class CreateAbrahamHistories < ActiveRecord::Migration[5.0] +class CreateWalterHistories < ActiveRecord::Migration[5.0] def change - create_table :abraham_histories do |t| + create_table :walter_histories do |t| t.string :controller_name t.string :action_name t.string :tour_name diff --git a/lib/generators/abraham/templates/abraham.yml b/lib/generators/walter/templates/walter.yml similarity index 100% rename from lib/generators/abraham/templates/abraham.yml rename to lib/generators/walter/templates/walter.yml diff --git a/lib/tasks/abraham_tasks.rake b/lib/tasks/abraham_tasks.rake index c87398e..7f8761f 100644 --- a/lib/tasks/abraham_tasks.rake +++ b/lib/tasks/abraham_tasks.rake @@ -1,5 +1,5 @@ # frozen_string_literal: true # desc "Explaining what the task does" -# task :abraham do +# task :walter do # # Task goes here # end diff --git a/lib/walter.rb b/lib/walter.rb new file mode 100644 index 0000000..1f237fd --- /dev/null +++ b/lib/walter.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require "walter/engine" + +module Walter + require 'walter/tourguide' + + def self.load_tours(tp=nil) + Walter::Tourguide.instance.load_tours(tp) + end + + def self.tours + Walter::Tourguide.instance.tours + end +end diff --git a/lib/abraham/engine.rb b/lib/walter/engine.rb similarity index 86% rename from lib/abraham/engine.rb rename to lib/walter/engine.rb index 9234726..81ef1cb 100644 --- a/lib/abraham/engine.rb +++ b/lib/walter/engine.rb @@ -2,7 +2,7 @@ require "rubygems" -module Abraham +module Walter class Engine < ::Rails::Engine end end diff --git a/lib/walter/tourguide.rb b/lib/walter/tourguide.rb new file mode 100644 index 0000000..5dc8e0c --- /dev/null +++ b/lib/walter/tourguide.rb @@ -0,0 +1,39 @@ +module Walter + class Tourguide + include Singleton + @tours = {} + attr_accessor :reload + + def initialize + super + @reload = true + end + + def tours + load_tours + @tours + end + + def load_tours(tours_path=nil) + return unless @reload + + @tours = {} + tours_path ||= Rails.application.config.walter.tours_path + tours_root = Pathname.new(Rails.root.join(tours_path)) + if Rails.root.join(tours_path).exist? + Dir.glob(Rails.root.join("#{tours_path}/**/*.yml")).each do |yml| + relative_filename = Pathname.new(yml).relative_path_from(tours_root) + # `controller_path` is either "controller_name" or "module_name/controller_name" + controller_path, filename = relative_filename.split + file_parts = filename.to_s.split(".") + action = file_parts[0] + locale = file_parts[1] + t = YAML.load_file(yml) + @tours["#{controller_path}.#{action}.#{locale}"] = t + end + end + puts "#{@tours.size} tours loaded" + @reload = ENV['WALTER_RELOAD_TOURS'].present? || Rails.env.development? + end + end +end diff --git a/lib/abraham/version.rb b/lib/walter/version.rb similarity index 50% rename from lib/abraham/version.rb rename to lib/walter/version.rb index e3afab7..f79cf96 100644 --- a/lib/abraham/version.rb +++ b/lib/walter/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -module Abraham - VERSION = "2.4.0" +module Walter + VERSION = "2.0" end diff --git a/package.json b/package.json index 7b3f2b4..b71a65d 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "abraham", + "name": "walter", "private": true, "dependencies": { "js-cookie": "^2.2.0", - "shepherd.js": "^6.0.0-beta" + "shepherd.js": "^8.3.1" } } diff --git a/test/abraham_test.rb b/test/abraham_test.rb index 7cf3ba4..cb36766 100644 --- a/test/abraham_test.rb +++ b/test/abraham_test.rb @@ -2,8 +2,8 @@ require "test_helper" -class Abraham::Test < ActiveSupport::TestCase +class Walter::Test < ActiveSupport::TestCase test "truth" do - assert_kind_of Module, Abraham + assert_kind_of Module, Walter end end diff --git a/test/dummy/app/assets/javascripts/application.js b/test/dummy/app/assets/javascripts/application.js index c709793..2e2fcde 100644 --- a/test/dummy/app/assets/javascripts/application.js +++ b/test/dummy/app/assets/javascripts/application.js @@ -11,5 +11,5 @@ // about supported directives. // //= require turbolinks -//= require abraham +//= require walter //= require_tree . diff --git a/test/dummy/app/assets/stylesheets/application.scss b/test/dummy/app/assets/stylesheets/application.scss index ee202ef..ee36115 100644 --- a/test/dummy/app/assets/stylesheets/application.scss +++ b/test/dummy/app/assets/stylesheets/application.scss @@ -10,6 +10,6 @@ * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. * - *= require abraham/theme-default + *= require walter/theme-default *= require_tree . - */ \ No newline at end of file + */ diff --git a/test/dummy/app/views/dashboard/home.html.erb b/test/dummy/app/views/dashboard/home.html.erb index 54a338b..c01933f 100644 --- a/test/dummy/app/views/dashboard/home.html.erb +++ b/test/dummy/app/views/dashboard/home.html.erb @@ -13,14 +13,14 @@ \ No newline at end of file + diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb index 46abe1f..9005f50 100644 --- a/test/dummy/app/views/layouts/application.html.erb +++ b/test/dummy/app/views/layouts/application.html.erb @@ -15,6 +15,6 @@

current_user.id = <%= current_user.id %>

- <%= abraham_tour %> + <%= walter_tour %> diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index fdc8bed..0d8b793 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -5,7 +5,7 @@ require_relative "boot" require "rails/all" Bundler.require(*Rails.groups) -require "abraham" +require "walter" module Dummy class Application < Rails::Application diff --git a/test/dummy/config/initializers/abraham.rb b/test/dummy/config/initializers/abraham.rb index b5bbe26..eed27e9 100644 --- a/test/dummy/config/initializers/abraham.rb +++ b/test/dummy/config/initializers/abraham.rb @@ -17,8 +17,8 @@ Rails.application.configure do end end - abraham_config = Rails.application.config_for :abraham - config.abraham = ActiveSupport::OrderedOptions.new - config.abraham.tour_options = abraham_config[:tour_options] - config.abraham.tours = tours + walter_config = Rails.application.config_for :walter + config.walter = ActiveSupport::OrderedOptions.new + config.walter.tour_options = walter_config[:tour_options] + config.walter.tours = tours end diff --git a/test/dummy/db/migrate/20161118143752_create_abraham_histories.rb b/test/dummy/db/migrate/20161118143752_create_abraham_histories.rb index ad7d5b0..c02c107 100644 --- a/test/dummy/db/migrate/20161118143752_create_abraham_histories.rb +++ b/test/dummy/db/migrate/20161118143752_create_abraham_histories.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -class CreateAbrahamHistories < ActiveRecord::Migration[5.0] +class CreateWalterHistories < ActiveRecord::Migration[5.0] def change - create_table :abraham_histories do |t| + create_table :walter_histories do |t| t.string :controller_name t.string :action_name t.string :tour_name diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index b3952e3..873febd 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -12,16 +12,16 @@ ActiveRecord::Schema.define(version: 2016_11_18_143752) do - create_table "abraham_histories", force: :cascade do |t| + create_table "walter_histories", force: :cascade do |t| t.string "controller_name" t.string "action_name" t.string "tour_name" t.integer "creator_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.index ["created_at"], name: "index_abraham_histories_on_created_at" - t.index ["creator_id"], name: "index_abraham_histories_on_creator_id" - t.index ["updated_at"], name: "index_abraham_histories_on_updated_at" + t.index ["created_at"], name: "index_walter_histories_on_created_at" + t.index ["creator_id"], name: "index_walter_histories_on_creator_id" + t.index ["updated_at"], name: "index_walter_histories_on_updated_at" end end diff --git a/test/dummy/test/controllers/abraham_histories_controller_test.rb b/test/dummy/test/controllers/abraham_histories_controller_test.rb index 1b1b374..fed2a17 100644 --- a/test/dummy/test/controllers/abraham_histories_controller_test.rb +++ b/test/dummy/test/controllers/abraham_histories_controller_test.rb @@ -2,10 +2,10 @@ require "test_helper" -class AbrahamHistoriesControllerTest < ActionDispatch::IntegrationTest - test "should create AbrahamHistory" do - assert_difference ["AbrahamHistory.count"] do - post abraham_histories_url, as: :json, params: { abraham_history: { action_name: "foo", controller_name: "bar", tour_name: "baz" } } +class WalterHistoriesControllerTest < ActionDispatch::IntegrationTest + test "should create WalterHistory" do + assert_difference ["WalterHistory.count"] do + post walter_histories_url, as: :json, params: { walter_history: { action_name: "foo", controller_name: "bar", tour_name: "baz" } } end end end diff --git a/test/dummy/test/controllers/dashboard_controller_test.rb b/test/dummy/test/controllers/dashboard_controller_test.rb index 92b12d7..facc475 100644 --- a/test/dummy/test/controllers/dashboard_controller_test.rb +++ b/test/dummy/test/controllers/dashboard_controller_test.rb @@ -13,7 +13,7 @@ class DashboardControllerTest < ActionDispatch::IntegrationTest test "uses configured shepherd configuration" do # No options - Rails.configuration.abraham.tour_options = nil + Rails.configuration.walter.tour_options = nil get dashboard_home_url assert_response :success assert_select "body script" do |element| @@ -22,7 +22,7 @@ class DashboardControllerTest < ActionDispatch::IntegrationTest end # Custom options - Rails.configuration.abraham.tour_options = '{ defaultStepOptions: { classes: "my-custom-class" } }' + Rails.configuration.walter.tour_options = '{ defaultStepOptions: { classes: "my-custom-class" } }' get dashboard_home_url assert_select "body script" do |element| # Config-specified options passed into Tour() diff --git a/test/dummy/test/system/tours_test.rb b/test/dummy/test/system/tours_test.rb index 17636fa..93b56bc 100644 --- a/test/dummy/test/system/tours_test.rb +++ b/test/dummy/test/system/tours_test.rb @@ -3,7 +3,7 @@ require "application_system_test_case" class ToursTest < ApplicationSystemTestCase setup do @user_id = Random.rand(1..99999) - @cookie_name = "abraham-dummy-#{@user_id}-dashboard-home-intro" + @cookie_name = "walter-dummy-#{@user_id}-dashboard-home-intro" ApplicationController.any_instance.stubs(:current_user).returns(OpenStruct.new(id: @user_id)) end diff --git a/test/install_generator_test.rb b/test/install_generator_test.rb index 1a80ee6..d0d3070 100644 --- a/test/install_generator_test.rb +++ b/test/install_generator_test.rb @@ -2,10 +2,10 @@ require "test_helper" require "rails/generators" -require "generators/abraham/install_generator" +require "generators/walter/install_generator" class InstallGeneratorTest < Rails::Generators::TestCase - tests Abraham::Generators::InstallGenerator + tests Walter::Generators::InstallGenerator destination File.expand_path("../tmp", __dir__) setup :prepare_destination @@ -13,7 +13,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase test "should generate a migration" do begin run_generator - assert_migration "db/migrate/create_abraham_histories" + assert_migration "db/migrate/create_walter_histories" ensure FileUtils.rm_rf destination_root end @@ -22,7 +22,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase test "should skip the migration when told to do so" do begin run_generator ["--skip-migration"] - assert_no_migration "db/migrate/create_abraham_histories" + assert_no_migration "db/migrate/create_walter_histories" ensure FileUtils.rm_rf destination_root end @@ -31,8 +31,8 @@ class InstallGeneratorTest < Rails::Generators::TestCase test "should generate an initializer" do begin run_generator - assert_file "config/initializers/abraham.rb" - assert_file "config/abraham.yml" + assert_file "config/initializers/walter.rb" + assert_file "config/walter.yml" ensure FileUtils.rm_rf destination_root end @@ -41,7 +41,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase test "should skip the initializer when told to do so" do begin run_generator ["--skip-initializer"] - assert_no_file "config/initializers/abraham.rb" + assert_no_file "config/initializers/walter.rb" ensure FileUtils.rm_rf destination_root end diff --git a/test/models/abraham_history_test.rb b/test/models/abraham_history_test.rb index 363bf8b..cb074ea 100644 --- a/test/models/abraham_history_test.rb +++ b/test/models/abraham_history_test.rb @@ -2,7 +2,7 @@ require "test_helper" -class AbrahamHistoryTest < ActiveSupport::TestCase +class WalterHistoryTest < ActiveSupport::TestCase # test "the truth" do # assert true # end diff --git a/abraham.gemspec b/walter.gemspec similarity index 55% rename from abraham.gemspec rename to walter.gemspec index 65c6fb8..4a6440a 100644 --- a/abraham.gemspec +++ b/walter.gemspec @@ -3,17 +3,16 @@ $LOAD_PATH.push File.expand_path("lib", __dir__) # Maintain your gem's version: -require "abraham/version" +require "walter/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = "abraham" - s.version = Abraham::VERSION - s.authors = ["Jonathan Abbett"] - s.email = ["jonathan@act.md"] - 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.name = "walter" + s.version = Walter::VERSION + s.authors = ["Mike Sutton"] + s.email = ["team@wizewerx.com"] + s.summary = "Application tours for Rails" + s.description = "Application tours for Rails" s.license = "MIT" s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]