GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Renamed anchor to fragment along with some minor tweeks to follow rfc2396 
better.
Lori Holden (author)
Mon Sep 01 22:29:33 -0700 2008
commit  02b3f1f228450beb944149b9650a123dbc5a0e06
tree    bd33c87743c458b4ce68bcd659792d4b9ea72412
parent  7b73934210b3ea614f6657787ac4ba61c83c338d
...
169
170
171
172
 
173
174
175
...
188
189
190
191
192
193
194
195
196
 
 
 
197
198
199
...
169
170
171
 
172
173
174
175
...
188
189
190
 
 
 
191
192
193
194
195
196
197
198
199
0
@@ -169,7 +169,7 @@ module Merb
0
       # String:: The generated URL.
0
       def generate_for_default_route(params, fallback)
0
         query_params = params.reject do |k,v|
0
- [:controller, :action, :id, :format, :anchor].include?(k.to_sym)
0
+ [:controller, :action, :id, :format, :fragment].include?(k.to_sym)
0
         end
0
 
0
         controller = params[:controller] || fallback[:controller]
0
@@ -188,12 +188,12 @@ module Merb
0
           format = fallback[:format] if format == :current
0
           url += ".#{format}"
0
         end
0
- if params[:anchor]
0
- url += "##{params[:anchor]}"
0
- end
0
         unless query_params.empty?
0
           url += "?" + Merb::Request.params_to_query_string(query_params)
0
         end
0
+ if params[:fragment]
0
+ url += "##{params[:fragment]}"
0
+ end
0
         url
0
       end
0
     end # self
...
258
259
260
261
262
 
 
263
264
265
266
 
 
 
267
268
269
...
258
259
260
 
 
261
262
263
264
265
266
267
268
269
270
271
272
0
@@ -258,12 +258,15 @@ module Merb
0
           format = fallback[:format] if format == :current
0
           url += ".#{format}"
0
         end
0
- if query_params && anchor = query_params.delete(:anchor)
0
- url += "##{anchor}"
0
+ if query_params
0
+ fragment = query_params.delete(:fragment)
0
         end
0
         if query_params && !query_params.empty?
0
           url += "?" + Merb::Request.params_to_query_string(query_params)
0
         end
0
+ if fragment
0
+ url += "##{fragment}"
0
+ end
0
         url
0
       end
0
 
...
308
309
310
311
312
 
 
313
314
315
...
308
309
310
 
 
311
312
313
314
315
0
@@ -308,8 +308,8 @@ describe Merb::Router::Route, "#generate" do
0
     @non_regexp_route.generate({ :name => stub('US', :to_param => 'USA') }).should == "/world/countries/USA"
0
   end
0
   
0
- it "adds anchor before ?" do
0
- @non_regexp_route.generate({:name => 101, :area => 10101, :anchor => :an_anchor}).should == "/world/countries/101#an_anchor?area=10101"
0
+ it "adds fragment after ?" do
0
+ @non_regexp_route.generate({:name => 101, :area => 10101, :fragment => :a_fragment}).should == "/world/countries/101?area=10101#a_fragment"
0
   end
0
 end
0
 
...
137
138
139
140
141
 
 
142
143
144
...
159
160
161
162
163
 
 
164
165
166
...
137
138
139
 
 
140
141
142
143
144
...
159
160
161
 
 
162
163
164
165
166
0
@@ -137,8 +137,8 @@ describe Merb::Router, ".generate", "given a Hash" do
0
     Merb::Router.generate({ :controller => "elements", :action => "show", :id => "fire", :format => :json }).should == "/elements/show/fire.json"
0
   end
0
   
0
- it "respects anchor parameter" do
0
- Merb::Router.generate({ :controller => "elements", :action => "search", :anchor => :an_anchor }, { :q => "water" }).should == "/elements/search#an_anchor?q=water"
0
+ it "respects fragment parameter" do
0
+ Merb::Router.generate({ :controller => "elements", :action => "search", :fragment => :a_fragment }, { :q => "water" }).should == "/elements/search?q=water#a_fragment"
0
   end
0
 end
0
 
0
@@ -159,8 +159,8 @@ describe Merb::Router, ".generate_for_default_route", "given a Hash" do
0
     Merb::Router.generate({ :controller => "elements", :action => "show", :id => "fire", :format => :json }).should == "/elements/show/fire.json"
0
   end
0
   
0
- it "respects anchor parameter" do
0
- Merb::Router.generate({ :controller => "elements", :action => "show", :id => "fire", :format => :json, :anchor => :an_anchor }).should == "/elements/show/fire.json#an_anchor"
0
+ it "respects fragment parameter" do
0
+ Merb::Router.generate({ :controller => "elements", :action => "show", :id => "fire", :format => :json, :fragment => :a_fragment }).should == "/elements/show/fire.json#a_fragment"
0
   end
0
 
0
   it "requires both parameters to be present" do

Comments

    No one has commented yet.