redirectr 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README +7 -6
  2. data/lib/redirectr.rb +18 -11
  3. metadata +6 -6
data/README CHANGED
@@ -1,5 +1,4 @@
1
- Redirectr
2
- =========
1
+ = Redirectr
3
2
 
4
3
  In many web applications, the user triggers actions that result in simple or complex workflows that should, after that workflow is finished, result in the user being redirected to the page where he initially started it. Another example would be a "back"-Link on any page.
5
4
  A simple but completely Un-RESTful way would be to store the "current" page in a cookie each time the user calls an action and redirect to the url stored there if needed.
@@ -10,8 +9,7 @@ Redirectr really does nothing more than provide a simple API for exactly that.
10
9
 
11
10
  Redirectr provides a few Controller and Helper methods that will be included in your ApplicationController and ApplicationHelper, respectively.
12
11
 
13
- Installation
14
- ============
12
+ == Installation
15
13
 
16
14
  With Rails 3, just at the following to your Gemfile
17
15
 
@@ -21,8 +19,7 @@ and then call
21
19
 
22
20
  bundle install
23
21
 
24
- Example
25
- =======
22
+ == Example
26
23
 
27
24
  Suppose you have an application with a contact form that can be reached via a footer link on every page. After submitting the form, the user should be redirected to the page he was before clicking on the "contact form" link.
28
25
 
@@ -47,4 +44,8 @@ and finally, in the 'create' action of your ContactsController:
47
44
  for more detailled examples, see the Rdoc documentation.
48
45
 
49
46
 
47
+ == Changelog
48
+
49
+ 0.0.7: Add Rails 2 compatibility (Thanks to Falk Hoppe)
50
+
50
51
  Copyright (c) 2010 Willem van Kerkhof <wvk@consolving.de>, released under the MIT license
data/lib/redirectr.rb CHANGED
@@ -118,19 +118,25 @@ module Redirectr
118
118
  end
119
119
 
120
120
  module Helpers
121
- # Create a link back to the path specified in the referrer-param.
122
- # title can be either a text string or anything else like an image.
123
- # Remember to call #html_safe on the title argument if it contains
124
- # HTML and you are using Rails 3.
125
- def link_to_back(title, options = {})
126
- link_to title, back_or_default, options
121
+ def self.included(base)
122
+ base.send :include, InstanceMethods
127
123
  end
124
+
125
+ module InstanceMethods
126
+ # Create a link back to the path specified in the referrer-param.
127
+ # title can be either a text string or anything else like an image.
128
+ # Remember to call #html_safe on the title argument if it contains
129
+ # HTML and you are using Rails 3.
130
+ def link_to_back(title, options = {})
131
+ link_to title, back_or_default, options
132
+ end
128
133
 
129
- # Create a hidden input field containing the referrer or current path.
130
- # Handy for use in forms that are called with a referrer param which
131
- # has to be passed on and respected by the form processing action.
132
- def hidden_referrer_input_tag(options = {})
133
- hidden_field_tag :referrer, referrer_or_current_path, options
134
+ # Create a hidden input field containing the referrer or current path.
135
+ # Handy for use in forms that are called with a referrer param which
136
+ # has to be passed on and respected by the form processing action.
137
+ def hidden_referrer_input_tag(options = {})
138
+ hidden_field_tag :referrer, referrer_or_current_path, options
139
+ end
134
140
  end
135
141
 
136
142
  end # module Helpers
@@ -138,3 +144,4 @@ end # module Redirectr
138
144
 
139
145
  ActionController::Base.send :include, Redirectr::ControllerMethods
140
146
  ActionView::Helpers.send :include, Redirectr::Helpers
147
+ ActionView::Base.send :include, Redirectr::Helpers
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redirectr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
4
+ hash: 17
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Willem van Kerkhof
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-25 00:00:00 +01:00
18
+ date: 2011-09-06 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  requirements: []
62
62
 
63
63
  rubyforge_project:
64
- rubygems_version: 1.3.7
64
+ rubygems_version: 1.5.3
65
65
  signing_key:
66
66
  specification_version: 3
67
67
  summary: Provides Rails-helper methods for referrer-style backlinks