Sha256: b26d7a279c231eff145efaf64518bd02a63910e3b0cb24982badcaba030ae6ba

Contents?: true

Size: 1.19 KB

Versions: 30

Compression:

Stored size: 1.19 KB

Contents

module ArchiveIndexTagsAndMethods
  
  include Radiant::Taggable
  
  tag "archive" do |tag|
    tag.expand
  end
  
  tag "title" do |tag|
    setup_date_parts
    page = tag.locals.page
    unless @year.nil?
      Date.new((@year || 1).to_i, (@month || 1).to_i, (@day || 1).to_i).strftime(page.title)
    else
      page.title
    end
  end
  
  tag "archive:year" do |tag|
    setup_date_parts
    @year.to_i unless @year.nil?
  end
  
  tag "archive:month" do |tag|
    setup_date_parts
    Date.new(@year.to_i, @month.to_i, 1).strftime('%B') rescue ''
  end
  
  tag "archive:day" do |tag|
    setup_date_parts
    @day.to_i unless @day.nil?
  end
  
  tag "archive:day_of_week" do |tag|
    setup_date_parts
    Date.new(@year.to_i, @month.to_i, @day.to_i).strftime('%A') rescue ''
  end
  
  tag("archive:children:first") { "unimplemented" }
  tag("archive:children:last" ) { "unimplemented" }
  tag("archive:children:count") { "unimplemented" }
  
  def virtual?
    true
  end
  
  private
    
    def request_uri
      request.request_uri unless request.nil?
    end
    
    def setup_date_parts
      @year, @month, @day = $1, $2, $3 if request_uri =~ %r{/(\d{4})(?:/(\d{2})(?:/(\d{2}))?)?/?$}
    end
  
end

Version data entries

30 entries across 30 versions & 3 rubygems

Version Path
radiantcms-couchrest_model-0.2.4 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiantcms-couchrest_model-0.2.2 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiantcms-couchrest_model-0.2.1 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiantcms-couchrest_model-0.2 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiantcms-couchrest_model-0.1.9 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiantcms-couchrest_model-0.1.8 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiantcms-couchrest_model-0.1.7 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiantcms-couchrest_model-0.1.6 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiantcms-couchrest_model-0.1.5 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiantcms-couchrest_model-0.1.4 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiant-0.7.2 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiant-0.9.1 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiant-0.8.2 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiant-0.9.0.rc2 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiant-rc-0.9.0 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiant-0.8.1 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiant-0.6.0 lib/archive_index_tags_and_methods.rb
radiant-0.6.1 lib/archive_index_tags_and_methods.rb
radiant-0.6.3 lib/archive_index_tags_and_methods.rb
radiant-0.6.2 lib/archive_index_tags_and_methods.rb