Module: Archive::ArchivePageExtensions

Defined in:
lib/globalize2/compatibility/archive/archive_page_extensions.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/globalize2/compatibility/archive/archive_page_extensions.rb', line 3

def self.included(base)
  base.class_eval do
    def child_url(child)
      date = child.published_at || Time.now
    
      if ArchiveYearIndexPage === child
        clean_url "#{ url }/#{ date.strftime '%Y' }/"
      elsif ArchiveMonthIndexPage === child
        clean_url "#{ url }/#{ date.strftime '%Y/%m' }/"
      elsif ArchiveDayIndexPage === child
        clean_url "#{ url }/#{ date.strftime '%Y/%m/%d/' }/"
      else
        clean_url "#{ url }/#{ date.strftime '%Y/%m/%d' }/#{ child.slug }"
      end
    end
  end
end