Sha256: ac8d8fbd61658681cd5d47a4cb2b4c88b56e9418d0ba6471dc7bba674b2b9439

Contents?: true

Size: 1.57 KB

Versions: 11

Compression:

Stored size: 1.57 KB

Contents

module ArchiveIndexTagsAndMethods
  
  include Radiant::Taggable
  
  desc %{
    Scope tags for an ArchivePage
  }
  tag "archive" do |tag|
    tag.expand
  end
  
  [:title, :breadcrumb].each do |method|
    tag method.to_s 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.send(method))
      else
        page.send(method)
      end
    end
  end
  
  desc %{
    Display the year for the current Archive
  }
  tag "archive:year" do |tag|
    setup_date_parts
    @year.to_i unless @year.nil?
  end
  

  desc %{
    Display the month for the current Archive
  }
  tag "archive:month" do |tag|
    setup_date_parts
    Date.new(@year.to_i, @month.to_i, 1).strftime('%B') rescue ''
  end
  

  desc %{
    Display the day for the current Archive
  }
  tag "archive:day" do |tag|
    setup_date_parts
    @day.to_i unless @day.nil?
  end
  

  desc %{
    Display the day of the week for the current Archive
  }
  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

11 entries across 11 versions & 2 rubygems

Version Path
radiant-1.0.0 ruby-debug/ruby/1.8/gems/radiant-archive-extension-1.0.7/lib/archive_index_tags_and_methods.rb
radiant-archive-extension-1.0.7 lib/archive_index_tags_and_methods.rb
radiant-archive-extension-1.0.6 lib/archive_index_tags_and_methods.rb
radiant-archive-extension-1.0.5 lib/archive_index_tags_and_methods.rb
radiant-archive-extension-1.0.4 lib/archive_index_tags_and_methods.rb
radiant-archive-extension-1.0.3 lib/archive_index_tags_and_methods.rb
radiant-archive-extension-1.0.2 lib/archive_index_tags_and_methods.rb
radiant-archive-extension-1.0.1 lib/archive_index_tags_and_methods.rb
radiant-archive-extension-1.0.0 lib/archive_index_tags_and_methods.rb
radiant-1.0.0.rc2 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb
radiant-1.0.0.rc1 vendor/extensions/archive/lib/archive_index_tags_and_methods.rb