Permalink
Browse files

Fix archive page url

  • Loading branch information...
oriolgual committed Oct 6, 2010
1 parent 583667a commit 332a6faeafa834ea936d145a0e0fd0c700c87bcd
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/globalize2/compatibility/archive/archive_page_extensions.rb
@@ -3,8 +3,10 @@ module Archive::ArchivePageExtensions
def self.included(base)
base.class_eval do
def child_url(child)
- date = child.published_at || Time.now
-
+
+ @year, @month, @day = $1, ($2 || 1).to_i, ($3 || 1).to_i if child.request and child.request.request_uri =~ %r{/(\d{4})(?:/(\d{2})(?:/(\d{2}))?)?/?$}
+ date = (@year ? Date.new(@year.to_i, @month, @day) : (child.published_at || Time.now))
+
if ArchiveYearIndexPage === child
clean_url "#{ url }/#{ date.strftime '%Y' }/"
elsif ArchiveMonthIndexPage === child
@@ -18,4 +20,4 @@ def child_url(child)
end
end
end
-end
+end

0 comments on commit 332a6fa

Please sign in to comment.