| CODENOTIFIER | HelpYou are not signed inSign in |
Project: reststop
Revision: 56
Author: gunark
Date: 17 Jun 2008 17:01:19
Changes: * `R` helper method should now work properly when a Restful object is fed as
input along with a custom action. The final argument can be a Hash and
will be translated into URL parameters. For example:
R(Kittens, 'list', 'colour' => 'black')
| ... | ...@@ -1 +1,33 @@ | |
| 0 | See CHANGELOG.txt | |
| 1 | 0 | \ No newline at end of file |
| 1 | === 0.3.0 :: In Progress... | |
| 2 | ||
| 3 | * Restr has been moved out to its own gem, and should now work properly with | |
| 4 | Rails 2.x (fixes bug #17421). | |
| 5 | * `R` helper method should now work properly when a Restful object is fed as | |
| 6 | input along with a custom action. The final argument can be a Hash and | |
| 7 | will be translated into URL parameters. For example: | |
| 8 | R(Kittens, 'list', 'colour' => 'black') | |
| 9 | ||
| 10 | === 0.2.0 :: 2007-12-10 | |
| 11 | ||
| 12 | * It is now possible to specify the format for rendering a page by appending | |
| 13 | it as a filename extension to the URL. For example: '/items.xml' to use the XML | |
| 14 | view module, or '/items/5.rss' to use the RSS module. | |
| 15 | * Custom actions are now possible. Custom methods defined in your controller will | |
| 16 | respond to the standard custom-action URLs. For example, if you have a method | |
| 17 | 'foo' in your 'kittens' controller, you can get to it by requesting the URL | |
| 18 | '/kittens/foo' or '/kittens/1/foo'. Note that the action will respond to any | |
| 19 | HTTP method (post, get, put, delete). It is up to you to handle different | |
| 20 | request methods inside your action's definition. | |
| 21 | * XML input (from an ActiveResource client, for example) is now parsed into a | |
| 22 | nested Hash, and is made available as the standard @input Camping variable. | |
| 23 | * HTML forms created using Markaby (i.e. by just using `form`) that | |
| 24 | have a :method parameter now automatically insert a hidden '_method' input to | |
| 25 | facilitate 'put' and 'delete' HTTP methods for HTML browsers. | |
| 26 | * Pages now correctly return HTTP status code 501 when an unimplemented controller | |
| 27 | method is called. ActiveRecord::NotFound exceptions are caught and return 404 | |
| 28 | status. | |
| 29 | * R helper now works for routing RESTful controllers. | |
| 30 | ||
| 31 | === 0.1.0 :: 2007-07-30 | |
| 32 | ||
| 33 | * First public release. | |
| 2 | 34 | \ No newline at end of file |
| ... | ...@@ -1,31 +1 @@ | |
| 0 | === 0.3.0 :: In Progress... | |
| 1 | ||
| 2 | * Restr has been moved out to its own gem, and should now work properly with | |
| 3 | Rails 2.x (fixes bug #17421). | |
| 4 | * `R` helper method should now work properly when a Restful object is fed as | |
| 5 | input along with a custom action. | |
| 6 | ||
| 7 | === 0.2.0 :: 2007-12-10 | |
| 8 | ||
| 9 | * It is now possible to specify the format for rendering a page by appending | |
| 10 | it as a filename extension to the URL. For example: '/items.xml' to use the XML | |
| 11 | view module, or '/items/5.rss' to use the RSS module. | |
| 12 | * Custom actions are now possible. Custom methods defined in your controller will | |
| 13 | respond to the standard custom-action URLs. For example, if you have a method | |
| 14 | 'foo' in your 'kittens' controller, you can get to it by requesting the URL | |
| 15 | '/kittens/foo' or '/kittens/1/foo'. Note that the action will respond to any | |
| 16 | HTTP method (post, get, put, delete). It is up to you to handle different | |
| 17 | request methods inside your action's definition. | |
| 18 | * XML input (from an ActiveResource client, for example) is now parsed into a | |
| 19 | nested Hash, and is made available as the standard @input Camping variable. | |
| 20 | * HTML forms created using Markaby (i.e. by just using `form`) that | |
| 21 | have a :method parameter now automatically insert a hidden '_method' input to | |
| 22 | facilitate 'put' and 'delete' HTTP methods for HTML browsers. | |
| 23 | * Pages now correctly return HTTP status code 501 when an unimplemented controller | |
| 24 | method is called. ActiveRecord::NotFound exceptions are caught and return 404 | |
| 25 | status. | |
| 26 | * R helper now works for routing RESTful controllers. | |
| 27 | ||
| 28 | === 0.1.0 :: 2007-07-30 | |
| 29 | ||
| 30 | * First public release. | |
| 31 | 0 | \ No newline at end of file |
| 1 | See History.txt | |
| 32 | 2 | \ No newline at end of file |
| ... | ...@@ -403,6 +403,7 @@ | |
| 403 | 403 | # R(Kittens, 1, 'meow') # /kittens/1/meow |
| 404 | 404 | # R(@kitten) # /kittens/1 |
| 405 | 405 | # R(@kitten, 'meow') # /kittens/1/meow |
| 406 | # R(Kittens, 'list', :colour => 'black') # /kittens/list?colour=black | |
| 406 | 407 | # |
| 407 | 408 | # The current output format is retained, so if the current <tt>@format</tt> is <tt>:XML</tt>, |
| 408 | 409 | # the URL will be /kittens/1.xml rather than /kittens/1. |
| ... | ...@@ -415,17 +416,21 @@ | |
| 415 | 416 | path = "/#{cl.underscore}/#{c.id}" |
| 416 | 417 | path << ".#{@format.to_s.downcase}" if @format |
| 417 | 418 | path << "/#{g.shift}" unless g.empty? |
| 418 | # FIXME: undefined behaviour if there are multiple arguments left... maybe we should allow for arbitrary params as a Hash? | |
| 419 | 419 | self / path |
| 420 | 420 | elsif c.respond_to?(:restful?) && c.restful? |
| 421 | 421 | base = c.name.split("::").last.underscore |
| 422 | id = g.shift | |
| 423 | action = g.shift | |
| 422 | id_or_action = g.shift | |
| 423 | if id_or_action =~ /\d+/ | |
| 424 | id = id_or_action | |
| 425 | action = g.shift | |
| 426 | else | |
| 427 | action = id_or_action | |
| 428 | end | |
| 424 | 429 | path = "/#{base}" |
| 425 | 430 | path << "/#{id}" if id |
| 426 | 431 | path << "/#{action}" if action |
| 427 | 432 | path << ".#{@format.to_s.downcase}" if @format |
| 428 | path << "?#{g}" unless g.empty? # FIXME: undefined behaviour if there are multiple arguments left | |
| 433 | path << "?#{g.collect{|a|a.collect{|k,v| C.escape(k)+"="+C.escape(v)}.join("&")}.join("&")}" unless g.empty? # FIXME: undefined behaviour if there are multiple arguments left | |
| 429 | 434 | self / path |
| 430 | 435 | else |
| 431 | 436 | _R(c, *g) |