2 username="https://www.google.com/accounts/o8/id?id=AItOawnXybLxkPMYpP3yw4b_I6IdC3cKTD-xEdU"
5 date="2011-11-30T20:42:55Z"
7 I got to grip with things to make a patch to do this. :-)
9 Here it is in case of use to anyone.
12 From f0554c5b61e1915086d5cf071f095ff233c2590d Mon Sep 17 00:00:00 2001
13 From: Matt Ford <matt@dancingfrog.co.uk>
14 Date: Wed, 30 Nov 2011 19:40:10 +0000
15 Subject: [PATCH] Patch to allow daily archival generation and link to them in
19 IkiWiki/Plugin/calendar.pm | 17 ++++++++++++++++-
20 ikiwiki-calendar.in | 34 +++++++++++++++++++++++++++++++---
21 templates/calendarday.tmpl | 5 +++++
22 templates/calendarmonth.tmpl | 2 +-
23 templates/calendaryear.tmpl | 2 +-
24 5 files changed, 54 insertions(+), 6 deletions(-)
25 create mode 100644 templates/calendarday.tmpl
27 diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm
28 index c7d2b7c..9999c03 100644
29 --- a/IkiWiki/Plugin/calendar.pm
30 +++ b/IkiWiki/Plugin/calendar.pm
31 @@ -47,6 +47,13 @@ sub getsetup () {
36 + type => \"boolean\",
38 + description => \"enable archiving on a daily basis (otherwise monthly)\",
44 example => \"page(posts/*) and !*/Discussion\",
45 @@ -222,11 +229,19 @@ EOF
46 $tag='month-calendar-day-link';
48 $calendar.=qq{\t\t<td class=\"$tag $downame{$wday}\">};
49 - $calendar.=htmllink($params{page}, $params{destpage},
50 + if (exists $pagesources{\"$archivebase/$params{year}/$params{month}/\".sprintf(\"%02d\",$day)}) {
51 + $calendar.=htmllink($params{page}, $params{destpage},
52 + \"$archivebase/$params{year}/$params{month}/\".sprintf(\"%02d\",$day),
54 + linktext => \"$day\",
57 + $calendar.=htmllink($params{page}, $params{destpage},
61 title => pagetitle(IkiWiki::basename($linkcache{$key})));
63 $calendar.=qq{</td>\n};
66 diff --git a/ikiwiki-calendar.in b/ikiwiki-calendar.in
67 index 037ef7d..af22bc5 100755
68 --- a/ikiwiki-calendar.in
69 +++ b/ikiwiki-calendar.in
70 @@ -30,21 +30,44 @@ IkiWiki::checkconfig();
71 my $archivebase = 'archives';
72 $archivebase = $config{archivebase} if defined $config{archivebase};
75 +$archiveday = $config{archiveday} if defined $config{archiveday};
77 if (! defined $pagespec) {
78 $pagespec=$config{archive_pagespec} || \"*\";
81 -sub writearchive ($$;$) {
84 + return ($year % 4 == 0 && (($year % 100 != 0) || $year % 400 == 0));
90 + my $days_in_month = (31,28,31,30,31,30,31,31,30,31,30,31)[$month-1];
91 + if ($month == 2 && is_leap_year($year)) {
94 + return $days_in_month;
97 +sub writearchive ($$;$;$) {
98 my $template=template(shift);
103 - my $page=defined $month ? \"$year/$month\" : $year;
105 + if (defined $year) {$page = \"$year\"};
106 + if (defined $month) {$page = \"$year/$month\"};
107 + if (defined $day) {$page = \"$year/$month/$day\"};
109 my $pagefile=newpagefile(\"$archivebase/$page\", $config{default_pageext});
110 $template->param(pagespec => $pagespec);
111 $template->param(year => $year);
112 $template->param(month => $month) if defined $month;
113 + $template->param(day => $day) if defined $day;
115 if ($force || ! -e \"$config{srcdir}/$pagefile\") {
116 writefile($pagefile, $config{srcdir}, $template->output);
117 @@ -54,8 +77,13 @@ sub writearchive ($$;$) {
119 foreach my $y ($startyear..$endyear) {
120 writearchive(\"calendaryear.tmpl\", $y);
121 - foreach my $m (qw{01 02 03 04 05 06 07 08 09 10 11 12}) {
122 + foreach my $m (map {sprintf(\"%02d\",$_)} (1..12)) {
123 writearchive(\"calendarmonth.tmpl\", $y, $m);
124 + if ($archiveday ) {
125 + foreach my $d (map {sprintf(\"%02d\",$_)} (1..month_days($m,$y))) {
126 + writearchive(\"calendarday.tmpl\", $y, $m, $d);
132 diff --git a/templates/calendarday.tmpl b/templates/calendarday.tmpl
134 index 0000000..ac963b9
136 +++ b/templates/calendarday.tmpl
138 +[[!sidebar content=\"\"\"
139 +[[!calendar type=month month=<TMPL_VAR MONTH> year=<TMPL_VAR YEAR> pages=\"<TMPL_VAR PAGESPEC>\"]]
142 +[[!inline pages=\"creation_day(<TMPL_VAR DAY>) and creation_month(<TMPL_VAR MONTH>) and creation_year(<TMPL_VAR YEAR>) and <TMPL_VAR PAGESPEC>\" archive=\"yes\" show=0 feeds=no reverse=yes]]
143 diff --git a/templates/calendarmonth.tmpl b/templates/calendarmonth.tmpl
144 index 23cd954..c998c16 100644
145 --- a/templates/calendarmonth.tmpl
146 +++ b/templates/calendarmonth.tmpl
148 [[!calendar type=month month=<TMPL_VAR MONTH> year=<TMPL_VAR YEAR> pages=\"<TMPL_VAR PAGESPEC>\"]]
151 -[[!inline pages=\"creation_month(<TMPL_VAR MONTH>) and creation_year(<TMPL_VAR YEAR>) and <TMPL_VAR PAGESPEC>\" show=0 feeds=no reverse=yes]]
152 +[[!inline pages=\"creation_month(<TMPL_VAR MONTH>) and creation_year(<TMPL_VAR YEAR>) and <TMPL_VAR PAGESPEC>\" archive=\"yes\" show=0 feeds=no reverse=yes]]
153 diff --git a/templates/calendaryear.tmpl b/templates/calendaryear.tmpl
154 index 714bd6d..b6e33c5 100644
155 --- a/templates/calendaryear.tmpl
156 +++ b/templates/calendaryear.tmpl
158 -[[!calendar type=year year=<TMPL_VAR YEAR> pages=\"<TMPL_VAR PAGESPEC>\"]]
159 +[[!calendar type=year year=<TMPL_VAR YEAR> pages=\"<TMPL_VAR PAGESPEC>\" archive=\"yes\"]]