1 Here is a patch that makes [[ikiwiki-calendar]] almost useless.
3 It adds some options, the main one being `calendar_autocreate`, which is
4 similar to the `tag_autocreate` option of the [[tag|plugins/tag]]: it create
5 archive pages when needed.
7 The documentation is updated as well (but as a non-native English speaker, I
8 won't be offended if you correct stuff you consider awkward):
10 - [[plugin|https://github.com/paternal/ikiwiki/blob/calendar-autocreate/doc/plugins/calendar.mdwn]]
11 - [[directive|https://github.com/paternal/ikiwiki/blob/calendar-autocreate/doc/ikiwiki/directive/calendar.mdwn]]
14 [[!template id=gitbranch branch=spalax/calendar-autocreate browse="https://github.com/paternal/ikiwiki/tree/calendar-autocreate" author="[[Louis|spalax]]"]]
18 > An attempt at a review (although note that I don't have commit access,
19 > so my opinion is not final):
21 > Should `calendar_autocreate_commit` really default to 1? I would personally
22 > expect that any new features that synthesize new pages should not commit
23 > them by default - I'd prefer to avoid cluttering git history with generated
24 > pages. (Indeed, should the option even exist?)
26 > I'd personally do the conditional in gencalendaryear more like:
29 return unless $config{calendar_autocreate};
32 > to reduce the indentation depth of the more interesting code.
34 > The recursion to generate missing years:
37 if (not exists $wikistate{calendar}{minyear}) {
38 $wikistate{calendar}{minyear} = $year;
39 } elsif ($wikistate{calendar}{minyear} > $year) {
40 gencalendaryear($year + 1);
41 $wikistate{calendar}{minyear} -= 1;
45 > does seem to be correct on closer examination, but it took me a while
46 > to work out that it would actually do the right thing by recursing:
49 > * recurse to generate 2006
50 > * recurse to generate 2007
51 > * recurse to generate 2008
52 > * recurse to generate 2009
53 > * recurse to try to generate 2010 (no effect)
54 > * minyear = minyear - 1 = 2010 - 1 = 2009
55 > * minyear = minyear - 1 = 2009 - 1 = 2008
56 > * minyear = minyear - 1 = 2008 - 1 = 2007
57 > * minyear = minyear - 1 = 2007 - 1 = 2006
58 > * minyear = minyear - 1 = 2006 - 1 = 2005
60 > I think it might be clearer (as well as less
61 > recursion-happy) to use iteration:
64 > * recurse to generate 2006
66 > * recurse to generate 2009
69 > something like this:
78 # Filling potential gaps in years [...] years 2006 to 2009.
79 return if $params{norecurse};
80 if (not exists $wikistate{calendar}{minyear}) {
81 $wikistate{calendar}{minyear} = $year;
82 } elsif ($wikistate{calendar}{minyear} > $year) {
83 foreach my $other ($year + 1 .. $wikistate{calendar}{minyear} - 1) {
84 gencalendar($year, norecurse => 1);
86 $wikistate{calendar}{minyear} = $year;
88 # ... and the opposite for maxyear
92 > I'm not sure about generating missing years at all, though: if the
93 > generation is entirely dynamic, and there were no posts at all during
94 > a particular year (or month for that matter), shouldn't we just skip
95 > the year/month? That seems to be what e.g. Wordpress does.
97 > This piece of ikiwiki-calendar functionality is lost:
100 - ... It also refreshes the wiki, updating the calendars to
101 -highlight the current day. This command is typically run at midnight from
105 > If I understand correctly, the highlight will be on the day at which
106 > the wiki was last refreshed, which seems arbitrary and confusing.
107 > If ikiwiki-calendar is not used, I'd say there should just not be a
108 > highlight for today (although I'm not sure how best to implement that -
109 > perhaps a config option representing "I am going to use ikiwiki-calendar").
112 -\[[!template id=plugin name=calendar author="\[[ManojSrivastava]]"]]
113 -\[[!tag type/widget]]
116 > Why did you remove that? It's useful information about the plugin
117 > which I think ought to stay.