]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/calendar_autocreate.mdwn
I keep getting this tag wrong
[ikiwiki.git] / doc / todo / calendar_autocreate.mdwn
1 Here is a patch that makes [[ikiwiki-calendar]] almost useless.
2
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.
6
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):
9
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]]
12
13 [[!tag patch]]
14 [[!template  id=gitbranch branch=spalax/calendar-autocreate browse="https://github.com/paternal/ikiwiki/tree/calendar-autocreate" author="[[Louis|spalax]]"]]
15
16 --[[Louis|spalax]]
17
18 > An attempt at a review (although note that I don't have commit access,
19 > so my opinion is not final):
20 >
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?)
25 >
26 > I'd personally do the conditional in gencalendaryear more like:
27 >
28 > [[!format perl """
29 return unless $config{calendar_autocreate};
30 """]]
31 >
32 > to reduce the indentation depth of the more interesting code.
33 >
34 > The recursion to generate missing years:
35 >
36 > [[!format perl """
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;
42 }
43 """]]
44 >
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:
47 >
48 > * generate 2005
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
59 >
60 > I think it might be clearer (as well as less
61 > recursion-happy) to use iteration:
62 >
63 > * generate 2005
64 >   * recurse to generate 2006
65 >   * ...
66 >   * recurse to generate 2009
67 > * minyear = 2005
68 >
69 > something like this:
70 >
71 > [[!format perl """
72 sub gencalendaryear {
73         my $year = shift;
74         my %params = @_;
75         ...
76         # generate this year
77         ...
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);
85                 }
86                 $wikistate{calendar}{minyear} = $year;
87         }
88         # ... and the opposite for maxyear
89 }
90 """]]
91 >
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.
96 >
97 > This piece of ikiwiki-calendar functionality is lost:
98 >
99 > [[!format diff """
100 - ... It also refreshes the wiki, updating the calendars to
101 -highlight the current day. This command is typically run at midnight from
102 -cron.
103 """]]
104 >
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").
110 >
111 > [[!format diff """
112 -\[[!template id=plugin name=calendar author="\[[ManojSrivastava]]"]]
113 -\[[!tag type/widget]]
114 """]]
115 >
116 > Why did you remove that? It's useful information about the plugin
117 > which I think ought to stay.
118 >
119 > --[[smcv]]