]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/calendar.pm
calendar: When there are multiple pages for a given day, they're displayed in a popup...
[ikiwiki.git] / IkiWiki / Plugin / calendar.pm
index fc497b3c7351ea2151bfb14092568dbb687c3eb2..8ca6dd82680171d8ebae5f88ac9053c327e0ad3d 100644 (file)
@@ -13,7 +13,7 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
 require 5.002;
 package IkiWiki::Plugin::calendar;
@@ -86,8 +86,10 @@ sub format_month (@) {
                my $year  = $date[5] + 1900;
                my $mtag  = sprintf("%02d", $month);
 
-               # Only one posting per day is being linked to.
-               $linkcache{"$year/$mtag/$mday"} = $p;
+               if (! $linkcache{"$year/$mtag/$mday"}) {
+                       $linkcache{"$year/$mtag/$mday"} = [];
+               }
+               push(@{$linkcache{"$year/$mtag/$mday"}}, $p);
        }
                
        my $pmonth = $params{month} - 1;
@@ -221,11 +223,38 @@ EOF
                                $tag='month-calendar-day-link';
                        }
                        $calendar.=qq{\t\t<td class="$tag $downame{$wday}">};
-                       $calendar.=htmllink($params{page}, $params{destpage}, 
-                               $linkcache{$key},
-                               noimageinline => 1,
-                               linktext => $day,
-                               title => pagetitle(IkiWiki::basename($linkcache{$key})));
+                       if (scalar(@{$linkcache{$key}}) == 1) {
+                               # Only one posting on this page
+                               my $page = $linkcache{$key}[0];
+                               $calendar.=htmllink($params{page}, $params{destpage}, 
+                                       $page,
+                                       noimageinline => 1,
+                                       linktext => $day,
+                                       title => pagetitle(IkiWiki::basename($page)));
+                       }
+                       else {
+                               $calendar.=qq{<div class='popup'>$day<div class='balloon'>};
+                               # Several postings on this page
+                               $calendar.=qq{<ul>};
+                               foreach my $page (@{$linkcache{$key}}) {
+                                       $calendar.= qq{\n\t\t\t<li>};
+                                       my $title;
+                                       if (exists $pagestate{$page}{meta}{title}) {
+                                               $title = "$pagestate{$page}{meta}{title}";
+                                       }
+                                       else {
+                                               $title = pagetitle(IkiWiki::basename($page));
+                                       }
+                                       $calendar.=htmllink($params{page}, $params{destpage}, 
+                                               $page,
+                                               noimageinline => 1,
+                                               linktext => $title,
+                                               title => $title);
+                                       $calendar.= '</li>';
+                               }
+                               $calendar.=qq{\n\t\t</ul>};
+                               $calendar.=qq{</div></div>};
+                       }
                        $calendar.=qq{</td>\n};
                }
                else {