radiant 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of radiant might be problematic. Click here for more details.
- data/CHANGELOG +61 -7
- data/CONTRIBUTORS +15 -0
- data/app/controllers/admin/export_controller.rb +1 -1
- data/app/controllers/admin/page_controller.rb +1 -0
- data/app/controllers/admin/user_controller.rb +2 -1
- data/app/controllers/application.rb +7 -8
- data/app/helpers/admin/node_helper.rb +84 -0
- data/app/helpers/admin/page_helper.rb +1 -19
- data/app/helpers/application_helper.rb +15 -9
- data/app/models/file_not_found_page.rb +2 -2
- data/app/models/page.rb +22 -18
- data/app/models/page_context.rb +9 -0
- data/app/models/radiant/config.rb +4 -2
- data/app/models/response_cache.rb +18 -12
- data/app/models/standard_tags.rb +111 -50
- data/app/views/admin/extension/index.rhtml +2 -2
- data/app/views/admin/layout/edit.rhtml +2 -2
- data/app/views/admin/layout/remove.rhtml +2 -2
- data/app/views/admin/page/_node.rhtml +4 -26
- data/app/views/admin/page/_part.rhtml +9 -14
- data/app/views/admin/page/edit.rhtml +38 -121
- data/app/views/admin/page/index.rhtml +2 -6
- data/app/views/admin/page/remove.rhtml +2 -2
- data/app/views/admin/snippet/edit.rhtml +3 -3
- data/app/views/admin/snippet/index.rhtml +2 -2
- data/app/views/admin/snippet/remove.rhtml +2 -2
- data/app/views/admin/user/edit.rhtml +4 -4
- data/app/views/admin/user/preferences.rhtml +2 -2
- data/app/views/admin/welcome/login.rhtml +1 -1
- data/config/environment.rb +79 -78
- data/db/schema.rb +2 -0
- data/lib/local_time.rb +12 -0
- data/lib/plugins/extension_patches/lib/fixture_loading_extension.rb +1 -1
- data/lib/plugins/extension_patches/lib/mailer_view_paths_extension.rb +3 -3
- data/lib/radiant.rb +1 -1
- data/lib/radiant/extension.rb +9 -3
- data/lib/radiant/extension_loader.rb +2 -2
- data/lib/tasks/extensions.rake +23 -8
- data/public/javascripts/admin.js +89 -0
- data/public/javascripts/controls.js +486 -354
- data/public/javascripts/dragdrop.js +90 -58
- data/public/javascripts/effects.js +398 -364
- data/public/javascripts/pngfix.js +37 -37
- data/public/javascripts/prototype.js +2764 -1095
- data/public/javascripts/ruledtable.js +10 -25
- data/public/javascripts/sitemap.js +74 -112
- data/public/javascripts/string.js +1 -7
- data/public/javascripts/tabcontrol.js +71 -86
- data/public/javascripts/tag_reference_search.js +19 -26
- data/public/stylesheets/admin/main.css +11 -5
- data/test/fixtures/extensions/01_basic/lib/new_module.rb +2 -0
- data/test/fixtures/page_parts.yml +16 -1
- data/test/fixtures/pages.yml +47 -84
- data/test/functional/extension_initialization_test.rb +11 -0
- data/test/helpers/login_test_helper.rb +12 -1
- data/test/helpers/page_test_helper.rb +6 -0
- data/test/helpers/render_test_helper.rb +11 -8
- data/test/test_helper.rb +1 -12
- data/test/unit/file_not_found_page_test.rb +5 -1
- data/test/unit/local_time_test.rb +45 -0
- data/test/unit/page_context_test.rb +32 -1
- data/test/unit/page_test.rb +45 -11
- data/test/unit/radiant/config_test.rb +1 -1
- data/test/unit/response_cache_test.rb +27 -2
- data/test/unit/standard_tags_test.rb +60 -15
- data/vendor/extensions/archive/README +29 -0
- data/vendor/extensions/archive/Rakefile +25 -0
- data/{app → vendor/extensions/archive/app}/models/archive_day_index_page.rb +0 -0
- data/{app → vendor/extensions/archive/app}/models/archive_finder.rb +8 -6
- data/{app → vendor/extensions/archive/app}/models/archive_month_index_page.rb +0 -0
- data/{app → vendor/extensions/archive/app}/models/archive_page.rb +0 -0
- data/{app → vendor/extensions/archive/app}/models/archive_year_index_page.rb +0 -0
- data/vendor/extensions/archive/archive_extension.rb +19 -0
- data/{lib → vendor/extensions/archive/lib}/archive_index_tags_and_methods.rb +0 -0
- data/vendor/extensions/archive/lib/tasks/archive_extension_tasks.rake +28 -0
- data/vendor/extensions/archive/test/fixtures/pages.yml +397 -0
- data/vendor/extensions/archive/test/functional/archive_extension_test.rb +16 -0
- data/{test → vendor/extensions/archive/test}/helpers/archive_index_test_helper.rb +0 -0
- data/vendor/extensions/archive/test/test_helper.rb +19 -0
- data/{test → vendor/extensions/archive/test}/unit/archive_day_index_page_test.rb +0 -0
- data/{test → vendor/extensions/archive/test}/unit/archive_month_index_page_test.rb +0 -0
- data/{test → vendor/extensions/archive/test}/unit/archive_page_test.rb +7 -1
- data/{test → vendor/extensions/archive/test}/unit/archive_year_index_page_test.rb +0 -0
- data/vendor/rails/actionmailer/CHANGELOG +10 -0
- data/vendor/rails/actionmailer/Rakefile +1 -1
- data/vendor/rails/actionmailer/lib/action_mailer/version.rb +1 -1
- data/vendor/rails/actionpack/CHANGELOG +51 -2
- data/vendor/rails/actionpack/Rakefile +1 -1
- data/vendor/rails/actionpack/lib/action_controller/assertions/dom_assertions.rb +2 -2
- data/vendor/rails/actionpack/lib/action_controller/assertions/model_assertions.rb +1 -1
- data/vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb +3 -0
- data/vendor/rails/actionpack/lib/action_controller/assertions/routing_assertions.rb +1 -0
- data/vendor/rails/actionpack/lib/action_controller/assertions/selector_assertions.rb +2 -0
- data/vendor/rails/actionpack/lib/action_controller/base.rb +7 -1
- data/vendor/rails/actionpack/lib/action_controller/caching.rb +39 -38
- data/vendor/rails/actionpack/lib/action_controller/cgi_ext/pstore_performance_fix.rb +30 -0
- data/vendor/rails/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb +1 -1
- data/vendor/rails/actionpack/lib/action_controller/cgi_process.rb +13 -4
- data/vendor/rails/actionpack/lib/action_controller/cookies.rb +5 -3
- data/vendor/rails/actionpack/lib/action_controller/filters.rb +176 -77
- data/vendor/rails/actionpack/lib/action_controller/integration.rb +31 -21
- data/vendor/rails/actionpack/lib/action_controller/macros/in_place_editing.rb +1 -1
- data/vendor/rails/actionpack/lib/action_controller/pagination.rb +7 -1
- data/vendor/rails/actionpack/lib/action_controller/resources.rb +117 -32
- data/vendor/rails/actionpack/lib/action_controller/routing.rb +56 -23
- data/vendor/rails/actionpack/lib/action_controller/test_process.rb +5 -2
- data/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb +4 -1
- data/vendor/rails/actionpack/lib/action_controller/verification.rb +1 -0
- data/vendor/rails/actionpack/lib/action_pack/version.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/base.rb +25 -19
- data/vendor/rails/actionpack/lib/action_view/compiled_templates.rb +2 -2
- data/vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb +18 -18
- data/vendor/rails/actionpack/lib/action_view/helpers/debug_helper.rb +10 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/deprecated_helper.rb +3 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb +33 -17
- data/vendor/rails/actionpack/test/activerecord/pagination_test.rb +9 -0
- data/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +13 -0
- data/vendor/rails/actionpack/test/controller/addresses_render_test.rb +4 -1
- data/vendor/rails/actionpack/test/controller/base_test.rb +1 -1
- data/vendor/rails/actionpack/test/controller/caching_test.rb +3 -2
- data/vendor/rails/actionpack/test/controller/cookie_test.rb +11 -0
- data/vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb +18 -0
- data/vendor/rails/actionpack/test/controller/filter_params_test.rb +1 -0
- data/vendor/rails/actionpack/test/controller/filters_test.rb +149 -26
- data/vendor/rails/actionpack/test/controller/integration_test.rb +93 -8
- data/vendor/rails/actionpack/test/controller/resources_test.rb +215 -36
- data/vendor/rails/actionpack/test/controller/routing_test.rb +2 -2
- data/vendor/rails/actionpack/test/controller/test_test.rb +16 -0
- data/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +66 -10
- data/vendor/rails/actionpack/test/controller/verification_test.rb +15 -0
- data/vendor/rails/actionpack/test/fixtures/test/hello_world.rxml +2 -1
- data/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb +5 -0
- data/vendor/rails/actionpack/test/template/compiled_templates_test.rb +29 -17
- data/vendor/rails/actionpack/test/template/javascript_helper_test.rb +4 -4
- data/vendor/rails/actionpack/test/template/number_helper_test.rb +1 -1
- data/vendor/rails/actionpack/test/template/prototype_helper_test.rb +13 -13
- data/vendor/rails/actionwebservice/CHANGELOG +14 -0
- data/vendor/rails/actionwebservice/Rakefile +2 -2
- data/vendor/rails/actionwebservice/lib/action_web_service/version.rb +1 -1
- data/vendor/rails/activerecord/CHANGELOG +34 -0
- data/vendor/rails/activerecord/Rakefile +1 -1
- data/vendor/rails/activerecord/lib/active_record/acts/list.rb +14 -2
- data/vendor/rails/activerecord/lib/active_record/acts/tree.rb +7 -0
- data/vendor/rails/activerecord/lib/active_record/associations.rb +29 -14
- data/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +5 -1
- data/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb +2 -2
- data/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb +10 -0
- data/vendor/rails/activerecord/lib/active_record/base.rb +12 -3
- data/vendor/rails/activerecord/lib/active_record/calculations.rb +2 -2
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +1 -1
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb +1 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +2 -2
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb +54 -38
- data/vendor/rails/activerecord/lib/active_record/deprecated_finders.rb +3 -3
- data/vendor/rails/activerecord/lib/active_record/fixtures.rb +1 -1
- data/vendor/rails/activerecord/lib/active_record/timestamp.rb +0 -9
- data/vendor/rails/activerecord/lib/active_record/version.rb +1 -1
- data/vendor/rails/activerecord/test/associations/eager_test.rb +13 -0
- data/vendor/rails/activerecord/test/associations/join_model_test.rb +10 -1
- data/vendor/rails/activerecord/test/associations_test.rb +36 -3
- data/vendor/rails/activerecord/test/base_test.rb +17 -4
- data/vendor/rails/activerecord/test/defaults_test.rb +15 -0
- data/vendor/rails/activerecord/test/fixtures/author.rb +1 -0
- data/vendor/rails/activerecord/test/fixtures/binaries.yml +437 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/schema.rb +13 -0
- data/vendor/rails/activerecord/test/fixtures/developer.rb +10 -0
- data/vendor/rails/activerecord/test/fixtures_test.rb +9 -5
- data/vendor/rails/activerecord/test/migration_test.rb +9 -10
- data/vendor/rails/activerecord/test/mixin_test.rb +47 -0
- data/vendor/rails/activerecord/test/validations_test.rb +2 -2
- data/vendor/rails/activesupport/CHANGELOG +16 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb +9 -3
- data/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb +48 -3
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/introspection.rb +14 -0
- data/vendor/rails/activesupport/lib/active_support/dependencies.rb +3 -3
- data/vendor/rails/activesupport/lib/active_support/json/encoders/core.rb +5 -3
- data/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb +6 -6
- data/vendor/rails/activesupport/lib/active_support/version.rb +1 -1
- data/vendor/rails/activesupport/test/core_ext/hash_ext_test.rb +37 -0
- data/vendor/rails/activesupport/test/core_ext/module_test.rb +8 -0
- data/vendor/rails/activesupport/test/dependencies_test.rb +11 -0
- data/vendor/rails/activesupport/test/{json.rb → json_test.rb} +15 -5
- data/vendor/rails/railties/CHANGELOG +25 -1
- data/vendor/rails/railties/README +32 -3
- data/vendor/rails/railties/Rakefile +5 -5
- data/vendor/rails/railties/environments/boot.rb +12 -18
- data/vendor/rails/railties/environments/environment.rb +15 -15
- data/vendor/rails/railties/lib/dispatcher.rb +1 -2
- data/vendor/rails/railties/lib/initializer.rb +33 -9
- data/vendor/rails/railties/lib/rails/version.rb +1 -1
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +1 -1
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb +1 -0
- data/vendor/rails/railties/lib/railties_path.rb +1 -1
- data/vendor/rails/railties/lib/tasks/framework.rake +4 -4
- data/vendor/rails/railties/lib/tasks/routes.rake +17 -0
- data/vendor/rails/release.rb +2 -2
- metadata +1877 -1848
@@ -24,7 +24,7 @@ module ActionController
|
|
24
24
|
define_method("set_#{object}_#{attribute}") do
|
25
25
|
@item = object.to_s.camelize.constantize.find(params[:id])
|
26
26
|
@item.update_attribute(attribute, params[:value])
|
27
|
-
render :text => @item.send(attribute)
|
27
|
+
render :text => @item.send(attribute).to_s
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module ActionController
|
2
2
|
# === Action Pack pagination for Active Record collections
|
3
3
|
#
|
4
|
-
# DEPRECATION WARNING: Pagination will be
|
4
|
+
# DEPRECATION WARNING: Pagination will be moved to a plugin in Rails 2.0.
|
5
|
+
# Install the classic_pagination plugin for forward compatibility:
|
6
|
+
# script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination
|
5
7
|
#
|
6
8
|
# The Pagination module aids in the process of paging large collections of
|
7
9
|
# Active Record objects. It offers macro-style automatic fetching of your
|
@@ -130,6 +132,8 @@ module ActionController
|
|
130
132
|
paginator_and_collection_for(collection_id, options)
|
131
133
|
end
|
132
134
|
|
135
|
+
deprecate :paginate => 'Pagination is moving to a plugin in Rails 2.0: script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination'
|
136
|
+
|
133
137
|
# These methods become class methods on any controller
|
134
138
|
module ClassMethods
|
135
139
|
# Creates a +before_filter+ which automatically paginates an Active
|
@@ -148,6 +152,8 @@ module ActionController
|
|
148
152
|
OPTIONS[self][collection_id] = options
|
149
153
|
end
|
150
154
|
end
|
155
|
+
|
156
|
+
deprecate :paginate => 'Pagination is moving to a plugin in Rails 2.0: script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination'
|
151
157
|
end
|
152
158
|
|
153
159
|
def create_paginators_and_retrieve_collections #:nodoc:
|
@@ -2,48 +2,68 @@ module ActionController
|
|
2
2
|
module Resources
|
3
3
|
class Resource #:nodoc:
|
4
4
|
attr_reader :collection_methods, :member_methods, :new_methods
|
5
|
-
attr_reader :path_prefix, :
|
5
|
+
attr_reader :path_prefix, :new_name_prefix
|
6
6
|
attr_reader :plural, :singular
|
7
7
|
attr_reader :options
|
8
8
|
|
9
9
|
def initialize(entities, options)
|
10
10
|
@plural = entities
|
11
11
|
@singular = options[:singular] || plural.to_s.singularize
|
12
|
-
|
12
|
+
|
13
13
|
@options = options
|
14
14
|
|
15
15
|
arrange_actions
|
16
16
|
add_default_actions
|
17
17
|
set_prefixes
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def controller
|
21
21
|
@controller ||= (options[:controller] || plural).to_s
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def path
|
25
25
|
@path ||= "#{path_prefix}/#{plural}"
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def new_path
|
29
29
|
@new_path ||= "#{path}/new"
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def member_path
|
33
33
|
@member_path ||= "#{path}/:id"
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def nesting_path_prefix
|
37
37
|
@nesting_path_prefix ||= "#{path}/:#{singular}_id"
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
|
+
def deprecate_name_prefix?
|
41
|
+
@name_prefix.blank? && !@new_name_prefix.blank?
|
42
|
+
end
|
43
|
+
|
44
|
+
def name_prefix
|
45
|
+
deprecate_name_prefix? ? @new_name_prefix : @name_prefix
|
46
|
+
end
|
47
|
+
|
48
|
+
def old_name_prefix
|
49
|
+
@name_prefix
|
50
|
+
end
|
51
|
+
|
52
|
+
def nesting_name_prefix
|
53
|
+
"#{new_name_prefix}#{singular}_"
|
54
|
+
end
|
55
|
+
|
56
|
+
def action_separator
|
57
|
+
@action_separator ||= Base.resource_action_separator
|
58
|
+
end
|
59
|
+
|
40
60
|
protected
|
41
61
|
def arrange_actions
|
42
62
|
@collection_methods = arrange_actions_by_methods(options.delete(:collection))
|
43
63
|
@member_methods = arrange_actions_by_methods(options.delete(:member))
|
44
64
|
@new_methods = arrange_actions_by_methods(options.delete(:new))
|
45
65
|
end
|
46
|
-
|
66
|
+
|
47
67
|
def add_default_actions
|
48
68
|
add_default_action(member_methods, :get, :edit)
|
49
69
|
add_default_action(new_methods, :get, :new)
|
@@ -52,6 +72,7 @@ module ActionController
|
|
52
72
|
def set_prefixes
|
53
73
|
@path_prefix = options.delete(:path_prefix)
|
54
74
|
@name_prefix = options.delete(:name_prefix)
|
75
|
+
@new_name_prefix = options.delete(:new_name_prefix)
|
55
76
|
end
|
56
77
|
|
57
78
|
def arrange_actions_by_methods(actions)
|
@@ -60,7 +81,7 @@ module ActionController
|
|
60
81
|
flipped_hash
|
61
82
|
end
|
62
83
|
end
|
63
|
-
|
84
|
+
|
64
85
|
def add_default_action(collection, method, action)
|
65
86
|
(collection[method] ||= []).unshift(action)
|
66
87
|
end
|
@@ -178,11 +199,11 @@ module ActionController
|
|
178
199
|
#
|
179
200
|
# The comment resources work the same, but must now include a value for :article_id.
|
180
201
|
#
|
181
|
-
#
|
182
|
-
#
|
202
|
+
# article_comments_url(@article)
|
203
|
+
# article_comment_url(@article, @comment)
|
183
204
|
#
|
184
|
-
#
|
185
|
-
#
|
205
|
+
# article_comments_url(:article_id => @article)
|
206
|
+
# article_comment_url(:article_id => @article, :id => @comment)
|
186
207
|
#
|
187
208
|
# * <tt>:name_prefix</tt> -- define a prefix for all generated routes, usually ending in an underscore.
|
188
209
|
# Use this if you have named routes that may clash.
|
@@ -192,7 +213,7 @@ module ActionController
|
|
192
213
|
#
|
193
214
|
# * <tt>:collection</tt> -- add named routes for other actions that operate on the collection.
|
194
215
|
# Takes a hash of <tt>#{action} => #{method}</tt>, where method is <tt>:get</tt>/<tt>:post</tt>/<tt>:put</tt>/<tt>:delete</tt>
|
195
|
-
# or <tt>:any</tt> if the method does not matter. These routes map to a URL like /messages
|
216
|
+
# or <tt>:any</tt> if the method does not matter. These routes map to a URL like /messages/rss, with a route of rss_messages_url.
|
196
217
|
# * <tt>:member</tt> -- same as :collection, but for actions that operate on a specific member.
|
197
218
|
# * <tt>:new</tt> -- same as :collection, but for actions that operate on the new resource action.
|
198
219
|
#
|
@@ -204,19 +225,19 @@ module ActionController
|
|
204
225
|
# # --> GET /thread/7/messages/1
|
205
226
|
#
|
206
227
|
# map.resources :messages, :collection => { :rss => :get }
|
207
|
-
# # --> GET /messages
|
228
|
+
# # --> GET /messages/rss (maps to the #rss action)
|
208
229
|
# # also adds a named route called "rss_messages"
|
209
230
|
#
|
210
231
|
# map.resources :messages, :member => { :mark => :post }
|
211
|
-
# # --> POST /messages/1
|
232
|
+
# # --> POST /messages/1/mark (maps to the #mark action)
|
212
233
|
# # also adds a named route called "mark_message"
|
213
234
|
#
|
214
235
|
# map.resources :messages, :new => { :preview => :post }
|
215
|
-
# # --> POST /messages/new
|
236
|
+
# # --> POST /messages/new/preview (maps to the #preview action)
|
216
237
|
# # also adds a named route called "preview_new_message"
|
217
238
|
#
|
218
239
|
# map.resources :messages, :new => { :new => :any, :preview => :post }
|
219
|
-
# # --> POST /messages/new
|
240
|
+
# # --> POST /messages/new/preview (maps to the #preview action)
|
220
241
|
# # also adds a named route called "preview_new_message"
|
221
242
|
# # --> /messages/new can be invoked via any request method
|
222
243
|
#
|
@@ -235,9 +256,10 @@ module ActionController
|
|
235
256
|
# /account profile.
|
236
257
|
#
|
237
258
|
# See map.resources for general conventions. These are the main differences:
|
238
|
-
# -
|
239
|
-
# -
|
240
|
-
# -
|
259
|
+
# - A singular name is given to map.resource. The default controller name is taken from the singular name.
|
260
|
+
# - There is no <tt>:collection</tt> option as there is only the singleton resource.
|
261
|
+
# - There is no <tt>:singular</tt> option as the singular name is passed to map.resource.
|
262
|
+
# - No default index route is created for the singleton resource controller.
|
241
263
|
# - When nesting singleton resources, only the singular name is used as the path prefix (example: 'account/messages/1')
|
242
264
|
#
|
243
265
|
# Example:
|
@@ -300,7 +322,7 @@ module ActionController
|
|
300
322
|
map_member_actions(map, resource)
|
301
323
|
|
302
324
|
if block_given?
|
303
|
-
with_options(:path_prefix => resource.nesting_path_prefix, &block)
|
325
|
+
with_options(:path_prefix => resource.nesting_path_prefix, :new_name_prefix => resource.nesting_name_prefix, &block)
|
304
326
|
end
|
305
327
|
end
|
306
328
|
end
|
@@ -315,7 +337,7 @@ module ActionController
|
|
315
337
|
map_member_actions(map, resource)
|
316
338
|
|
317
339
|
if block_given?
|
318
|
-
with_options(:path_prefix => resource.nesting_path_prefix, &block)
|
340
|
+
with_options(:path_prefix => resource.nesting_path_prefix, :new_name_prefix => resource.nesting_name_prefix, &block)
|
319
341
|
end
|
320
342
|
end
|
321
343
|
end
|
@@ -324,8 +346,21 @@ module ActionController
|
|
324
346
|
resource.collection_methods.each do |method, actions|
|
325
347
|
actions.each do |action|
|
326
348
|
action_options = action_options_for(action, resource, method)
|
327
|
-
|
328
|
-
|
349
|
+
|
350
|
+
unless resource.old_name_prefix.blank?
|
351
|
+
map.deprecated_named_route("#{action}_#{resource.name_prefix}#{resource.plural}", "#{resource.old_name_prefix}#{action}_#{resource.plural}")
|
352
|
+
map.deprecated_named_route("formatted_#{action}_#{resource.name_prefix}#{resource.plural}", "formatted_#{resource.old_name_prefix}#{action}_#{resource.plural}")
|
353
|
+
end
|
354
|
+
|
355
|
+
if resource.deprecate_name_prefix?
|
356
|
+
map.deprecated_named_route("#{action}_#{resource.name_prefix}#{resource.plural}", "#{action}_#{resource.plural}")
|
357
|
+
map.deprecated_named_route("formatted_#{action}_#{resource.name_prefix}#{resource.plural}", "formatted_#{action}_#{resource.plural}")
|
358
|
+
end
|
359
|
+
|
360
|
+
map.named_route("#{action}_#{resource.name_prefix}#{resource.plural}", "#{resource.path}#{resource.action_separator}#{action}", action_options)
|
361
|
+
map.connect("#{resource.path};#{action}", action_options)
|
362
|
+
map.connect("#{resource.path}.:format;#{action}", action_options)
|
363
|
+
map.named_route("formatted_#{action}_#{resource.name_prefix}#{resource.plural}", "#{resource.path}#{resource.action_separator}#{action}.:format", action_options)
|
329
364
|
end
|
330
365
|
end
|
331
366
|
end
|
@@ -335,6 +370,11 @@ module ActionController
|
|
335
370
|
map.named_route("#{resource.name_prefix}#{resource.plural}", resource.path, index_action_options)
|
336
371
|
map.named_route("formatted_#{resource.name_prefix}#{resource.plural}", "#{resource.path}.:format", index_action_options)
|
337
372
|
|
373
|
+
if resource.deprecate_name_prefix?
|
374
|
+
map.deprecated_named_route("#{resource.name_prefix}#{resource.plural}", "#{resource.plural}")
|
375
|
+
map.deprecated_named_route("formatted_#{resource.name_prefix}#{resource.plural}", "formatted_#{resource.plural}")
|
376
|
+
end
|
377
|
+
|
338
378
|
create_action_options = action_options_for("create", resource)
|
339
379
|
map.connect(resource.path, create_action_options)
|
340
380
|
map.connect("#{resource.path}.:format", create_action_options)
|
@@ -351,11 +391,37 @@ module ActionController
|
|
351
391
|
actions.each do |action|
|
352
392
|
action_options = action_options_for(action, resource, method)
|
353
393
|
if action == :new
|
354
|
-
|
355
|
-
|
394
|
+
|
395
|
+
unless resource.old_name_prefix.blank?
|
396
|
+
map.deprecated_named_route("new_#{resource.name_prefix}#{resource.singular}", "#{resource.old_name_prefix}new_#{resource.singular}")
|
397
|
+
map.deprecated_named_route("formatted_new_#{resource.name_prefix}#{resource.singular}", "formatted_#{resource.old_name_prefix}new_#{resource.singular}")
|
398
|
+
end
|
399
|
+
|
400
|
+
if resource.deprecate_name_prefix?
|
401
|
+
map.deprecated_named_route("new_#{resource.name_prefix}#{resource.singular}", "new_#{resource.singular}")
|
402
|
+
map.deprecated_named_route("formatted_new_#{resource.name_prefix}#{resource.singular}", "formatted_new_#{resource.singular}")
|
403
|
+
end
|
404
|
+
|
405
|
+
map.named_route("new_#{resource.name_prefix}#{resource.singular}", resource.new_path, action_options)
|
406
|
+
map.named_route("formatted_new_#{resource.name_prefix}#{resource.singular}", "#{resource.new_path}.:format", action_options)
|
407
|
+
|
356
408
|
else
|
357
|
-
|
358
|
-
|
409
|
+
|
410
|
+
unless resource.old_name_prefix.blank?
|
411
|
+
map.deprecated_named_route("#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{resource.old_name_prefix}#{action}_new_#{resource.singular}")
|
412
|
+
map.deprecated_named_route("formatted_#{action}_new_#{resource.name_prefix}#{resource.singular}", "formatted_#{resource.old_name_prefix}#{action}_new_#{resource.singular}")
|
413
|
+
end
|
414
|
+
|
415
|
+
if resource.deprecate_name_prefix?
|
416
|
+
map.deprecated_named_route("#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{action}_new_#{resource.singular}")
|
417
|
+
map.deprecated_named_route("formatted_#{action}_new_#{resource.name_prefix}#{resource.singular}", "formatted_#{action}_new_#{resource.singular}")
|
418
|
+
end
|
419
|
+
|
420
|
+
map.named_route("#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{resource.new_path}#{resource.action_separator}#{action}", action_options)
|
421
|
+
map.connect("#{resource.new_path};#{action}", action_options)
|
422
|
+
map.connect("#{resource.new_path}.:format;#{action}", action_options)
|
423
|
+
map.named_route("formatted_#{action}_new_#{resource.name_prefix}#{resource.singular}", "#{resource.new_path}#{resource.action_separator}#{action}.:format", action_options)
|
424
|
+
|
359
425
|
end
|
360
426
|
end
|
361
427
|
end
|
@@ -365,8 +431,22 @@ module ActionController
|
|
365
431
|
resource.member_methods.each do |method, actions|
|
366
432
|
actions.each do |action|
|
367
433
|
action_options = action_options_for(action, resource, method)
|
368
|
-
|
369
|
-
|
434
|
+
|
435
|
+
unless resource.old_name_prefix.blank?
|
436
|
+
map.deprecated_named_route("#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.old_name_prefix}#{action}_#{resource.singular}")
|
437
|
+
map.deprecated_named_route("formatted_#{action}_#{resource.name_prefix}#{resource.singular}", "formatted_#{resource.old_name_prefix}#{action}_#{resource.singular}")
|
438
|
+
end
|
439
|
+
|
440
|
+
if resource.deprecate_name_prefix?
|
441
|
+
map.deprecated_named_route("#{action}_#{resource.name_prefix}#{resource.singular}", "#{action}_#{resource.singular}")
|
442
|
+
map.deprecated_named_route("formatted_#{action}_#{resource.name_prefix}#{resource.singular}", "formatted_#{action}_#{resource.singular}")
|
443
|
+
end
|
444
|
+
|
445
|
+
map.named_route("#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}#{resource.action_separator}#{action}", action_options)
|
446
|
+
map.connect("#{resource.member_path};#{action}", action_options)
|
447
|
+
map.connect("#{resource.member_path}.:format;#{action}", action_options)
|
448
|
+
map.named_route("formatted_#{action}_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}#{resource.action_separator}#{action}.:format", action_options)
|
449
|
+
|
370
450
|
end
|
371
451
|
end
|
372
452
|
|
@@ -374,6 +454,11 @@ module ActionController
|
|
374
454
|
map.named_route("#{resource.name_prefix}#{resource.singular}", resource.member_path, show_action_options)
|
375
455
|
map.named_route("formatted_#{resource.name_prefix}#{resource.singular}", "#{resource.member_path}.:format", show_action_options)
|
376
456
|
|
457
|
+
if resource.deprecate_name_prefix?
|
458
|
+
map.deprecated_named_route("#{resource.name_prefix}#{resource.singular}", "#{resource.singular}")
|
459
|
+
map.deprecated_named_route("formatted_#{resource.name_prefix}#{resource.singular}", "formatted_#{resource.singular}")
|
460
|
+
end
|
461
|
+
|
377
462
|
update_action_options = action_options_for("update", resource)
|
378
463
|
map.connect(resource.member_path, update_action_options)
|
379
464
|
map.connect("#{resource.member_path}.:format", update_action_options)
|
@@ -451,26 +451,17 @@ module ActionController
|
|
451
451
|
# is given (as an array), only the keys indicated will be used to build
|
452
452
|
# the query string. The query string will correctly build array parameter
|
453
453
|
# values.
|
454
|
-
def build_query_string(hash, only_keys=nil)
|
454
|
+
def build_query_string(hash, only_keys = nil)
|
455
455
|
elements = []
|
456
|
-
|
457
|
-
only_keys ||= hash.keys
|
458
|
-
|
459
|
-
only_keys.each do |key|
|
460
|
-
value = hash[key] or next
|
461
|
-
key = CGI.escape key.to_s
|
462
|
-
if value.class == Array
|
463
|
-
key << '[]'
|
464
|
-
else
|
465
|
-
value = [ value ]
|
466
|
-
end
|
467
|
-
value.each { |val| elements << "#{key}=#{CGI.escape(val.to_param.to_s)}" }
|
468
|
-
end
|
469
456
|
|
470
|
-
|
471
|
-
|
457
|
+
(only_keys || hash.keys).each do |key|
|
458
|
+
if value = hash[key]
|
459
|
+
elements << value.to_query(key)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
elements.empty? ? '' : "?#{elements.sort * '&'}"
|
472
463
|
end
|
473
|
-
|
464
|
+
|
474
465
|
# Write the real recognition implementation and then resend the message.
|
475
466
|
def recognize(path, environment={})
|
476
467
|
write_recognition
|
@@ -668,7 +659,7 @@ module ActionController
|
|
668
659
|
end
|
669
660
|
|
670
661
|
def extract_value
|
671
|
-
"#{local_name} = hash[:#{key}] #{"|| #{default.inspect}" if default}"
|
662
|
+
"#{local_name} = hash[:#{key}] && hash[:#{key}].to_param #{"|| #{default.inspect}" if default}"
|
672
663
|
end
|
673
664
|
def value_check
|
674
665
|
if default # Then we know it won't be nil
|
@@ -989,6 +980,10 @@ module ActionController
|
|
989
980
|
def named_route(name, path, options = {})
|
990
981
|
@set.add_named_route(name, path, options)
|
991
982
|
end
|
983
|
+
|
984
|
+
def deprecated_named_route(name, deprecated_name, options = {})
|
985
|
+
@set.add_deprecated_named_route(name, deprecated_name)
|
986
|
+
end
|
992
987
|
|
993
988
|
# Added deprecation notice for anyone who already added a named route called "root".
|
994
989
|
# It'll be used as a shortcut for map.connect '' in Rails 2.0.
|
@@ -1019,7 +1014,7 @@ module ActionController
|
|
1019
1014
|
def clear!
|
1020
1015
|
@routes = {}
|
1021
1016
|
@helpers = []
|
1022
|
-
|
1017
|
+
|
1023
1018
|
@module ||= Module.new
|
1024
1019
|
@module.instance_methods.each do |selector|
|
1025
1020
|
@module.send :remove_method, selector
|
@@ -1055,6 +1050,38 @@ module ActionController
|
|
1055
1050
|
def install(destinations = [ActionController::Base, ActionView::Base])
|
1056
1051
|
Array(destinations).each { |dest| dest.send :include, @module }
|
1057
1052
|
end
|
1053
|
+
|
1054
|
+
def define_deprecated_named_route_methods(name, deprecated_name)
|
1055
|
+
|
1056
|
+
[:url, :path].each do |kind|
|
1057
|
+
@module.send :module_eval, <<-end_eval # We use module_eval to avoid leaks
|
1058
|
+
|
1059
|
+
def #{url_helper_name(deprecated_name, kind)}(*args)
|
1060
|
+
|
1061
|
+
ActiveSupport::Deprecation.warn(
|
1062
|
+
'The named route "#{url_helper_name(deprecated_name, kind)}" uses a format that has been deprecated. ' +
|
1063
|
+
'You should use "#{url_helper_name(name, kind)}" instead.', caller
|
1064
|
+
)
|
1065
|
+
|
1066
|
+
send :#{url_helper_name(name, kind)}, *args
|
1067
|
+
|
1068
|
+
end
|
1069
|
+
|
1070
|
+
def #{hash_access_name(deprecated_name, kind)}(*args)
|
1071
|
+
|
1072
|
+
ActiveSupport::Deprecation.warn(
|
1073
|
+
'The named route "#{hash_access_name(deprecated_name, kind)}" uses a format that has been deprecated. ' +
|
1074
|
+
'You should use "#{hash_access_name(name, kind)}" instead.', caller
|
1075
|
+
)
|
1076
|
+
|
1077
|
+
send :#{hash_access_name(name, kind)}, *args
|
1078
|
+
|
1079
|
+
end
|
1080
|
+
|
1081
|
+
end_eval
|
1082
|
+
end
|
1083
|
+
|
1084
|
+
end
|
1058
1085
|
|
1059
1086
|
private
|
1060
1087
|
def url_helper_name(name, kind = :url)
|
@@ -1177,6 +1204,10 @@ module ActionController
|
|
1177
1204
|
def add_named_route(name, path, options = {})
|
1178
1205
|
named_routes[name] = add_route(path, options)
|
1179
1206
|
end
|
1207
|
+
|
1208
|
+
def add_deprecated_named_route(name, deprecated_name)
|
1209
|
+
named_routes.define_deprecated_named_route_methods(name, deprecated_name)
|
1210
|
+
end
|
1180
1211
|
|
1181
1212
|
def options_as_params(options)
|
1182
1213
|
# If an explicit :controller was given, always make :action explicit
|
@@ -1190,10 +1221,9 @@ module ActionController
|
|
1190
1221
|
#
|
1191
1222
|
# great fun, eh?
|
1192
1223
|
|
1193
|
-
options_as_params = options
|
1194
|
-
|
1195
|
-
|
1196
|
-
end
|
1224
|
+
options_as_params = options.clone
|
1225
|
+
options_as_params[:action] ||= 'index' if options[:controller]
|
1226
|
+
options_as_params[:action] = options_as_params[:action].to_s if options_as_params[:action]
|
1197
1227
|
options_as_params
|
1198
1228
|
end
|
1199
1229
|
|
@@ -1224,6 +1254,9 @@ module ActionController
|
|
1224
1254
|
options = options_as_params(options)
|
1225
1255
|
expire_on = build_expiry(options, recall)
|
1226
1256
|
|
1257
|
+
if options[:controller]
|
1258
|
+
options[:controller] = options[:controller].to_s
|
1259
|
+
end
|
1227
1260
|
# if the controller has changed, make sure it changes relative to the
|
1228
1261
|
# current controller module, if any. In other words, if we're currently
|
1229
1262
|
# on admin/get, and the new controller is 'set', the new controller
|