backpedal 0.1.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b67bb1087008f4342567ec4abccfe9875a418b66002d1c07c4bbbd31a0f26835
4
- data.tar.gz: bd06cb1fa0e33d4972bb63b5bcc26c4d6f3fcaac43ad9a106f40ca7fbf90a2c9
3
+ metadata.gz: f7ade430b7ab68f84c6ed65337ffa3b1b5cfef1bd44680c444e5ad5cbf3a5ded
4
+ data.tar.gz: 7181e86b2706a6ae1121c776058780f27aae89d0039096755c0b41c4ca5ac044
5
5
  SHA512:
6
- metadata.gz: e335d2deb4ee4e577a985c1639f636f4d8ba14c84e6468005343fdf95b64e223fbe386dc08fcc6e13762d4b7a3f2c2ed65b2f34979fc60d13148ee0c76c688cd
7
- data.tar.gz: c185118d6316d9207552684dc78220be46b849ebefccd414aafc76fed584c14a0ad00a3e4c52aff2b98811f26559baa52eb252f5d2560216171100452e52f964
6
+ metadata.gz: '092329a2ed0b7be1f3b9e94602214d40ce03e7968c2587419765f12a4f841805802b89a47a4e6d787f4b7eaab8d4c3cb28ccf2c628b340091d6da8cbf975e470'
7
+ data.tar.gz: 54b5ae10125122477cdf20fa9265bb89c4d7cff5dc847b1ad7a3e376f96b3f31c9af0538503eb136e462da226c686ae80ad41472ca1a89d72f61e67485635bf4
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ backpedal (0.2.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.5.0)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ backpedal!
16
+ bundler (~> 2.0)
17
+ rake (~> 10.0)
18
+
19
+ BUNDLED WITH
20
+ 2.0.2
data/README.md CHANGED
@@ -45,6 +45,24 @@ Have a specific path in mind? Try this:
45
45
  <p> Here is where your users would appear be if you had some </p>
46
46
  ```
47
47
 
48
+ Wish to backpedal from the controller? Use the `stepback` method in your controller
49
+
50
+ ```ruby
51
+ Class PagesController
52
+ def create
53
+ @page = Page.new(pages_params)
54
+ if @page.save
55
+ flash[:success] = "Yahoo! now to step back one level"
56
+ stepback
57
+ else
58
+ "something else"
59
+ end
60
+ end
61
+ end
62
+ ```
63
+
64
+ Using `stepback` on a multi-step form or wizard, and want to redirect back to before it all began? Tell stepback how many pages you want to stepback with an optional argument: `stepback(3)`
65
+
48
66
  What if you want a specific controller action to wipe out the navigation stack and restart at the current action? Then set a before_action filter to dissolve the navigation stack.
49
67
 
50
68
  ```ruby
@@ -67,6 +85,16 @@ end
67
85
 
68
86
  If you add the initializer, it will overwrite the default skipped http verbs(new, edit, destroy). So make sure you include those if you want to skip those controller actions.
69
87
 
88
+ ## Debugging
89
+
90
+ Are you finding it difficult to keep track of the navigation stack? Use the `stack` helper to print the navigation into any view.
91
+
92
+ ```erb
93
+ <%# app/layouts/application.html.erb %>
94
+ <body>
95
+ <%= stack %>
96
+ <%= yield %>
97
+ ```
70
98
  ## Contributing
71
99
 
72
100
  Bug reports and pull requests are welcome on GitHub at https://github.com/greyoxide/backpedal.
@@ -1,9 +1,11 @@
1
1
  require 'backpedal/version'
2
2
  require 'backpedal/builder'
3
3
  require 'backpedal/actions'
4
- require 'backpedal/back_link_helper'
4
+ require 'backpedal/helpers/back_link_helper'
5
+ require 'backpedal/helpers/stack_helper.rb'
5
6
 
6
7
  module Backpedal
7
8
  ActionView::Base.send :include, BackLinkHelper
9
+ ActionView::Base.send :include, StackHelper
8
10
  ActionController::Base.send :include, Actions
9
11
  end
@@ -26,6 +26,7 @@ module Actions
26
26
  end
27
27
 
28
28
  def dissolve
29
+ # Erase the navigation stack and restart it at the current controller action.
29
30
  session[:tree] = request.original_url
30
31
  end
31
32
 
@@ -36,4 +37,15 @@ module Actions
36
37
  tree.delete_if { |x| x = path }
37
38
  session[:tree] = tree.join(",")
38
39
  end
40
+
41
+ def stepback(steps = nil)
42
+ # Redirect to a specific point in the navigation stack from the controller
43
+ tree = session[:tree].split(",")
44
+ unless steps == nil
45
+ target = tree.reverse[steps - 1]
46
+ else
47
+ target = tree.last
48
+ end
49
+ redirect_to target
50
+ end
39
51
  end
@@ -0,0 +1,9 @@
1
+ module StackHelper
2
+ def stack
3
+ content_tag :ol do
4
+ session[:tree].split(",").each do |path|
5
+ concat content_tag :li, path
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Backpedal
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backpedal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - greyoxide
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-15 00:00:00.000000000 Z
11
+ date: 2020-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -47,6 +47,7 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - ".gitignore"
49
49
  - Gemfile
50
+ - Gemfile.lock
50
51
  - LICENSE.txt
51
52
  - README.md
52
53
  - Rakefile
@@ -55,8 +56,9 @@ files:
55
56
  - bin/setup
56
57
  - lib/backpedal.rb
57
58
  - lib/backpedal/actions.rb
58
- - lib/backpedal/back_link_helper.rb
59
59
  - lib/backpedal/builder.rb
60
+ - lib/backpedal/helpers/back_link_helper.rb
61
+ - lib/backpedal/helpers/stack_helper.rb
60
62
  - lib/backpedal/version.rb
61
63
  homepage: https://github.com/Greyoxide/backpedal
62
64
  licenses:
@@ -79,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
81
  - !ruby/object:Gem::Version
80
82
  version: '0'
81
83
  requirements: []
82
- rubygems_version: 3.0.1
84
+ rubygems_version: 3.0.6
83
85
  signing_key:
84
86
  specification_version: 4
85
87
  summary: A Rails gem that gives your users a universal back link across multiple routes.