]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/todo/Calendar:_listing_multiple_entries_per_day_.mdwn
poll vote (Accept only OpenID for logins)
[git.ikiwiki.info.git] / doc / todo / Calendar:_listing_multiple_entries_per_day_.mdwn
1 [[!tag patch]]
3 I am copying stuff discussed in the [[forum|/forum/Calendar:_listing_multiple_entries_per_day]], since the [[patch]] only list pages that are todo or bugs.
5 If there are several pages created on the same date, the [[calendar directive|/ikiwiki/directive/calendar]] only display the first one.
6 Here is a patch that:
8 - if there is a single entry in one day, does not change anything (compared to the previous version of the calendar plugin);
9 - if there are several entries, when mouse passes over the day, displays a popup listing all the entries of that day.
11 That's all. No new pages for each day, takes as little space as it took before, and only a few lines more in the source.
13 The only thing I am not totally happy with is the CSS. We have to say that the text is aligned on the left (otherwise, it is aligned on the right, as is each day of the calendar), but I do not know which place is the more sensible to put that line of CSS in.
15 Regards,    
16 -- Louis
19     diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm
20     index d443198..2c9ed79 100644
21     --- a/IkiWiki/Plugin/calendar.pm
22     +++ b/IkiWiki/Plugin/calendar.pm
23     @@ -86,8 +86,11 @@ sub format_month (@) {
24                 my $year  = $date[5] + 1900;
25                 my $mtag  = sprintf("%02d", $month);
26      
27     -           # Only one posting per day is being linked to.
28     -           $linkcache{"$year/$mtag/$mday"} = $p;
29     +           # Several postings per day
30     +           if (! $linkcache{"$year/$mtag/$mday"}) {
31     +                   $linkcache{"$year/$mtag/$mday"} = [];
32     +           }
33     +           push(@{$linkcache{"$year/$mtag/$mday"}}, $p);
34         }
35                 
36         my $pmonth = $params{month} - 1;
37     @@ -221,11 +224,36 @@ EOF
38                                 $tag='month-calendar-day-link';
39                         }
40                         $calendar.=qq{\t\t<td class="$tag $downame{$wday}">};
41     -                   $calendar.=htmllink($params{page}, $params{destpage}, 
42     -                           $linkcache{$key},
43     -                           noimageinline => 1,
44     -                           linktext => $day,
45     -                           title => pagetitle(IkiWiki::basename($linkcache{$key})));
46     +                   if ( scalar(@{$linkcache{$key}}) == 1) {
47     +                           # Only one posting on this page
48     +                           my $page = $linkcache{$key}[0];
49     +                           $calendar.=htmllink($params{page}, $params{destpage}, 
50     +                                   $page,
51     +                                   noimageinline => 1,
52     +                                   linktext => $day,
53     +                                   title => pagetitle(IkiWiki::basename($page)));
54     +                   } else {
55     +                           $calendar.=qq{<div class='popup'>$day<div class='balloon'>};
56     +                           # Several postings on this page
57     +                           $calendar.=qq{<ul>};
58     +                           foreach my $page (@{$linkcache{$key}}) {
59     +                                   $calendar.= qq{\n\t\t\t<li>};
60     +                                   my $title;
61     +                                   if (exists $pagestate{$page}{meta}{title}) {
62     +                                           $title = "$pagestate{$page}{meta}{title}";
63     +                                   } else {
64     +                                           $title = pagetitle(IkiWiki::basename($page));
65     +                                   }
66     +                                   $calendar.=htmllink($params{page}, $params{destpage}, 
67     +                                           $page,
68     +                                           noimageinline => 1,
69     +                                           linktext => $title,
70     +                                           title => $title);
71     +                                   $calendar.= '</li>';
72     +                           }
73     +                           $calendar.=qq{\n\t\t</ul>};
74     +                           $calendar.=qq{</div></div>};
75     +                   }
76                         $calendar.=qq{</td>\n};
77                 }
78                 else {
79     diff --git a/doc/style.css b/doc/style.css
80     old mode 100644
81     new mode 100755
82     index 424d438..b52c72b
83     --- a/doc/style.css
84     +++ b/doc/style.css
85     @@ -323,6 +323,7 @@ div.progress-done {
86      .popup .paren,
87      .popup .expand {
88         display: none;
89     +   text-align: left;
90      }
91      .popup:hover .balloon,
92      .popup:focus .balloon {
94 > [[applied|done]] --[[Joey]]