Compare commits

..

3 Commits

Author SHA1 Message Date
Jonathan Abbett
6d91ce0788 Remove requires from engine 2018-05-08 14:23:55 -04:00
Jonathan Abbett
9c7c393a6c Attempt to yarnify as well 2018-05-08 14:07:04 -04:00
Jonathan Abbett
44ee9c771d Bugfix: Reorder Gemfile 2018-05-08 13:33:26 -04:00
112 changed files with 642 additions and 1656 deletions

7
.gitignore vendored
View File

@ -2,8 +2,6 @@
capybara-*.html capybara-*.html
.rspec .rspec
/log /log
/node_modules
/pkg
/tmp /tmp
/test/dummy/log /test/dummy/log
/test/dummy/tmp /test/dummy/tmp
@ -17,9 +15,6 @@ capybara-*.html
**.orig **.orig
rerun.txt rerun.txt
pickle-email-*.html pickle-email-*.html
# Don't commit yarn.lock, to ensure that package.json is specific enough
yarn.lock
yarn-error.log
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
config/initializers/secret_token.rb config/initializers/secret_token.rb
@ -35,7 +30,6 @@ config/secrets.yml
# these should all be checked in to normalize the environment: # these should all be checked in to normalize the environment:
# Gemfile.lock, .ruby-version, .ruby-gemset # Gemfile.lock, .ruby-version, .ruby-gemset
Gemfile.lock
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc .rvmrc
@ -54,4 +48,3 @@ bower.json
.idea/ .idea/
/test/dummy/tmp/ /test/dummy/tmp/
/test/dummy/log/ /test/dummy/log/
.DS_Store

View File

@ -1,188 +0,0 @@
AllCops:
TargetRubyVersion: 2.3
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Exclude:
- '**/templates/**/*'
- '**/vendor/**/*'
- 'actionpack/lib/action_dispatch/journey/parser.rb'
- 'lib/templates/**/*'
- 'db/**/*'
- 'config/**/*'
- 'vendor/**/*'
# Prefer &&/|| over and/or.
Style/AndOr:
Enabled: true
# Do not use braces for hash literals when they are the last argument of a
# method call.
Style/BracesAroundHashParameters:
Enabled: true
EnforcedStyle: context_dependent
# Align `when` with `case`.
Layout/CaseIndentation:
Enabled: true
# Align comments with method definitions.
Layout/CommentIndentation:
Enabled: true
Layout/EmptyLineAfterMagicComment:
Enabled: true
Layout/EmptyLinesAroundBlockBody:
Enabled: true
# In a regular class definition, no empty lines around the body.
Layout/EmptyLinesAroundClassBody:
Enabled: true
# In a regular method definition, no empty lines around the body.
Layout/EmptyLinesAroundMethodBody:
Enabled: true
# In a regular module definition, no empty lines around the body.
Layout/EmptyLinesAroundModuleBody:
Enabled: true
Layout/FirstParameterIndentation:
Enabled: true
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
Style/HashSyntax:
Enabled: true
# Method definitions after `private` or `protected` isolated calls need one
# extra level of indentation.
Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: rails
# Two spaces, no tabs (for indentation).
Layout/IndentationWidth:
Enabled: true
Layout/SpaceAfterColon:
Enabled: true
Layout/SpaceAfterComma:
Enabled: true
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true
Layout/SpaceAroundKeyword:
Enabled: true
Layout/SpaceAroundOperators:
Enabled: true
Layout/SpaceBeforeFirstArg:
Enabled: true
# Defining a method with parameters needs parentheses.
Style/MethodDefParentheses:
Enabled: true
Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always
# Use `foo {}` not `foo{}`.
Layout/SpaceBeforeBlockBraces:
Enabled: true
# Use `foo { bar }` not `foo {bar}`.
Layout/SpaceInsideBlockBraces:
Enabled: true
# Use `{ a: 1 }` not `{a:1}`.
Layout/SpaceInsideHashLiteralBraces:
Enabled: true
Layout/SpaceInsideParens:
Enabled: true
# Check quotes usage according to lint rule below.
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
# Detect hard tabs, no hard tabs.
Layout/Tab:
Enabled: true
# Blank lines should not have any spaces.
Layout/TrailingBlankLines:
Enabled: true
# No trailing whitespace.
Layout/TrailingWhitespace:
Enabled: true
# Use quotes for string literals when they are enough.
Style/UnneededPercentQ:
Enabled: true
# Align `end` with the matching keyword or starting expression except for
# assignments, where it should be aligned with the LHS.
Layout:
Enabled: true
EnforcedStyleAlignWith: keyword
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
Lint/RequireParentheses:
Enabled: true
# Don't warn until lines go beyond GitHub view limit
Metrics/LineLength:
Enabled: false
# Prefer the compact readable style
Style/ClassAndModuleChildren:
EnforcedStyle: compact
Style/FormatStringToken:
EnforcedStyle: template
# Disable top-level documentation
Documentation:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/ParameterLists:
CountKeywordArgs: false
Style/RescueStandardError:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Metrics/BlockLength:
Enabled: false
Naming/AccessorMethodName:
Enabled: false
Metrics/ClassLength:
Enabled: false
Style/GuardClause:
Enabled: false
# Ignore templates

View File

@ -1 +1 @@
walter abraham

View File

@ -1 +1 @@
2.6.5 2.3.3

41
Gemfile
View File

@ -1,29 +1,19 @@
# frozen_string_literal: true # frozen_string_literal: true
source 'http://rubygems.org' source 'http://rubygems.org'
source 'http://rails-assets.org'
group :development, :test do # Declare your gem's dependencies in abraham.gemspec.
gem 'sassc-rails'
end
# Set the Rails version. We have this switch so that we can test multiple
# versions for Rails on Travis CI.
# Inspired by http://aaronmiler.com/blog/testing-your-rails-engine-with-multiple-versions-of-rails/
rails_version = ENV['RAILS_VERSION'] || 'default'
rails = case rails_version
when 'default'
'~> 5.2'
when 'master'
{github: 'rails/rails'}
else
"~> #{rails_version}"
end
gem 'rails', rails
# Declare your gem's dependencies in walter.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and # Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group. # development dependencies will be added by default to the :development group.
gemspec gemspec
source 'http://rails-assets.org' do
gem 'rails-assets-shepherd.js', '~> 1.8'
gem 'rails-assets-js-cookie', '~> 2.1'
gem 'rails-assets-tether', '~> 1.4'
end
# Declare any dependencies that are still in development here instead of in # Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or # your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing # Git. Remember to move these dependencies to your gemspec before releasing
@ -31,16 +21,3 @@ gemspec
# To use a debugger # To use a debugger
# gem 'byebug', group: [:development, :test] # gem 'byebug', group: [:development, :test]
group :development, :test do
gem 'turbolinks'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
gem 'mocha'
end

168
Gemfile.lock Normal file
View File

@ -0,0 +1,168 @@
PATH
remote: .
specs:
abraham (1.2)
jquery-rails
rails (~> 5.0.0, >= 5.0.0.1)
rails-assets-js-cookie (~> 2.1)
rails-assets-shepherd.js (~> 1.8)
rails-assets-tether (~> 1.4)
sass-rails (~> 5.0)
GEM
remote: http://rubygems.org/
remote: http://rails-assets.org/
specs:
actioncable (5.0.7)
actionpack (= 5.0.7)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.7)
actionpack (= 5.0.7)
actionview (= 5.0.7)
activejob (= 5.0.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.7)
actionview (= 5.0.7)
activesupport (= 5.0.7)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.7)
activesupport (= 5.0.7)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.7)
activesupport (= 5.0.7)
globalid (>= 0.3.6)
activemodel (5.0.7)
activesupport (= 5.0.7)
activerecord (5.0.7)
activemodel (= 5.0.7)
activesupport (= 5.0.7)
arel (~> 7.0)
activesupport (5.0.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
ast (2.4.0)
builder (3.2.3)
concurrent-ruby (1.0.5)
crass (1.0.4)
erubis (2.7.0)
ffi (1.9.23)
globalid (0.4.1)
activesupport (>= 4.2.0)
i18n (1.0.1)
concurrent-ruby (~> 1.0)
jquery-rails (4.3.3)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mini_mime (>= 0.1.1)
method_source (0.9.0)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.11.3)
nio4r (2.3.1)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
parallel (1.12.1)
parser (2.5.1.0)
ast (~> 2.4.0)
powerpack (0.1.1)
rack (2.0.5)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.7)
actioncable (= 5.0.7)
actionmailer (= 5.0.7)
actionpack (= 5.0.7)
actionview (= 5.0.7)
activejob (= 5.0.7)
activemodel (= 5.0.7)
activerecord (= 5.0.7)
activesupport (= 5.0.7)
bundler (>= 1.3.0)
railties (= 5.0.7)
sprockets-rails (>= 2.0.0)
rails-assets-js-cookie (2.2.0)
rails-assets-shepherd.js (1.8.1)
rails-assets-tether (>= 1.0.1, < 2)
rails-assets-tether (1.4.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.0.7)
actionpack (= 5.0.7)
activesupport (= 5.0.7)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (3.0.0)
rake (12.3.1)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rubocop (0.55.0)
parallel (~> 1.10)
parser (>= 2.5)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
sass (3.5.6)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (0.20.0)
thread_safe (0.3.6)
tilt (2.0.8)
tzinfo (1.2.5)
thread_safe (~> 0.1)
unicode-display_width (1.3.2)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
PLATFORMS
ruby
DEPENDENCIES
abraham!
rails-assets-js-cookie (~> 2.1)!
rails-assets-shepherd.js (~> 1.8)!
rails-assets-tether (~> 1.4)!
rubocop
sqlite3
BUNDLED WITH
1.16.1

149
README.md
View File

@ -1,96 +1,84 @@
# Walter # 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._
<p align="center"> ![Watercolor Sheep](https://upload.wikimedia.org/wikipedia/commons/e/e4/Watercolor_Sheep_Drawing.jpg)
<i>Product tours like a badass.</i>
<br/> Abraham injects dynamically-generated [Shepherd.js](http://github.hubspot.com/shepherd/docs/welcome/) code into your Rails application whenever a user should see a guided tour. Skip a tour, and we'll try again next time; complete a tour, and it won't show up again.
<img src="https://img.icons8.com/doodle/240/000000/walter-white.png"/>
<br/>
<a style='font-size: 12px;' href="https://icons8.com/icon/5iWNvQRbAKx9/walter-white">Walter White icon by Icons8</a>
</p>
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. * Define tour content with simple YAML files, in any/many languages.
* Organize tours by controller and action. * Organize tours by controller and action.
* Trigger tours automatically on page load or manually via JavaScript method. * Plays nicely with Turbolinks.
* 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 ## Requirements
* Walter 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.
* Walter is tested on Rails 5.2, 6.0, and 6.1
## Installation ## Installation
Add `walter` to your Gemfile: Add `abraham` and its JavaScript dependencies to your Gemfile:
``` ```
gem 'walter' gem 'abraham'
source 'https://rails-assets.org' do
gem 'rails-assets-shepherd.js', '~> 1.8'
gem 'rails-assets-js-cookie', '~> 2.1'
end
``` ```
Install the gem and run the installer: Then run:
``` ```
$ bundle install $ bundle install
$ rails generate walter:install $ rails generate abraham:install
$ rails db:migrate
``` ```
Install the JavaScript dependencies: Require `abraham` in `app/assets/javascripts/application.js`
``` ```
$ yarn add js-cookie@^2.2.0 shepherd.js@^6.0.0-beta //= require abraham
``` ```
Require `walter` in `app/assets/javascripts/application.js` Require a Shepherd.js CSS theme in `app/assets/stylesheets/application.scss`
``` ```
//= require walter //= require "shepherd.js/dist/css/shepherd-theme-default"
``` ```
Require a CSS theme in `app/assets/stylesheets/application.scss` Shepherd.js provides the following themes:
``` - `shepherd-theme-arrows`
*= require walter/theme-default - `shepherd-theme-arrows-fix`
``` - `shepherd-theme-arrows-plain-buttons`
- `shepherd-theme-dark`
- `shepherd-theme-default`
- `shepherd-theme-square`
- `shepherd-theme-square-dark`
Walter provides the following themes: Update `config/abraham.yml` if you choose a different theme:
- `theme-default`
- `theme-dark`
Update `config/walter.yml` if you choose a different theme:
``` ```
defaults: &defaults defaults: &defaults
:tour_options: '{ defaultStepOptions: { classes: "theme-dark" } }' :default_theme: 'shepherd-theme-arrows'
``` ```
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 ```erb
<%= walter_tour %> <%= abraham_tour %>
</body> </body>
</html> </html>
``` ```
## Defining your tours ## Defining your tours
Define your tours in the `app/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.) Define your tours in the `config/tours` directory. Its directory structure should mirror your application's controllers, and the tour files should mirror your actions/views.
``` ```
app/ config/
└── tours/ └── tours/
├── admin/ └── blog/
│ └── articles/
│ └── edit.en.yml
├── blog/
│ ├── show.en.yml │ ├── show.en.yml
│ └── show.es.yml │ └── show.es.yml
└── articles/ └── articles/
@ -100,15 +88,11 @@ app/
└── show.es.yml └── show.es.yml
``` ```
For example, per above, when a Spanish-speaking user visits `/articles/`, they'll see the tours defined by `config/tours/articles/index.es.yml`. NB: You must specify a locale in the filename, even if you're only supporting one language.
(Note: You must specify a locale in the filename, even if you're only supporting one language.)
### Tour content ### Tour content
Within a tour file, each tour is composed of a series of **steps**. A step may have a `title` and must have `text`. You may attach a step to a particular element on the page, and place the callout in a particular position. 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.
In this example, we define a tour called "intro" with 3 steps:
```yaml ```yaml
intro: intro:
@ -129,71 +113,20 @@ intro:
placement: "bottom" placement: "bottom"
``` ```
Walter takes care of which buttons should appear with each step: Abraham takes care of which buttons should appear with each step:
* "Later" and "Continue" buttons on the first step * "Later" and "Continue" buttons on the first step
* "Exit", "Back" and "Continue" 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`
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/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, 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
walkthrough:
trigger: "manual"
steps:
1:
text: "This walkthrough will show you how to..."
```
This tour will not start automatically; instead, use the `Walter.startTour` method with the tour name:
```
<button id="startTour">Start tour</button>
<script>
document.querySelector("#startTour").addEventListener("click", function() {
Walter.startTour("walkthrough"));
});
</script>
```
...or if you happen to use jQuery:
```
<script>
$("#startTour").on("click", function() { Walter.startTour('walkthrough'); })
</script>
```
### Testing your tours ### Testing your tours
Walter loads tour definitions once when you start your server. Restart your server to see tour changes. 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 Walter tours getting in the way, clear the Walter configuration in your test helper, e.g. 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 Rails.application.configure do
config.walter.tours = {} config.abraham.tours = {}
end end
``` ```

View File

@ -1,35 +1,34 @@
# frozen_string_literal: true # frozen_string_literal: true
begin begin
require "bundler/setup" require 'bundler/setup'
rescue LoadError rescue LoadError
puts "You must `gem install bundler` and `bundle install` to run rake tasks" puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end end
require "rdoc/task" require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc| RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = "rdoc" rdoc.rdoc_dir = 'rdoc'
rdoc.title = "Walter" rdoc.title = 'Abraham'
rdoc.options << "--line-numbers" rdoc.options << '--line-numbers'
rdoc.rdoc_files.include("README.md") rdoc.rdoc_files.include('README.md')
rdoc.rdoc_files.include("lib/**/*.rb") rdoc.rdoc_files.include('lib/**/*.rb')
end end
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__) APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
load "rails/tasks/engine.rake" load 'rails/tasks/engine.rake'
load "rails/tasks/statistics.rake" load 'rails/tasks/statistics.rake'
require "bundler/gem_tasks" require 'bundler/gem_tasks'
require "rake/testtask" require 'rake/testtask'
Rake::TestTask.new(:test) do |t| Rake::TestTask.new(:test) do |t|
t.libs << "test" t.libs << 'lib'
t.pattern = "test/**/*_test.rb" t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false t.verbose = false
t.warning = false
end end
task default: :test task default: :test

26
abraham.gemspec Normal file
View File

@ -0,0 +1,26 @@
# frozen_string_literal: true
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
# Maintain your gem's version:
require 'abraham/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.license = 'MIT'
s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md']
s.add_dependency 'rails', '~> 5.0.0', '>= 5.0.0.1'
s.add_dependency 'sass-rails', '~> 5.0'
s.add_dependency 'jquery-rails'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'rubocop'
end

View File

@ -0,0 +1,10 @@
//= require jquery
//= require jquery_ujs
//= require js-cookie
//= require tether
//= require tether-shepherd
$(document).on('turbolinks:before-cache', function() {
// Remove visible product tours
$(".shepherd-step").remove();
});

View File

@ -1,28 +0,0 @@
//= 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) {
setTimeout(function(){Walter.tours[tourName].start()}, 300);
}
};
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 = [];
});

View File

View File

@ -1,194 +0,0 @@
.shepherd-button {
background: #3288e6;
border: 0;
border-radius: 3px;
color: hsla(0, 0%, 100%, .75);
cursor: pointer;
margin-right: .5rem;
padding: .5rem 1.5rem;
transition: all .5s ease;
}
.shepherd-button:not(:disabled):hover {
background: #196fcc;
color: hsla(0, 0%, 100%, .75);
}
.shepherd-button.shepherd-button-secondary {
background: #f1f2f3;
color: rgba(0, 0, 0, .75);
}
.shepherd-button.shepherd-button-secondary:not(:disabled):hover {
background: #d6d9db;
color: rgba(0, 0, 0, .75);
}
.shepherd-button:disabled {
cursor: not-allowed;
}
.shepherd-footer {
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
display: flex;
justify-content: flex-end;
padding: 0 1rem 1rem;
}
.shepherd-footer .shepherd-button:last-child {
margin-right: 0;
}
.shepherd-cancel-icon {
background: transparent;
border: none;
color: hsla(0, 0%, 50.2%, .75);
font-size: 2em;
cursor: pointer;
font-weight: 400;
margin: 0;
padding: 0;
transition: color .5s ease;
}
.shepherd-cancel-icon:hover {
color: rgba(0, 0, 0, .75);
}
.shepherd-has-title .shepherd-content .shepherd-cancel-icon {
color: hsla(0, 0%, 50.2%, .75);
}
.shepherd-has-title .shepherd-content .shepherd-cancel-icon:hover {
color: rgba(0, 0, 0, .75);
}
.shepherd-title {
display: flex;
font-size: 1rem;
font-weight: 400;
flex: 1 0 auto;
margin: 0;
padding: 0;
}
.shepherd-header {
align-items: center;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
display: flex;
justify-content: flex-end;
padding: 0.5rem 0rem 0;
}
.shepherd-has-title .shepherd-content .shepherd-header {
padding: 1rem;
}
.shepherd-text {
font-size: 1rem;
padding: 1rem;
}
.shepherd-text p {
margin-top: 0;
}
.shepherd-text p:last-child {
margin-bottom: 0;
}
.shepherd-content {
border-radius: 5px;
outline: none;
padding: 0;
}
.shepherd-element {
border-radius: 5px;
box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
//max-width: 600px;
outline: none;
z-index: 9999;
line-height: 1.2;
}
.shepherd-element,
.shepherd-element *,
.shepherd-element :after,
.shepherd-element :before {
box-sizing: border-box;
}
.shepherd-element .shepherd-arrow {
border: 16px solid transparent;
content: "";
display: block;
height: 16px;
pointer-events: none;
position: absolute;
width: 16px;
z-index: 10000;
}
.shepherd-element.shepherd-element-attached-bottom.shepherd-element-attached-center .shepherd-arrow,
.shepherd-element.shepherd-pinned-top .shepherd-arrow {
bottom: 0;
border-top-color: #232323;
left: 50%;
transform: translate(-50%, 100%);
}
.shepherd-element.shepherd-element-attached-top.shepherd-element-attached-center .shepherd-arrow {
border-bottom-color: #232323;
left: 50%;
top: 0;
transform: translate(-50%, -100%);
}
.shepherd-element.shepherd-element-attached-top.shepherd-element-attached-center.shepherd-has-title .shepherd-arrow {
border-bottom-color: #303030;
}
.shepherd-element.shepherd-element-attached-middle.shepherd-element-attached-left .shepherd-arrow,
.shepherd-element.shepherd-pinned-right .shepherd-arrow {
border-right-color: #232323;
left: 0;
top: 50%;
transform: translate(-100%, -50%);
}
.shepherd-element.shepherd-element-attached-middle.shepherd-element-attached-right .shepherd-arrow,
.shepherd-element.shepherd-pinned-left .shepherd-arrow {
border-left-color: #232323;
right: 0;
top: 50%;
transform: translate(100%, -50%);
}
.shepherd-modal-overlay-container {
-ms-filter: progid:dximagetransform.microsoft.gradient.alpha(Opacity=50);
filter: alpha(opacity=50);
fill-rule: evenodd;
height: 0;
left: 0;
opacity: 0;
overflow: hidden;
pointer-events: none;
position: fixed;
top: 0;
transition: all .3s ease-out, height 0ms .3s, opacity .3s 0ms;
width: 100vw;
z-index: 9997;
}
.shepherd-modal-overlay-container.shepherd-modal-is-visible {
height: 100vh;
opacity: .5;
transition: all .3s ease-out, height 0s 0s, opacity .3s 0s;
}
.shepherd-modal-overlay-container.shepherd-modal-is-visible path {
pointer-events: all;
}

View File

@ -1,117 +0,0 @@
.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;
}

View File

@ -1,40 +0,0 @@
@import "_common";
.theme-dark.shepherd-element {
background: #232323;
.shepherd-text {
color: #eee;
}
.shepherd-title {
color: #fff;
}
&.shepherd-has-title .shepherd-content .shepherd-header {
background: #303030;
}
&.shepherd-element-attached-bottom.shepherd-element-attached-center .shepherd-arrow,
&.shepherd-pinned-top .shepherd-arrow {
border-top-color: #232323;
}
&.shepherd-element-attached-top.shepherd-element-attached-center .shepherd-arrow {
border-bottom-color: #232323;
}
&.shepherd-element-attached-top.shepherd-element-attached-center.shepherd-has-title .shepherd-arrow {
border-bottom-color: #303030;
}
&.shepherd-element-attached-middle.shepherd-element-attached-left .shepherd-arrow,
&.shepherd-pinned-right .shepherd-arrow {
border-right-color: #232323;
}
&.shepherd-element-attached-middle.shepherd-element-attached-right .shepherd-arrow,
&.shepherd-pinned-left .shepherd-arrow {
border-left-color: #232323;
}
}

View File

@ -1,40 +0,0 @@
@import "_common";
.theme-default.shepherd-element {
background: #fff;
.shepherd-text {
color: rgba(0, 0, 0, .75);
}
.shepherd-title {
color: rgba(0, 0, 0, .75);
}
&.shepherd-has-title .shepherd-content .shepherd-header {
background: #e6e6e6;
}
&.shepherd-element-attached-bottom.shepherd-element-attached-center .shepherd-arrow,
&.shepherd-pinned-top .shepherd-arrow {
border-top-color: #fff;
}
&.shepherd-element-attached-top.shepherd-element-attached-center .shepherd-arrow {
border-bottom-color: #fff;
}
&.shepherd-element-attached-top.shepherd-element-attached-center.shepherd-has-title .shepherd-arrow {
border-bottom-color: #e6e6e6;
}
&.shepherd-element-attached-middle.shepherd-element-attached-left .shepherd-arrow,
&.shepherd-pinned-right .shepherd-arrow {
border-right-color: #fff;
}
&.shepherd-element-attached-middle.shepherd-element-attached-right .shepherd-arrow,
&.shepherd-pinned-left .shepherd-arrow {
border-left-color: #fff;
}
}

View File

@ -0,0 +1,21 @@
# 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
# Never trust parameters from the scary internet, only allow the white list through.
def abraham_history_params
params.require(:abraham_history).permit(:controller_name, :action_name, :tour_name)
end
end

View File

@ -1,21 +0,0 @@
# 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

View File

@ -0,0 +1,28 @@
# frozen_string_literal: true
module AbrahamHelper
def abraham_tour
# Do we have tours for this controller/action in the user's locale?
tours = Rails.configuration.abraham.tours["#{controller_name}.#{action_name}.#{I18n.locale}"]
unless tours
# How about the default locale?
tours = Rails.configuration.abraham.tours["#{controller_name}.#{action_name}.#{I18n.default_locale}"]
end
if tours
completed = AbrahamHistory.where(
creator_id: current_user.id,
controller_name: controller_name,
action_name: action_name
)
remaining = tours.keys - completed.map(&:tour_name)
if remaining.any?
# Generate the javascript snippet for the next remaining tour
render(partial: 'application/abraham',
locals: { tour_name: remaining.first,
steps: tours[remaining.first]['steps'] })
end
end
end
end

View File

@ -1,50 +0,0 @@
# frozen_string_literal: true
module WalterHelper
def walter_tour
# Do we have tours for this controller/action in the user's locale?
tours = Walter.tours["#{controller_path}.#{action_name}.#{I18n.locale}"]
# Otherwise, default to the default locale
tours ||= Walter.tours["#{controller_path}.#{action_name}.#{I18n.default_locale}"]
if tours
# Have any automatic tours been completed already?
completed = WalterHistory.where(
creator_id: current_user.id,
controller_name: controller_path,
action_name: action_name
)
tour_keys_completed = completed.map(&:tour_name)
tour_keys = tours.keys
tour_html = ''
tour_keys.each do |key|
tour_html += (render(partial: "application/shepherd",
locals: { tour_name: key,
tour_completed: tour_keys_completed.include?(key),
trigger: tours[key]["trigger"],
tour_delay: tours[key]['delay']||500,
steps: tours[key]["steps"] }))
end
tour_html.html_safe
end
end
def walter_cookie_prefix
"walter-#{fetch_application_name.to_s.underscore}-#{current_user.id}-#{controller_path}-#{action_name}"
end
def fetch_application_name
if Module.method_defined?(:module_parent)
Rails.application.class.module_parent
else
Rails.application.class.parent
end
end
def walter_domain
request.host
end
end

0
app/mailers/.keep Normal file
View File

View File

@ -0,0 +1,3 @@
# frozen_string_literal: true
class AbrahamHistory < ActiveRecord::Base
end

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true self.abstract_class = true
end end

View File

@ -1,4 +0,0 @@
# frozen_string_literal: true
class WalterHistory < ActiveRecord::Base
end

View File

@ -0,0 +1,60 @@
<script>
var tour = new Shepherd.Tour({
defaults: {
classes: '<%= Rails.configuration.abraham.default_theme %>'
}
});
tour.on("complete", function() {
// ajax
return $.ajax({
url: "/abraham_histories/",
type: "POST",
dataType: "json",
contentType: "application/json",
data: JSON.stringify({
controller_name: '<%= controller_name %>',
action_name: '<%= action_name %>',
tour_name: '<%= tour_name %>'
})
});
});
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') %>
title: "<%= step['title'] %>",
<% end %>
text: "<%= step['text'] %>",
<% if step.key?('attachTo') %>
attachTo: { element: "<%= step['attachTo']['element'] %>", on: "<%= step['attachTo']['placement'] %>" },
showOn: function() {
// Only display this step if its selector is present
return document.querySelector("<%= step['attachTo']['element'] %>") ? true : false
},
<% end %>
buttons: [
<% if index == 0 %>
{ text: '<%= t('abraham.later') %>', action: tour.cancel, classes: 'shepherd-button-secondary' },
{ text: '<%= t('abraham.continue') %>', action: tour.next }
<% else %>
<% if index == steps.size - 1 %>
{ text: '<%= t('abraham.done') %>', action: tour.complete }
<% else %>
{ text: '<%= t('abraham.exit') %>', action: tour.cancel, classes: 'shepherd-button-secondary' },
{ text: '<%= t('abraham.next') %>', action: tour.next }
<% end %>
<% end %>
]
});
<% end %>
// 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();
}
</script>

View File

@ -1,77 +0,0 @@
<script>
Walter.tours["<%= tour_name %>"] = new Shepherd.Tour(<%= Rails.configuration.walter.tour_options.html_safe unless Rails.configuration.walter.tour_options.nil? %>);
<% if trigger != 'manual' %>
Walter.tours["<%= tour_name %>"].on("complete", function() {
// Make AJAX call to save history of tour completion
return fetch("/walter_histories/", {
method: "POST",
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
authenticity_token: '<%= form_authenticity_token %>',
controller_name: '<%= controller_path %>',
action_name: '<%= action_name %>',
tour_name: '<%= tour_name %>'
})
});
});
Walter.tours["<%= tour_name %>"].on("cancel", function() {
Cookies.set('<%= walter_cookie_prefix %>-<%= tour_name %>', 'later', { domain: '<%= walter_domain %>' });
});
<% end %>
<% steps.each_with_index do |(key, step), index| %>
Walter.tours["<%= tour_name %>"].addStep({
id: 'step-<%= key %>',
<% if step.key?('title') %>
title: "<%== step['title'] %>",
<% end %>
text: "<%== step['text'] %>",
<% if step.key?('attachTo') %>
attachTo: { element: "<%= step['attachTo']['element'] %>", on: "<%= step['attachTo']['placement'] %>" },
showOn: function() {
// Only display this step if its selector is present
return document.querySelector("<%= step['attachTo']['element'] %>") ? true : false
},
<% end %>
buttons: [
<% if index == steps.size - 1 %>
<% if steps.size > 1 %>
{ text: '<%= t('walter.back') %>', action: Walter.tours["<%= tour_name %>"].back, classes: 'shepherd-button-secondary' },
<% end %>
{ text: '<%= t('walter.done') %>', action: Walter.tours["<%= tour_name %>"].complete },
<% else %>
<% if index == 0 %>
{ text: '<%= t('walter.later') %>', action: Walter.tours["<%= tour_name %>"].cancel, classes: 'shepherd-button-secondary' },
<% else %>
{ text: '<%= t('walter.back') %>', action: Walter.tours["<%= tour_name %>"].back, classes: 'shepherd-button-secondary' },
<% end %>
{ text: '<%= t('walter.continue') %>', action: Walter.tours["<%= tour_name %>"].next },
<% end %>
]
});
<% end %>
<% if trigger != "manual" %>
Walter.tours["<%= tour_name %>"].checkAndStart = function (start) {
return function () {
// Don't start the tour if the user dismissed it once this session
var tourMayStart = !Cookies.get('<%= walter_cookie_prefix %>-<%= tour_name %>', {domain: '<%= walter_domain %>'});
<% if steps.first[1]['attachTo'] %>
// Don't start the tour if the first step's element is missing
tourMayStart = tourMayStart && document.querySelector("<%= steps.first[1]['attachTo']['element'] %>");
<% end %>
if (tourMayStart) {
setTimeout(function(){start();}, <%= tour_delay %>); // need to delay this
}
}
}(Walter.tours["<%= tour_name %>"].start)
<% if !tour_completed %>
Walter.incompleteTours.push("<%= tour_name %>");
<% end %>
<% end %>
</script>

View File

@ -1,15 +1,14 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true # frozen_string_literal: true
# This command will automatically be run when you run "rails" with Rails gems # This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application. # installed from the root of your application.
ENGINE_ROOT = File.expand_path("..", __dir__) ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path("../lib/walter/engine", __dir__) ENGINE_PATH = File.expand_path('../../lib/abraham/engine', __FILE__)
# Set up gems listed in the Gemfile. # Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
require "rails/all" require 'rails/all'
require "rails/engine/commands" require 'rails/engine/commands'

View File

@ -1,8 +1,7 @@
en: en:
walter: abraham:
later: "Later" later: "Later"
continue: "Continue" continue: "Continue"
exit: "Exit" exit: "Exit"
done: "Done" done: "Done"
next: "Next" next: "Next"
back: "Back"

View File

@ -1,5 +1,5 @@
es: es:
walter: abraham:
later: "Luego" later: "Luego"
continue: "Continuar" continue: "Continuar"
exit: "Dejar" exit: "Dejar"

View File

@ -1,5 +1,5 @@
fr: fr:
walter: abraham:
later: "Plus tard" later: "Plus tard"
continue: "Continuer" continue: "Continuer"
exit: "Quitter" exit: "Quitter"

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.routes.draw do Rails.application.routes.draw do
resources :walter_histories, only: :create resources :abraham_histories, only: :create
end end

5
lib/abraham.rb Normal file
View File

@ -0,0 +1,5 @@
# frozen_string_literal: true
require 'abraham/engine'
module Abraham
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'rubygems'
require "rubygems" module Abraham
module Walter
class Engine < ::Rails::Engine class Engine < ::Rails::Engine
end end
end end

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
module Abraham
module Walter VERSION = '1.2'
VERSION = "2.5"
end end

View File

@ -0,0 +1,28 @@
# frozen_string_literal: true
require 'rails/generators'
require 'rails/generators/active_record'
module Abraham
module Generators
class InstallGenerator < ActiveRecord::Generators::Base
argument :name, type: :string, default: 'random_name'
class_option :'skip-migration', type: :boolean, desc: "Don't generate a migration for the histories table"
class_option :'skip-initializer', type: :boolean, desc: "Don't generate an initializer"
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
# Copies the migration template to db/migrate.
def copy_files
return if options['skip-migration']
migration_template 'migration.rb', 'db/migrate/create_abraham_histories.rb'
end
def create_initializer
return if options['skip-initializer']
copy_file 'initializer.rb', 'config/initializers/abraham.rb'
copy_file 'abraham.yml', 'config/abraham.yml'
end
end
end
end

View File

@ -0,0 +1,11 @@
defaults: &defaults
:default_theme: 'shepherd-theme-default'
development:
<<: *defaults
test:
<<: *defaults
production:
<<: *defaults

View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
Rails.application.configure do
tours = {}
if Rails.root.join('config/tours').exist?
Dir[Rails.root.join('config/tours/*/')].each do |dir|
Dir[dir + '*.yml'].each do |yml|
path_parts = yml.split(File::SEPARATOR)
controller = path_parts[path_parts.size - 2]
file_parts = path_parts[path_parts.size - 1].split('.')
action = file_parts[0]
locale = file_parts[1]
t = YAML.load_file(yml)
tours["#{controller}.#{action}.#{locale}"] = t
end
end
end
abraham_config = Rails.application.config_for :abraham
config.abraham = ActiveSupport::OrderedOptions.new
config.abraham.default_theme = abraham_config[:default_theme]
config.abraham.tours = tours
end

View File

@ -1,12 +1,11 @@
# frozen_string_literal: true # frozen_string_literal: true
class CreateAbrahamHistories < ActiveRecord::Migration[5.0]
class CreateWalterHistories < ActiveRecord::Migration[5.0]
def change def change
create_table :walter_histories do |t| create_table :abraham_histories do |t|
t.string :controller_name t.string :controller_name
t.string :action_name t.string :action_name
t.string :tour_name t.string :tour_name
t.string :creator_id, null: false, index: true t.references :creator, null: false, index: true
t.timestamps index: true t.timestamps index: true
end end

View File

@ -1,37 +0,0 @@
# frozen_string_literal: true
require "rails/generators"
require "rails/generators/active_record"
module Walter
module Generators
class InstallGenerator < ActiveRecord::Generators::Base
argument :name, type: :string, default: "random_name"
class_option :'skip-migration', type: :boolean, desc: "Don't generate a migration for the histories table"
class_option :'skip-initializer', type: :boolean, desc: "Don't generate an initializer"
class_option :'skip-config', type: :boolean, desc: "Don't generate a config file"
source_root File.expand_path(File.join(File.dirname(__FILE__), "templates"))
# Copies the migration template to db/migrate.
def copy_files
return if options["skip-migration"]
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/walter.rb"
end
def create_config
return if options["skip-config"]
copy_file "walter.yml", "config/walter.yml"
end
end
end
end

View File

@ -1,10 +0,0 @@
# 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

View File

@ -1,14 +0,0 @@
defaults: &defaults
# Add any valid Shepherd.js configuration JSON here
# and it will be passed into the `new Shepherd.Tour()`
# initializer.
:tour_options: '{ defaultStepOptions: { classes: "theme-default" } }'
development:
<<: *defaults
test:
<<: *defaults
production:
<<: *defaults

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# desc "Explaining what the task does" # desc "Explaining what the task does"
# task :walter do # task :abraham do
# # Task goes here # # Task goes here
# end # end

View File

@ -1,15 +0,0 @@
# 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

View File

@ -1,39 +0,0 @@
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

View File

@ -1,8 +0,0 @@
{
"name": "walter",
"private": true,
"dependencies": {
"js-cookie": "^2.2.0",
"shepherd.js": "^8.3.1"
}
}

View File

@ -1,9 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'test_helper'
require "test_helper" class Abraham::Test < ActiveSupport::TestCase
test 'truth' do
class Walter::Test < ActiveSupport::TestCase assert_kind_of Module, Abraham
test "truth" do
assert_kind_of Module, Walter
end end
end end

View File

@ -1,20 +0,0 @@
require "test_helper"
require "webdrivers"
Capybara.server = :webrick
Capybara.register_driver(:headless_chrome) do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { args: %w[headless disable-gpu] }
)
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
desired_capabilities: capabilities
)
end
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400]
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake, # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative "config/application" require_relative 'config/application'
Rails.application.load_tasks Rails.application.load_tasks

View File

@ -10,6 +10,5 @@
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives. // about supported directives.
// //
//= require turbolinks //= require abraham
//= require walter
//= require_tree . //= require_tree .

View File

@ -10,6 +10,6 @@
* files in this directory. Styles in this file should be added after the last require_* statement. * 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. * It is generally better to create a new file per style scope.
* *
*= require walter/theme-default *= require "shepherd.js/dist/css/shepherd-theme-default"
*= require_tree . *= require_tree .
*/ */

View File

@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
module ApplicationCable module ApplicationCable
class Channel < ActionCable::Channel::Base class Channel < ActionCable::Channel::Base
end end

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
module ApplicationCable module ApplicationCable
class Connection < ActionCable::Connection::Base class Connection < ActionCable::Connection::Base
end end

View File

@ -1,10 +1,9 @@
# frozen_string_literal: true # frozen_string_literal: true
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
helper_method :current_user helper_method :current_user
def current_user def current_user
OpenStruct.new(id: Random.rand(1..99_999)) OpenStruct.new(id: Random.rand(1..99999))
end end
end end

View File

@ -1,8 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
class DashboardController < ApplicationController class DashboardController < ApplicationController
def home; end def home
def other; end end
def placement; end
def missing; end def other
end
end end

View File

@ -1,5 +0,0 @@
# frozen_string_literal: true
class Foobar::DashboardController < ApplicationController
def home; end
end

View File

@ -1,4 +1,3 @@
# frozen_string_literal: true # frozen_string_literal: true
module ApplicationHelper module ApplicationHelper
end end

View File

@ -1,4 +1,3 @@
# frozen_string_literal: true # frozen_string_literal: true
module DashboardHelper module DashboardHelper
end end

View File

@ -1,4 +1,3 @@
# frozen_string_literal: true # frozen_string_literal: true
class ApplicationJob < ActiveJob::Base class ApplicationJob < ActiveJob::Base
end end

View File

@ -1,6 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base class ApplicationMailer < ActionMailer::Base
default from: "from@example.com" default from: 'from@example.com'
layout "mailer" layout 'mailer'
end end

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true self.abstract_class = true
end end

View File

@ -1,26 +1,6 @@
<h1>Dashboard#home</h1> <h1>Dashboard#home</h1>
<p>Find me in app/views/dashboard/home.html.erb</p> <p>Find me in app/views/dashboard/home.html.erb</p>
<%= link_to "Other Page", dashboard_other_url %>
<div class="notice-me" style="width:300px;height:300px;background-color:whitesmoke;"> <div class="notice-me" style="width:300px;height:300px;background-color:whitesmoke;">
a content element to notice a content element to notice
</div> </div>
<button id="restart_automatic">Restart the automatic tour</button>
<button id="show_manual">Show manual tour</button>
<button id="show_another_manual">Show ANOTHER manual tour</button>
<script>
document.querySelector("#restart_automatic").addEventListener("click", function() {
Walter.startTour("intro");
});
document.querySelector("#show_manual").addEventListener("click", function() {
Walter.startTour("a_manual_tour");
});
document.querySelector("#show_another_manual").addEventListener("click", function() {
Walter.startTour("another_manual_tour");
});
</script>

View File

@ -1,5 +0,0 @@
<h1>missing</h1>
This page does not have the first step attachTo element,
so we would expect the tour not to start,
even though the second step could be rendered.

View File

@ -1,4 +1,2 @@
<h1>Dashboard#other</h1> <h1>Dashboard#other</h1>
<p>Find me in app/views/dashboard/other.html.erb</p> <p>Find me in app/views/dashboard/other.html.erb</p>
<%= link_to "Home Page", dashboard_home_url %>

View File

@ -1,22 +0,0 @@
<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

@ -1,4 +0,0 @@
<h1>Foobar::Dashboard#home</h1>
<p>Find me in app/views/foobar/dashboard/home.html.erb</p>
We should get a unique tour for this module, not the same one as Dashboard#home

View File

@ -11,10 +11,6 @@
<body> <body>
<%= yield %> <%= yield %>
<hr> <%= abraham_tour %>
<p><em>current_user.id = <%= current_user.id %></em></p>
<%= walter_tour %>
</body> </body>
</html> </html>

View File

@ -1,5 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true # frozen_string_literal: true
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) load Gem.bin_path('bundler', 'bundle')
load Gem.bin_path("bundler", "bundle")

View File

@ -1,6 +1,5 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true # frozen_string_literal: true
APP_PATH = File.expand_path('../config/application', __dir__)
APP_PATH = File.expand_path("../config/application", __dir__) require_relative '../config/boot'
require_relative "../config/boot" require 'rails/commands'
require "rails/commands"

View File

@ -1,6 +1,5 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true # frozen_string_literal: true
require_relative '../config/boot'
require_relative "../config/boot" require 'rake'
require "rake"
Rake.application.run Rake.application.run

View File

@ -1,12 +1,11 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true # frozen_string_literal: true
require 'pathname'
require "pathname" require 'fileutils'
require "fileutils"
include FileUtils include FileUtils
# path to your application root. # path to your application root.
APP_ROOT = Pathname.new File.expand_path("..", __dir__) APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args) def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==") system(*args) || abort("\n== Command #{args} failed ==")
@ -16,9 +15,9 @@ chdir APP_ROOT do
# This script is a starting point to setup your application. # This script is a starting point to setup your application.
# Add necessary setup steps to this file. # Add necessary setup steps to this file.
puts "== Installing dependencies ==" puts '== Installing dependencies =='
system! "gem install bundler --conservative" system! 'gem install bundler --conservative'
system("bundle check") || system!("bundle install") system('bundle check') || system!('bundle install')
# puts "\n== Copying sample files ==" # puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml') # unless File.exist?('config/database.yml')
@ -26,11 +25,11 @@ chdir APP_ROOT do
# end # end
puts "\n== Preparing database ==" puts "\n== Preparing database =="
system! "bin/rails db:setup" system! 'bin/rails db:setup'
puts "\n== Removing old logs and tempfiles ==" puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear" system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server ==" puts "\n== Restarting application server =="
system! "bin/rails restart" system! 'bin/rails restart'
end end

View File

@ -1,12 +1,11 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true # frozen_string_literal: true
require 'pathname'
require "pathname" require 'fileutils'
require "fileutils"
include FileUtils include FileUtils
# path to your application root. # path to your application root.
APP_ROOT = Pathname.new File.expand_path("..", __dir__) APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args) def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==") system(*args) || abort("\n== Command #{args} failed ==")
@ -16,16 +15,16 @@ chdir APP_ROOT do
# This script is a way to update your development environment automatically. # This script is a way to update your development environment automatically.
# Add necessary update steps to this file. # Add necessary update steps to this file.
puts "== Installing dependencies ==" puts '== Installing dependencies =='
system! "gem install bundler --conservative" system! 'gem install bundler --conservative'
system("bundle check") || system!("bundle install") system('bundle check') || system!('bundle install')
puts "\n== Updating database ==" puts "\n== Updating database =="
system! "bin/rails db:migrate" system! 'bin/rails db:migrate'
puts "\n== Removing old logs and tempfiles ==" puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear" system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server ==" puts "\n== Restarting application server =="
system! "bin/rails restart" system! 'bin/rails restart'
end end

View File

@ -1,7 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
# This file is used by Rack-based servers to start the application. # This file is used by Rack-based servers to start the application.
require_relative "config/environment" require_relative 'config/environment'
run Rails.application run Rails.application

View File

@ -1,5 +1,5 @@
defaults: &defaults defaults: &defaults
:tour_options: '{ defaultStepOptions: { classes: "theme-default" } }' :default_theme: 'shepherd-theme-default'
development: development:
<<: *defaults <<: *defaults

View File

@ -1,21 +1,15 @@
# frozen_string_literal: true # frozen_string_literal: true
require_relative 'boot'
require_relative "boot" require 'rails/all'
require "rails/all"
Bundler.require(*Rails.groups) Bundler.require(*Rails.groups)
require "walter" require 'abraham'
module Dummy module Dummy
class Application < Rails::Application class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here. # Settings in config/environments/* take precedence over those specified here.
# 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
end
end end
end end

View File

@ -1,7 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
# Set up gems listed in the Gemfile. # Set up gems listed in the Gemfile.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__) $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)

View File

@ -6,5 +6,4 @@ test:
production: production:
adapter: redis adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> url: redis://localhost:6379/1
channel_prefix: dummy_production

View File

@ -1,7 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
# Load the Rails application. # Load the Rails application.
require_relative "application" require_relative 'application'
# Initialize the Rails application. # Initialize the Rails application.
Rails.application.initialize! Rails.application.initialize!

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
@ -15,12 +14,12 @@ Rails.application.configure do
config.consider_all_requests_local = true config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled. # Enable/disable caching. By default caching is disabled.
if Rails.root.join("tmp/caching-dev.txt").exist? if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
config.cache_store = :memory_store config.cache_store = :memory_store
config.public_file_server.headers = { config.public_file_server.headers = {
"Cache-Control" => "public, max-age=172800" 'Cache-Control' => 'public, max-age=172800'
} }
else else
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
@ -52,5 +51,5 @@ Rails.application.configure do
# Use an evented file watcher to asynchronously detect changes in source code, # Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem. # routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end end

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
@ -18,7 +17,7 @@ Rails.application.configure do
# Disable serving static files from the `/public` folder by default since # Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this. # Apache or NGINX already handles this.
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS. # Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier config.assets.js_compressor = :uglifier
@ -77,7 +76,7 @@ Rails.application.configure do
# require 'syslog/logger' # require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present? if ENV['RAILS_LOG_TO_STDOUT'].present?
logger = ActiveSupport::Logger.new(STDOUT) logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger) config.logger = ActiveSupport::TaggedLogging.new(logger)

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
@ -17,7 +16,7 @@ Rails.application.configure do
# Configure public file server for tests with Cache-Control for performance. # Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true config.public_file_server.enabled = true
config.public_file_server.headers = { config.public_file_server.headers = {
"Cache-Control" => "public, max-age=3600" 'Cache-Control' => 'public, max-age=3600'
} }
# Show full error reports and disable caching. # Show full error reports and disable caching.

View File

@ -1,24 +1,23 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
tours = {} tours = {}
tours_root = Pathname.new(Rails.root.join("config/tours"))
if Rails.root.join("config/tours").exist? if Rails.root.join('config/tours').exist?
Dir.glob(Rails.root.join("config/tours/**/*.yml")).each do |yml| Dir[Rails.root.join('config/tours/*/')].each do |dir|
relative_filename = Pathname.new(yml).relative_path_from(tours_root) Dir[dir + '*.yml'].each do |yml|
# `controller_path` is either "controller_name" or "module_name/controller_name" path_parts = yml.split(File::SEPARATOR)
controller_path, filename = relative_filename.split controller = path_parts[path_parts.size - 2]
file_parts = filename.to_s.split(".") file_parts = path_parts[path_parts.size - 1].split('.')
action = file_parts[0] action = file_parts[0]
locale = file_parts[1] locale = file_parts[1]
t = YAML.load_file(yml) t = YAML.load_file(yml)
tours["#{controller_path}.#{action}.#{locale}"] = t tours["#{controller}.#{action}.#{locale}"] = t
end
end end
end end
walter_config = Rails.application.config_for :walter abraham_config = Rails.application.config_for :abraham
config.walter = ActiveSupport::OrderedOptions.new config.abraham = ActiveSupport::OrderedOptions.new
config.walter.tour_options = walter_config[:tour_options] config.abraham.default_theme = abraham_config[:default_theme]
config.walter.tours = tours config.abraham.tours = tours
end end

View File

@ -1,16 +1,12 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "1.0" Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path # Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path # Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('../../node_modules')
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js ) # Rails.application.config.assets.precompile += %w( search.js )

View File

@ -1,7 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars. # Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid. # Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :marshal Rails.application.config.action_dispatch.cookies_serializer = :json

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file. # Configure sensitive parameters which will be filtered from the log file.

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# #
# This file contains migration options to ease your Rails 5.0 upgrade. # This file contains migration options to ease your Rails 5.0 upgrade.
@ -19,5 +18,8 @@ ActiveSupport.to_time_preserves_timezone = true
# Require `belongs_to` associations by default. Previous versions had false. # Require `belongs_to` associations by default. Previous versions had false.
Rails.application.config.active_record.belongs_to_required_by_default = true Rails.application.config.active_record.belongs_to_required_by_default = true
# Do not halt callback chains when a callback returns false. Previous versions had true.
ActiveSupport.halt_callback_chains_on_return_false = false
# Configure SSL options to enable HSTS with subdomains. Previous versions had false. # Configure SSL options to enable HSTS with subdomains. Previous versions had false.
Rails.application.config.ssl_options = { hsts: { subdomains: true } } Rails.application.config.ssl_options = { hsts: { subdomains: true } }

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: "_dummy_session" Rails.application.config.session_store :cookie_store, key: '_dummy_session'

View File

@ -1,5 +1,4 @@
# frozen_string_literal: true # frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which # This file contains settings for ActionController::ParamsWrapper which

View File

@ -16,16 +16,6 @@
# #
# This would use the information in config/locales/es.yml. # This would use the information in config/locales/es.yml.
# #
# The following keys must be escaped otherwise they will not be retrieved by
# the default I18n backend:
#
# true, false, on, off, yes, no
#
# Instead, surround them with single quotes.
#
# en:
# 'true': 'foo'
#
# To learn more, please read the Rails Internationalization guide # To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html. # available at http://guides.rubyonrails.org/i18n.html.

View File

@ -1,21 +1,20 @@
# frozen_string_literal: true # frozen_string_literal: true
# Puma can serve each request in a thread from an internal thread pool. # Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum. # The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match # Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum # the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record. # and maximum, this matches the default thread size of Active Record.
# #
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i
threads threads_count, threads_count threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests, default is 3000. # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
# #
port ENV.fetch("PORT") { 3000 } port ENV.fetch('PORT') { 3000 }
# Specifies the `environment` that Puma will run in. # Specifies the `environment` that Puma will run in.
# #
environment ENV.fetch("RAILS_ENV") { "development" } environment ENV.fetch('RAILS_ENV') { 'development' }
# Specifies the number of `workers` to boot in clustered mode. # Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together # Workers are forked webserver processes. If using threads and workers together

View File

@ -1,14 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.routes.draw do Rails.application.routes.draw do
get "dashboard/home" get 'dashboard/home'
get "dashboard/other"
get "dashboard/placement"
get "dashboard/missing"
namespace :foobar do get 'dashboard/other'
get "dashboard/home"
end
# 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
end end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
%w(
%w[
.ruby-version .ruby-version
.rbenv-vars .rbenv-vars
tmp/restart.txt tmp/restart.txt
tmp/caching-dev.txt tmp/caching-dev.txt
].each { |path| Spring.watch(path) } ).each { |path| Spring.watch(path) }

View File

@ -10,20 +10,10 @@ intro:
text: "ENGLISH Refers to an element that won't exist on the page, should skip to 4" text: "ENGLISH Refers to an element that won't exist on the page, should skip to 4"
attachTo: attachTo:
element: "#i-dont-exist" element: "#i-dont-exist"
placement: "right" position: "right"
4: 4:
title: "ENGLISH The final step" title: "ENGLISH The final step"
text: "ENGLISH Some text here too, and it's attached to the right" text: "ENGLISH Some text here too, and it's attached to the right"
attachTo: attachTo:
element: ".notice-me" element: ".notice-me"
placement: "right" position: "right"
a_manual_tour:
trigger: manual
steps:
1:
text: "You triggered the manual tour"
another_manual_tour:
trigger: manual
steps:
1:
text: "You triggered the OTHER manual tour"

View File

@ -10,10 +10,10 @@ intro:
text: "Refers to an element that won't exist on the page, should skip to 4" text: "Refers to an element that won't exist on the page, should skip to 4"
attachTo: attachTo:
element: "#i-dont-exist" element: "#i-dont-exist"
placement: "right" position: "right"
4: 4:
title: "SPANISH The final step" title: "SPANISH The final step"
text: "Some text here too, and it's attached to the right" text: "Some text here too, and it's attached to the right"
attachTo: attachTo:
element: ".notice-me" element: ".notice-me"
placement: "right" position: "right"

View File

@ -1,10 +0,0 @@
tour:
steps:
1:
title: "This step points to a missing element"
text: "This should not skip to the second step"
attachTo:
element: "#i-dont-exist"
placement: "right"
2:
text: "You should not see me!"

View File

@ -3,9 +3,6 @@ tour_one:
1: 1:
title: "TOUR ONE step one ENGLISH" title: "TOUR ONE step one ENGLISH"
text: "we show this on your first visit" text: "we show this on your first visit"
attachTo:
element: "p"
placement: "top"
tour_two: tour_two:
steps: steps:

View File

@ -1,77 +0,0 @@
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"

Some files were not shown because too many files have changed in this diff Show More