]> sipb.mit.edu Git - ikiwiki.git/blob - doc/forum/Calendar:_listing_multiple_entries_per_day/comment_5_de545ebb6376066674ef2aaae4757b9c._comment
ikiwiki (3.20140916) unstable; urgency=low
[ikiwiki.git] / doc / forum / Calendar:_listing_multiple_entries_per_day / comment_5_de545ebb6376066674ef2aaae4757b9c._comment
1 [[!comment format=mdwn
2  username="spalax"
3  subject="Popup listing multiple entries per day"
4  date="2012-06-08T00:56:06Z"
5  content="""
6 [[!tag patch]]
7
8 Hello,
9 here is a patch that:
10
11 - if there is a single entry in one day, does not change anything (compared to the previous version of the calendar plugin);
12 - if there are several entries, when mouse passes over the day, displays a popup listing all the entries of that day.
13
14 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.
15
16 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.
17
18 Regards,    
19 -- Louis
20
21
22     diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm
23     index d443198..2c9ed79 100644
24     --- a/IkiWiki/Plugin/calendar.pm
25     +++ b/IkiWiki/Plugin/calendar.pm
26     @@ -86,8 +86,11 @@ sub format_month (@) {
27                 my $year  = $date[5] + 1900;
28                 my $mtag  = sprintf(\"%02d\", $month);
29      
30     -           # Only one posting per day is being linked to.
31     -           $linkcache{\"$year/$mtag/$mday\"} = $p;
32     +           # Several postings per day
33     +           if (! $linkcache{\"$year/$mtag/$mday\"}) {
34     +                   $linkcache{\"$year/$mtag/$mday\"} = [];
35     +           }
36     +           push(@{$linkcache{\"$year/$mtag/$mday\"}}, $p);
37         }
38                 
39         my $pmonth = $params{month} - 1;
40     @@ -221,11 +224,36 @@ EOF
41                                 $tag='month-calendar-day-link';
42                         }
43                         $calendar.=qq{\t\t<td class=\"$tag $downame{$wday}\">};
44     -                   $calendar.=htmllink($params{page}, $params{destpage}, 
45     -                           $linkcache{$key},
46     -                           noimageinline => 1,
47     -                           linktext => $day,
48     -                           title => pagetitle(IkiWiki::basename($linkcache{$key})));
49     +                   if ( scalar(@{$linkcache{$key}}) == 1) {
50     +                           # Only one posting on this page
51     +                           my $page = $linkcache{$key}[0];
52     +                           $calendar.=htmllink($params{page}, $params{destpage}, 
53     +                                   $page,
54     +                                   noimageinline => 1,
55     +                                   linktext => $day,
56     +                                   title => pagetitle(IkiWiki::basename($page)));
57     +                   } else {
58     +                           $calendar.=qq{<div class='popup'>$day<div class='balloon'>};
59     +                           # Several postings on this page
60     +                           $calendar.=qq{<ul>};
61     +                           foreach my $page (@{$linkcache{$key}}) {
62     +                                   $calendar.= qq{\n\t\t\t<li>};
63     +                                   my $title;
64     +                                   if (exists $pagestate{$page}{meta}{title}) {
65     +                                           $title = \"$pagestate{$page}{meta}{title}\";
66     +                                   } else {
67     +                                           $title = pagetitle(IkiWiki::basename($page));
68     +                                   }
69     +                                   $calendar.=htmllink($params{page}, $params{destpage}, 
70     +                                           $page,
71     +                                           noimageinline => 1,
72     +                                           linktext => $title,
73     +                                           title => $title);
74     +                                   $calendar.= '</li>';
75     +                           }
76     +                           $calendar.=qq{\n\t\t</ul>};
77     +                           $calendar.=qq{</div></div>};
78     +                   }
79                         $calendar.=qq{</td>\n};
80                 }
81                 else {
82     diff --git a/doc/style.css b/doc/style.css
83     old mode 100644
84     new mode 100755
85     index 6e2afce..4149229
86     --- a/doc/style.css
87     +++ b/doc/style.css
88     @@ -316,6 +316,7 @@ div.progress-done {
89      .popup .paren,
90      .popup .expand {
91         display: none;
92     +   text-align: left;
93      }
94      .popup:hover .balloon,
95      .popup:focus .balloon {
96
97 """]]