wontomedia 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -1
- data/VERSION.yml +1 -1
- data/vendor/plugins/redirect_routing/MIT-LICENSE +21 -0
- data/vendor/plugins/redirect_routing/README +64 -0
- data/vendor/plugins/redirect_routing/Rakefile +42 -0
- data/vendor/plugins/redirect_routing/VERSION.yml +4 -0
- data/vendor/plugins/redirect_routing/init.rb +3 -0
- data/vendor/plugins/redirect_routing/lib/redirect_routing.rb +2 -0
- data/vendor/plugins/redirect_routing/lib/redirect_routing/routes.rb +7 -0
- data/vendor/plugins/redirect_routing/lib/redirect_routing_controller.rb +25 -0
- data/vendor/plugins/redirect_routing/redirect_routing.gemspec +51 -0
- data/vendor/plugins/redirect_routing/test/redirect_routing_test.rb +91 -0
- data/vendor/plugins/redirect_routing/test/test_helper.rb +27 -0
- metadata +13 -2
data/Rakefile
CHANGED
@@ -52,7 +52,9 @@ ENDOSTRING
|
|
52
52
|
s.extra_rdoc_files = ["README"]
|
53
53
|
|
54
54
|
s.files = FileList["[A-Z]*", "assets/wontomedia-sample.rb",
|
55
|
-
"vendor/plugins/asset_packager/**/*",
|
55
|
+
"vendor/plugins/asset_packager/**/*",
|
56
|
+
"vendor/plugins/redirect_routing/**/*",
|
57
|
+
"doc/*", "doc/scripts/*",
|
56
58
|
"{app,config,bin,db,default-custom,generators,lib,public,script}/**/*"].
|
57
59
|
exclude("database.yml", "wontomedia.rb",
|
58
60
|
"**/*_packaged.js", "**/*_packaged.css"
|
data/VERSION.yml
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2006 Lars Pind
|
2
|
+
Copyright (c) 2008 Manfred Stienstra, Fingertips <manfred@fngtps.com>
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,64 @@
|
|
1
|
+
RedirectRouting
|
2
|
+
===============
|
3
|
+
|
4
|
+
Forked by Seamus Abshere (seamus@abshere.net)
|
5
|
+
|
6
|
+
Note: you may have to put
|
7
|
+
|
8
|
+
ActionController::Routing::RouteSet::Mapper.send :include, RedirectRouting::Routes
|
9
|
+
|
10
|
+
at the top of config/routes.rb.
|
11
|
+
|
12
|
+
This plugin lets you do simple redirects straight from your routes.rb file:
|
13
|
+
|
14
|
+
map.redirect '', :controller => 'events'
|
15
|
+
|
16
|
+
This will make the root of your site redirect to the events controller, typically at /events.
|
17
|
+
|
18
|
+
You can redirect any URL to any set of options, or event a string URL, like this:
|
19
|
+
|
20
|
+
map.redirect 'test', 'http://example.com'
|
21
|
+
|
22
|
+
GET /test, and you'll be redirected to my blog.
|
23
|
+
|
24
|
+
You can also set the status to be a 301 permanent redirect instead of a temporary 302:
|
25
|
+
|
26
|
+
map.redirect 'oldurl', 'newurl', :permament => true
|
27
|
+
map.redirect 'oldurl', :controller => 'new_controller', :action => 'new_action', :permament => true
|
28
|
+
|
29
|
+
Finally you can preserve wildcard paths
|
30
|
+
|
31
|
+
map.redirect 'festivals/*path', 'http://example.com/events/festivals', :keep_path => :path
|
32
|
+
map.redirect 'news/*articles', 'http://blog.example.com', :keep_path => :articles
|
33
|
+
|
34
|
+
Motivation
|
35
|
+
----------
|
36
|
+
|
37
|
+
Why this plugin?
|
38
|
+
|
39
|
+
Because if Rails Routing is supposed to be a Ruby replacement for mod_rewrite, then at least some redirect capability is called for.
|
40
|
+
|
41
|
+
But more concretely, because there's no good alternative unless you're using Apache. The alternative options that I've been able to figure out are:
|
42
|
+
|
43
|
+
* Configure your web server to do the redirect for you, which is trivial with mod_rewrite in Apache, but not so trivial with Mongrel, or
|
44
|
+
* Manually create a controller for the sole purpose of redirecting, or
|
45
|
+
* Tack the redirect onto another controller, which isn't very RESTful
|
46
|
+
|
47
|
+
If there's demand, I'll add a switch for a permanent redirect, but I don't have the need yet.
|
48
|
+
|
49
|
+
If you know of a simpler way to do this, please let me know.
|
50
|
+
|
51
|
+
Credits
|
52
|
+
-------
|
53
|
+
|
54
|
+
Written by Lars Pind
|
55
|
+
|
56
|
+
http://pinds.com
|
57
|
+
|
58
|
+
Changelog
|
59
|
+
---------
|
60
|
+
|
61
|
+
* Added :keep_path options [Seamus Abshere & Manfred Stienstra]
|
62
|
+
* Updated to Rails Edge [Manfred Stienstra]
|
63
|
+
* Support for 301 redirects [Gioele Barabucci]
|
64
|
+
* Silence warning about missing helper [Tim Connor]
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the test plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.pattern = 'test/**/*_test.rb'
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Generate documentation for the test plugin.'
|
16
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
+
rdoc.rdoc_dir = 'rdoc'
|
18
|
+
rdoc.title = 'Test'
|
19
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
20
|
+
rdoc.rdoc_files.include('README')
|
21
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
+
end
|
23
|
+
|
24
|
+
begin
|
25
|
+
require 'jeweler'
|
26
|
+
Jeweler::Tasks.new do |spec|
|
27
|
+
spec.name = "redirect_routing"
|
28
|
+
|
29
|
+
spec.author = "Manfred Stienstra"
|
30
|
+
spec.email = "manfred@fngtps.com"
|
31
|
+
|
32
|
+
spec.description = <<-EOF
|
33
|
+
simple redirects straight from your routes.rb file
|
34
|
+
EOF
|
35
|
+
spec.summary = <<-EOF
|
36
|
+
simple redirects straight from your routes.rb file
|
37
|
+
EOF
|
38
|
+
spec.homepage = "http://github.com/seamusabshere/redirect_routing/tree/master"
|
39
|
+
end
|
40
|
+
rescue LoadError
|
41
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
42
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class RedirectRoutingController < ActionController::Base
|
2
|
+
def redirect
|
3
|
+
options = params[:args].extract_options!
|
4
|
+
status = options.delete(:permanent) == true ? :moved_permanently : :found
|
5
|
+
url_options = params[:args].first || options
|
6
|
+
|
7
|
+
if path_to_keep = options[:keep_path] and params[path_to_keep].present?
|
8
|
+
raise ArgumentError, "Redirect target should be a String when using the :keep_path option" unless url_options.is_a?(String)
|
9
|
+
parsed_url = URI.parse url_options
|
10
|
+
parsed_url.path = ([parsed_url.path] + params[path_to_keep]).join '/'
|
11
|
+
url_options = parsed_url.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
if params[:format].present?
|
15
|
+
case url_options
|
16
|
+
when String
|
17
|
+
url_options << ".#{params[:format]}"
|
18
|
+
when Hash
|
19
|
+
url_options[:format] = params[:format]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
redirect_to url_options, :status => status
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{redirect_routing}
|
8
|
+
s.version = "0.0.4"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Manfred Stienstra"]
|
12
|
+
s.date = %q{2009-10-08}
|
13
|
+
s.description = %q{ simple redirects straight from your routes.rb file
|
14
|
+
}
|
15
|
+
s.email = %q{manfred@fngtps.com}
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"README"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"MIT-LICENSE",
|
21
|
+
"README",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION.yml",
|
24
|
+
"init.rb",
|
25
|
+
"lib/redirect_routing.rb",
|
26
|
+
"lib/redirect_routing/routes.rb",
|
27
|
+
"lib/redirect_routing_controller.rb",
|
28
|
+
"redirect_routing.gemspec",
|
29
|
+
"test/redirect_routing_test.rb",
|
30
|
+
"test/test_helper.rb"
|
31
|
+
]
|
32
|
+
s.homepage = %q{http://github.com/seamusabshere/redirect_routing/tree/master}
|
33
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubygems_version = %q{1.3.5}
|
36
|
+
s.summary = %q{simple redirects straight from your routes.rb file}
|
37
|
+
s.test_files = [
|
38
|
+
"test/redirect_routing_test.rb",
|
39
|
+
"test/test_helper.rb"
|
40
|
+
]
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
|
+
s.specification_version = 3
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
47
|
+
else
|
48
|
+
end
|
49
|
+
else
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class EventsController < ActionController::Base
|
4
|
+
end
|
5
|
+
ActionController::Routing::Routes.add_route('/:controller/:action/:id')
|
6
|
+
|
7
|
+
class RedirectRoutingTest < TestCase
|
8
|
+
tests RedirectRoutingController
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@controller = RedirectRoutingController.new
|
12
|
+
@request = ActionController::TestRequest.new
|
13
|
+
@response = ActionController::TestResponse.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_redirect_routes
|
17
|
+
with_routing do |set|
|
18
|
+
set.draw do |map|
|
19
|
+
map.redirect '', :controller => 'events'
|
20
|
+
map.redirect 'test', 'http://example.com'
|
21
|
+
map.redirect 'oldurl', 'newurl', :permanent => true
|
22
|
+
map.redirect 'festivals/*path', 'http://example.com/events/festivals', :keep_path => :path
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_recognizes({ :controller => "redirect_routing", :action => "redirect", :args => [{ 'controller' => "events" }] }, "/")
|
26
|
+
assert_recognizes({ :controller => "redirect_routing", :action => "redirect", :args => ["http://example.com"] }, "/test")
|
27
|
+
assert_recognizes({ :controller => "redirect_routing", :action => "redirect", :args => ["newurl", {'permanent' => true}] }, "/oldurl")
|
28
|
+
assert_recognizes({ :controller => "redirect_routing", :action => "redirect", :args => ["http://example.com/events/festivals", {'keep_path' => :path}], :path => ['music', 'recent'] }, "/festivals/music/recent")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_redirect_controller_with_hash
|
33
|
+
get :redirect, :args => [{ :controller => "events" }]
|
34
|
+
assert_redirected_to :controller => "events"
|
35
|
+
assert_response 302
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_redirect_controller_with_string
|
39
|
+
get :redirect, :args => ["http://example.com"]
|
40
|
+
assert_redirected_to "http://example.com"
|
41
|
+
assert_response 302
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_permanent_redirect_controller_with_hash
|
45
|
+
get :redirect, :args => [{ :controller => "events", :permanent => true }]
|
46
|
+
assert_redirected_to :controller => "events"
|
47
|
+
assert_response 301
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_permanent_redirect_controller_with_string
|
51
|
+
get :redirect, :args => ["http://example.com", { :permanent => true }]
|
52
|
+
assert_redirected_to "http://example.com"
|
53
|
+
assert_response 301
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_redirect_controller_with_hash_and_append_path
|
57
|
+
assert_raises(ArgumentError) do
|
58
|
+
get :redirect, :args => [{ :controller => "events", :keep_path => :path }], :path => [ "festivals/recent" ]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_redirect_controller_with_string_and_append_path
|
63
|
+
get :redirect, :args => ["http://example.com", { :keep_path => :path }], :path => [ "festivals/recent" ]
|
64
|
+
assert_redirected_to "http://example.com/festivals/recent"
|
65
|
+
assert_response 302
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_redirect_controller_with_string_and_append_path_array
|
69
|
+
get :redirect, :args => ["http://example.com", { :keep_path => :path }], :path => [ "festivals", "recent" ]
|
70
|
+
assert_redirected_to "http://example.com/festivals/recent"
|
71
|
+
assert_response 302
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_permanent_redirect_controller_with_hash_and_append_path
|
75
|
+
assert_raises(ArgumentError) do
|
76
|
+
get :redirect, :args => [{ :controller => "events", :permanent => true, :keep_path => :path }], :path => [ "festivals/recent" ]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_permanent_redirect_controller_with_string_and_append_path
|
81
|
+
get :redirect, :args => ["http://example.com", { :permanent => true, :keep_path => :path }], :path => [ "festivals/recent" ]
|
82
|
+
assert_redirected_to "http://example.com/festivals/recent"
|
83
|
+
assert_response 301
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_redirect_normally_when_the_path_to_keep_is_blank
|
87
|
+
get :redirect, :args => ["http://example.com", { :keep_path => :unknown }], :path => [ "festivals/recent" ]
|
88
|
+
assert_redirected_to "http://example.com"
|
89
|
+
assert_response 302
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
ENV['RAILS_ENV'] = "test"
|
2
|
+
|
3
|
+
rails_vendor_path = File.expand_path('../../../vendor/rails')
|
4
|
+
if File.exist?(rails_vendor_path)
|
5
|
+
$:.concat([
|
6
|
+
File.join(rails_vendor_path, 'activesupport', 'lib'),
|
7
|
+
File.join(rails_vendor_path, 'actionpack', 'lib')
|
8
|
+
])
|
9
|
+
require 'active_support'
|
10
|
+
require 'action_controller'
|
11
|
+
require 'action_controller/test_process'
|
12
|
+
else
|
13
|
+
puts "\n[!] Tests only run when the plugin is installed in the plugins directory, running the tests against anything other than your particular Rails version doesn't really serve a purpose."
|
14
|
+
exit -1
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'test/unit'
|
18
|
+
|
19
|
+
begin
|
20
|
+
TestCase = ActionController::TestCase
|
21
|
+
rescue NameError
|
22
|
+
TestCase = Test::Unit::TestCase
|
23
|
+
end
|
24
|
+
|
25
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
26
|
+
require 'init'
|
27
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Glen E. Ivey
|
@@ -235,6 +235,17 @@ files:
|
|
235
235
|
- vendor/plugins/asset_packager/test/assets/stylesheets/screen.css
|
236
236
|
- vendor/plugins/asset_packager/test/assets/stylesheets/subdir/bar.css
|
237
237
|
- vendor/plugins/asset_packager/test/assets/stylesheets/subdir/foo.css
|
238
|
+
- vendor/plugins/redirect_routing/MIT-LICENSE
|
239
|
+
- vendor/plugins/redirect_routing/README
|
240
|
+
- vendor/plugins/redirect_routing/Rakefile
|
241
|
+
- vendor/plugins/redirect_routing/VERSION.yml
|
242
|
+
- vendor/plugins/redirect_routing/init.rb
|
243
|
+
- vendor/plugins/redirect_routing/lib/redirect_routing.rb
|
244
|
+
- vendor/plugins/redirect_routing/lib/redirect_routing/routes.rb
|
245
|
+
- vendor/plugins/redirect_routing/lib/redirect_routing_controller.rb
|
246
|
+
- vendor/plugins/redirect_routing/redirect_routing.gemspec
|
247
|
+
- vendor/plugins/redirect_routing/test/redirect_routing_test.rb
|
248
|
+
- vendor/plugins/redirect_routing/test/test_helper.rb
|
238
249
|
has_rdoc: true
|
239
250
|
homepage: http://wontomedia.rubyforge.org
|
240
251
|
licenses: []
|