Sha256: 03b79fc3e62fcad67926b88e263eca85e9fdccfe589f3998cb9adb8e6e623fb2

Contents?: true

Size: 907 Bytes

Versions: 3

Compression:

Stored size: 907 Bytes

Contents

require_dependency 'archive_finder'
require_dependency 'archive_index_behavior_tags_and_methods'

class ArchiveYearIndexBehavior < Behavior::Base
  
  register "Archive Year Index"
  
  description %{
    To create a year index for an archive, create a child page for the
    archive and apply the "Archive Year Index" behavior to it.
    
    The following tags are then made accessible to you:
    
    <r:archive:children>...</r:archive:children>
      Grants access to a subset of the children of the archive page
      that match the specific year which the index page is rendering.
  }
  
  include ArchiveIndexBehaviorTagsAndMethods
  
  define_tags do
    url = request.request_uri unless request.nil?
    tag "archive:children" do |tag|
      year = $1 if url =~ %r{/(\d{4})/?$}
      tag.locals.children = ArchiveFinder.year_finder(page.parent.children, year)
      tag.expand
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
radiant-0.5.0 app/behaviors/archive_year_index_behavior.rb
radiant-0.5.1 app/behaviors/archive_year_index_behavior.rb
radiant-0.5.2 app/behaviors/archive_year_index_behavior.rb