Renamed helpers to correspond to renamed Controller classes.
[merb_radiant.git] / radiant_extensions_plugins / extensions / archive / lib / .svn / text-base / archive_index_tags_and_methods.rb.svn-base
blobe4e40429c44356c30ea44b1161e184db48a133d8
1 module ArchiveIndexTagsAndMethods
2   
3   include Radiant::Taggable
4   
5   tag "archive" do |tag|
6     tag.expand
7   end
8   
9   tag "title" do |tag|
10     setup_date_parts
11     page = tag.locals.page
12     unless @year.nil?
13       Date.new((@year || 1).to_i, (@month || 1).to_i, (@day || 1).to_i).strftime(page.title)
14     else
15       page.title
16     end
17   end
18   
19   tag "archive:year" do |tag|
20     setup_date_parts
21     @year.to_i unless @year.nil?
22   end
23   
24   tag "archive:month" do |tag|
25     setup_date_parts
26     Date.new(@year.to_i, @month.to_i, 1).strftime('%B') rescue ''
27   end
28   
29   tag "archive:day" do |tag|
30     setup_date_parts
31     @day.to_i unless @day.nil?
32   end
33   
34   tag "archive:day_of_week" do |tag|
35     setup_date_parts
36     Date.new(@year.to_i, @month.to_i, @day.to_i).strftime('%A') rescue ''
37   end
38   
39   tag("archive:children:first") { "unimplemented" }
40   tag("archive:children:last" ) { "unimplemented" }
41   tag("archive:children:count") { "unimplemented" }
42   
43   def virtual?
44     true
45   end
46   
47   private
48     
49     def request_uri
50       request.request_uri unless request.nil?
51     end
52     
53     def setup_date_parts
54       @year, @month, @day = $1, $2, $3 if request_uri =~ %r{/(\d{4})(?:/(\d{2})(?:/(\d{2}))?)?/?$}
55     end
56   
57 end