@@ -33,6 +33,14 @@ def news_dir
33
33
end
34
34
end
35
35
36
+ def insert_date ( string , year , month = 0 )
37
+ string . gsub ( /%Y|%m|%B/ , {
38
+ '%Y' => year . to_s ,
39
+ '%m' => "%.2d" % month ,
40
+ '%B' => @month_names [ month ]
41
+ } )
42
+ end
43
+
36
44
end
37
45
38
46
class MonthlyArchive < ArchivePage
@@ -48,11 +56,7 @@ def initialize(site,base,lang,year,month,posts)
48
56
49
57
title = @locales [ 'monthly_archive_title' ]
50
58
51
- data [ 'title' ] = title . gsub ( /%Y|%m|%B/ , {
52
- '%Y' => @year . to_s ,
53
- '%m' => "%.2d" % @month ,
54
- '%B' => @month_names [ @month ]
55
- } )
59
+ data [ 'title' ] = insert_date ( title , @year , @month )
56
60
data [ 'year' ] = year
57
61
end
58
62
@@ -71,20 +75,15 @@ def initialize(site,base,lang,year,posts)
71
75
title = @locales [ 'yearly_archive_title' ]
72
76
month_link_text = @locales [ 'monthly_archive_link' ]
73
77
74
- data [ 'title' ] = title . gsub ( '%Y' , @year . to_s )
78
+ data [ 'title' ] = insert_date ( title , @year )
75
79
data [ 'year' ] = @year
76
80
77
81
months = posts . map { |post | post . date . month } . uniq
78
82
79
83
# hash with url => link_text (including year) elements
80
84
data [ 'months' ] = Hash [
81
85
months . map { |month | "%.2d" % month } . zip (
82
- months . map { |month | month_link_text . gsub ( /%Y|%m|%B/ , {
83
- '%Y' => @year . to_s ,
84
- '%m' => "%.2d" % month ,
85
- '%B' => @month_names [ month ]
86
- } )
87
- }
86
+ months . map { |month | insert_date ( month_link_text , @year , month ) }
88
87
)
89
88
]
90
89
end
@@ -111,7 +110,7 @@ def initialize(site,base,lang,posts)
111
110
# hash with url => link_text elements
112
111
data [ 'years' ] = Hash [
113
112
years . map { |year | year . to_s } . zip (
114
- years . map { |year | year_link_text . gsub ( /%Y/ , '%Y' => year . to_s ) }
113
+ years . map { |year | insert_date ( year_link_text , year ) }
115
114
)
116
115
]
117
116
end
0 commit comments