Permalink
Browse files

move url methods and tags to path

this paves the way to deprecate current implementations and change behaviors:
for example the <r:url /> will be able to print the URL including domain.
  • Loading branch information...
1 parent f211d2b commit cf3d0330a05b0fa6d1e0f4e5efcb29477da15a19 @saturnflyer saturnflyer committed Oct 24, 2010
Showing with 173 additions and 163 deletions.
  1. +1 −0 CHANGELOG
  2. +21 −16 app/models/page.rb
  3. +66 −62 app/models/standard_tags.rb
  4. +85 −85 spec/models/standard_tags_spec.rb
View
@@ -2,6 +2,7 @@
=== Edge
+* Move url methods to path [Jim Gay]
* Allow use of custom TextFilter names[Petrik de Heus]
* Set autocomplete="off" for password fields [Gert Goet]
* Allow loading of database templates from extensions [Jim Gay]
View
@@ -63,9 +63,10 @@ def cache?
true
end
- def child_url(child)
- clean_url(url + '/' + child.slug)
+ def child_path(child)
+ clean_path(path + '/' + child.slug)
end
+ alias_method :child_url, :child_path
def headers
# Return a blank hash that child classes can override or merge
@@ -116,13 +117,14 @@ def status=(value)
self.status_id = value.id
end
- def url
+ def path
if parent?
- parent.child_url(self)
+ parent.child_path(self)
else
- clean_url(slug)
+ clean_path(slug)
end
end
+ alias_method :url, :path
def process(request, response)
@request, @response = request, response
@@ -160,20 +162,20 @@ def render_snippet(snippet)
parse_object(snippet)
end
- def find_by_url(url, live = true, clean = true)
+ def find_by_path(path, live = true, clean = true)
return nil if virtual?
- url = clean_url(url) if clean
- my_url = self.url
- if (my_url == url) && (not live or published?)
+ path = clean_path(path) if clean
+ my_path = self.path
+ if (my_path == path) && (not live or published?)
self
- elsif (url =~ /^#{Regexp.quote(my_url)}([^\/]*)/)
+ elsif (path =~ /^#{Regexp.quote(my_path)}([^\/]*)/)
slug_child = children.find_by_slug($1)
if slug_child
- found = slug_child.find_by_url(url, live, clean)
+ found = slug_child.find_by_path(path, live, clean)
return found if found
end
children.each do |child|
- found = child.find_by_url(url, live, clean)
+ found = child.find_by_path(path, live, clean)
return found if found
end
file_not_found_types = ([FileNotFoundPage] + FileNotFoundPage.descendants)
@@ -183,6 +185,7 @@ def find_by_url(url, live = true, clean = true)
children.find(:first, :conditions => [condition] + file_not_found_names)
end
end
+ alias_method :find_by_url, :find_by_path
def update_status
self.published_at = Time.zone.now if published? && self.published_at == nil
@@ -204,11 +207,12 @@ class << self
alias_method :in_menu?, :in_menu
alias_method :in_menu, :in_menu=
- def find_by_url(url, live = true)
+ def find_by_path(path, live = true)
root = find_by_parent_id(nil)
raise MissingRootPageError unless root
- root.find_by_url(url, live)
+ root.find_by_path(path, live)
end
+ alias_method :find_by_url, :find_by_path
def display_name(string = nil)
if string
@@ -310,9 +314,10 @@ def update_virtual
true
end
- def clean_url(url)
- "/#{ url.strip }/".gsub(%r{//+}, '/')
+ def clean_path(path)
+ "/#{ path.strip }/".gsub(%r{//+}, '/')
end
+ alias_method :clean_url, :clean_path
def parent?
!parent.nil?
Oops, something went wrong.

1 comment on commit cf3d033

@protoror

not work correct <r:url /> in block <r:navigation>
change <r:url /> to <r:path /> solved problem

Please sign in to comment.