Renamed helpers to correspond to renamed Controller classes.
[merb_radiant.git] / radiant_extensions_plugins / extensions / archive / app / models / .svn / text-base / archive_page.rb.svn-base
blobd4d97550e8462379d23ed4c420769ab299e48041
1 class ArchivePage < Page
3   description %{
4     An archive page provides behavior similar to a blog archive or a news
5     archive. Child page URLs are altered to be in %Y/%m/%d format
6     (2004/05/06).
7     
8     An archive page can be used in conjunction with the "Archive Year Index",
9     "Archive Month Index", and "Archive Day Index" page types to create year,
10     month, and day indexes.
11   }
12   
13   def child_url(child)
14     date = child.published_at || Time.now
15     clean_url "#{ url }/#{ date.strftime '%Y/%m/%d' }/#{ child.slug }"
16   end
17   
18   def find_by_url(url, live = true, clean = false)
19     url = clean_url(url) if clean
20     if url =~ %r{^#{ self.url }(\d{4})(?:/(\d{2})(?:/(\d{2}))?)?/?$}
21       year, month, day = $1, $2, $3
22       children.find_by_class_name(
23         case
24         when day
25           'ArchiveDayIndexPage'
26         when month
27           'ArchiveMonthIndexPage'
28         else
29           'ArchiveYearIndexPage'
30         end
31       )
32     else
33       super
34     end
35   end
36 end