speaking_url 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc
CHANGED
@@ -60,18 +60,23 @@ Additionally, the methods +upcase+ and +downcase+ are made Umlaut aware.
|
|
60
60
|
== Configuring routes
|
61
61
|
|
62
62
|
To actually deploy the new routes, the Gem ships with the
|
63
|
-
+speaking_url_resource+ method.
|
64
|
-
simply provide the resources as symbols:
|
65
|
-
|
63
|
+
+speaking_url_resource+ method. You simply provide the resources as symbols:
|
66
64
|
|
67
65
|
speaking_url_resource :person, :product
|
68
66
|
|
69
|
-
|
70
|
-
speaking url(s).
|
71
|
-
|
72
|
-
|
67
|
+
As a a result both - the person and product resource - are made accessible by
|
68
|
+
their speaking url(s). The controller is inferred from the model name, but can
|
69
|
+
be customized:
|
70
|
+
|
71
|
+
speaking_url_resource :person, :controller => 'vip/persons'
|
72
|
+
speaking_url_resource :product, :controller => 'my_products'
|
73
|
+
|
73
74
|
|
75
|
+
*NOTE*: You probably want to include the lines as one of your last
|
76
|
+
statements in your +route.rb+ file to:
|
74
77
|
|
78
|
+
* give standard routes higher priority
|
79
|
+
* and achieve better performance (due to DB calls in the routing process)
|
75
80
|
|
76
81
|
== Usage in Controllers
|
77
82
|
|
@@ -97,8 +102,11 @@ to use the speaking url helpers:
|
|
97
102
|
So far the Gem is pretty limited. What could be developed for following
|
98
103
|
version is:
|
99
104
|
|
105
|
+
* more configuration options
|
100
106
|
* support for other persistent storage mappers
|
101
|
-
*
|
107
|
+
* go to a single table/collection implementation for performance and more
|
108
|
+
flexibility (i.e. index and create actions/routes)
|
109
|
+
* make this a rack application
|
102
110
|
|
103
111
|
|
104
112
|
= License
|
@@ -5,6 +5,8 @@ module ActionDispatch::Routing
|
|
5
5
|
|
6
6
|
def speaking_url_resource(*resources)
|
7
7
|
|
8
|
+
options = resources.extract_options!
|
9
|
+
|
8
10
|
resources.map!(&:to_sym)
|
9
11
|
|
10
12
|
resources.each do |sym|
|
@@ -31,7 +33,9 @@ module ActionDispatch::Routing
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
|
-
|
36
|
+
controller = options[:controller] || klass.name.underscore.pluralize
|
37
|
+
|
38
|
+
match "*path", :to => "#{controller}#show", :constraints => current_address_constraint_class.new
|
35
39
|
match "*path" => redirect{|p, req| klass.find_by_url(req.path).current_url}, :constraints => old_address_constraint_class.new
|
36
40
|
|
37
41
|
end
|
data/lib/speaking_url/version.rb
CHANGED
data/test/routing_test.rb
CHANGED
@@ -40,3 +40,26 @@ class NavigationTest < ActionController::IntegrationTest
|
|
40
40
|
end
|
41
41
|
|
42
42
|
|
43
|
+
class RoutesConfigurationTest < ActionController::TestCase
|
44
|
+
|
45
|
+
test "controller specification" do
|
46
|
+
|
47
|
+
with_routing do |set|
|
48
|
+
set.draw do |map|
|
49
|
+
speaking_url_resource :article, :controller => 'nested/articles'
|
50
|
+
end
|
51
|
+
|
52
|
+
Article.delete_all
|
53
|
+
a = Article.new
|
54
|
+
a.add_mapping("/foo/bar")
|
55
|
+
|
56
|
+
assert_recognizes({:controller => 'nested/articles', :action => 'show', :path => "foo/bar"}, {:path => '/foo/bar'})
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: speaking_url
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kai Rubarth
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-29 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- test/dummy/Rakefile
|
71
71
|
- test/dummy/app/controllers/application_controller.rb
|
72
72
|
- test/dummy/app/controllers/articles_controller.rb
|
73
|
+
- test/dummy/app/controllers/nested/articles_controller.rb
|
73
74
|
- test/dummy/app/helpers/application_helper.rb
|
74
75
|
- test/dummy/app/models/article.rb
|
75
76
|
- test/dummy/app/views/layouts/application.html.erb
|
@@ -133,45 +134,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
134
|
requirements: []
|
134
135
|
|
135
136
|
rubyforge_project: speaking_url
|
136
|
-
rubygems_version: 1.
|
137
|
+
rubygems_version: 1.6.2
|
137
138
|
signing_key:
|
138
139
|
specification_version: 3
|
139
140
|
summary: allows arbitrary url for resources and facilitates seo-friendly changing of urls.
|
140
|
-
test_files:
|
141
|
-
|
142
|
-
- test/dummy/Rakefile
|
143
|
-
- test/dummy/app/controllers/application_controller.rb
|
144
|
-
- test/dummy/app/controllers/articles_controller.rb
|
145
|
-
- test/dummy/app/helpers/application_helper.rb
|
146
|
-
- test/dummy/app/models/article.rb
|
147
|
-
- test/dummy/app/views/layouts/application.html.erb
|
148
|
-
- test/dummy/config.ru
|
149
|
-
- test/dummy/config/application.rb
|
150
|
-
- test/dummy/config/boot.rb
|
151
|
-
- test/dummy/config/database.yml
|
152
|
-
- test/dummy/config/environment.rb
|
153
|
-
- test/dummy/config/environments/development.rb
|
154
|
-
- test/dummy/config/environments/production.rb
|
155
|
-
- test/dummy/config/environments/test.rb
|
156
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
157
|
-
- test/dummy/config/initializers/inflections.rb
|
158
|
-
- test/dummy/config/initializers/mime_types.rb
|
159
|
-
- test/dummy/config/initializers/secret_token.rb
|
160
|
-
- test/dummy/config/initializers/session_store.rb
|
161
|
-
- test/dummy/config/locales/en.yml
|
162
|
-
- test/dummy/config/mongoid.yml
|
163
|
-
- test/dummy/config/routes.rb
|
164
|
-
- test/dummy/public/404.html
|
165
|
-
- test/dummy/public/422.html
|
166
|
-
- test/dummy/public/500.html
|
167
|
-
- test/dummy/public/favicon.ico
|
168
|
-
- test/dummy/public/javascripts/application.js
|
169
|
-
- test/dummy/public/javascripts/controls.js
|
170
|
-
- test/dummy/public/javascripts/dragdrop.js
|
171
|
-
- test/dummy/public/javascripts/effects.js
|
172
|
-
- test/dummy/public/javascripts/prototype.js
|
173
|
-
- test/dummy/public/javascripts/rails.js
|
174
|
-
- test/dummy/public/stylesheets/.gitkeep
|
175
|
-
- test/dummy/script/rails
|
176
|
-
- test/routing_test.rb
|
177
|
-
- test/test_helper.rb
|
141
|
+
test_files: []
|
142
|
+
|