aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspalax <spalax@web>2012-06-07 20:56:07 -0400
committeradmin <admin@branchable.com>2012-06-07 20:56:07 -0400
commit778e4f744542ac4fbd26c5f1af59a8c4ed7ef710 (patch)
tree458aa3094543b5ae99eeb198f4bef5f35ef0413f
parent8087b235994340dc15bddc17de553048361320ca (diff)
downloadikiwiki-778e4f744542ac4fbd26c5f1af59a8c4ed7ef710.tar
ikiwiki-778e4f744542ac4fbd26c5f1af59a8c4ed7ef710.tar.gz
Added a comment: Popup listing multiple entries per day
-rw-r--r--doc/forum/Calendar:_listing_multiple_entries_per_day/comment_5_de545ebb6376066674ef2aaae4757b9c._comment97
1 files changed, 97 insertions, 0 deletions
diff --git a/doc/forum/Calendar:_listing_multiple_entries_per_day/comment_5_de545ebb6376066674ef2aaae4757b9c._comment b/doc/forum/Calendar:_listing_multiple_entries_per_day/comment_5_de545ebb6376066674ef2aaae4757b9c._comment
new file mode 100644
index 000000000..fef852066
--- /dev/null
+++ b/doc/forum/Calendar:_listing_multiple_entries_per_day/comment_5_de545ebb6376066674ef2aaae4757b9c._comment
@@ -0,0 +1,97 @@
+[[!comment format=mdwn
+ username="spalax"
+ subject="Popup listing multiple entries per day"
+ date="2012-06-08T00:56:06Z"
+ content="""
+[[!tag patch]]
+
+Hello,
+here is a patch that:
+
+- if there is a single entry in one day, does not change anything (compared to the previous version of the calendar plugin);
+- if there are several entries, when mouse passes over the day, displays a popup listing all the entries of that day.
+
+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.
+
+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.
+
+Regards,
+-- Louis
+
+
+ diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm
+ index d443198..2c9ed79 100644
+ --- a/IkiWiki/Plugin/calendar.pm
+ +++ b/IkiWiki/Plugin/calendar.pm
+ @@ -86,8 +86,11 @@ 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;
+ + # Several postings per day
+ + if (! $linkcache{\"$year/$mtag/$mday\"}) {
+ + $linkcache{\"$year/$mtag/$mday\"} = [];
+ + }
+ + push(@{$linkcache{\"$year/$mtag/$mday\"}}, $p);
+ }
+
+ my $pmonth = $params{month} - 1;
+ @@ -221,11 +224,36 @@ 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 {
+ diff --git a/doc/style.css b/doc/style.css
+ old mode 100644
+ new mode 100755
+ index 6e2afce..4149229
+ --- a/doc/style.css
+ +++ b/doc/style.css
+ @@ -316,6 +316,7 @@ div.progress-done {
+ .popup .paren,
+ .popup .expand {
+ display: none;
+ + text-align: left;
+ }
+ .popup:hover .balloon,
+ .popup:focus .balloon {
+
+"""]]