Sha256: 5f9518ed4a279885c01a3702f146d25a0435f9aee7545b5faf894500f586e8cc
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
require_dependency 'archive_finder' class ArchiveBehavior < Behavior::Base register "Archive" description %{ The Archive behavior causes a page and its children to behave in a fashion similar to a blog archive or a news archive. Child URLs are altered to be in %Y/%m/%d format (2004/05/06). If you would like to have custom index pages for the year, month, or day, use the "Archive Year Index", "Archive Month Index", and "Archive Day Index" behaviors respectively for three separate child pages. } def child_url(child) date = child.published_at || Time.now clean_url "#{ page_url }/#{ date.strftime '%Y/%m/%d' }/#{ child.slug }" end def find_page_by_url(url, live = true, clean = false) url = clean_url(url) if clean if url =~ %r{^#{ page.url }(\d{4})(?:/(\d{2})(?:/(\d{2}))?)?/?$} year, month, day = $1, $2, $3 @page.children.find_by_behavior_id( case when day 'Archive Day Index' when month 'Archive Month Index' else 'Archive Year Index' end ) else super end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
radiant-0.5.0 | app/behaviors/archive_behavior.rb |
radiant-0.5.1 | app/behaviors/archive_behavior.rb |
radiant-0.5.2 | app/behaviors/archive_behavior.rb |