My Calendar Plugin

Creating and modifying plugins.
Post Reply
Col. Kurtz
Regular
Posts: 450
Joined: Thu May 26, 2005 10:43 am
Location: Bonn, Germany
Contact:

My Calendar Plugin

Post by Col. Kurtz »

I really like the My Calendar Plugin, but I dont use it because the lines really dont look good if you dont have an very wide sidebar.

Image

Is there a way to display it like:

Date Titele (and/or link)
(Number of Days left)

and to highlight the dates?

like:

07.08. New Release of SX
(5 Days left)
09.08. Whatever
(7 Days left)

...

?

______________________
MARC
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: My Calendar Plugin

Post by garvinhicking »

Yes, I suggest to edit the plugin for that and change the PHP output.

I did not build the plugin with smarty template customization because it would be overkill for that to load the smarty things.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Anthem
Regular
Posts: 20
Joined: Wed Aug 03, 2005 10:28 pm

Post by Anthem »

It seems that both IE and Firefox honor   really as nonbreaking space, so you might want you change the line

Code: Select all

(' . $days . ' ' . DAYS . ')'
in serendipity_plugin_mycalendar.php to

Code: Select all

(' . $days . ' ' . DAYS . ')'
I'd actually recommend that change for the official mycalendar, too :)

The remaining time will still show in the same line as the title if there is enough space.
If you want the remaining time always in its own line you might want to change the line to:

Code: Select all

<br>(' . $days . ' ' . DAYS . ')'
or use some stylesheets in this area
2b || !2b
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Thanks for that information!

I am actually a bit afraid that if we include the  in the official plugin it might break other people's sidebar which are dependend on a fixed width - if the plugin enforces a wider area, it might break heavily graphical sidebars...?!

So...maybe make it a config option? *LOL*

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Anthem
Regular
Posts: 20
Joined: Wed Aug 03, 2005 10:28 pm

Post by Anthem »

Ok :)

So what about:

Code: Select all

<SPAN CLASS="mc_date">25.05</SPAN> - <A HREF="">asdf</A> <SPAN CLASS="mc_interval">(53 days)</SPAN>
and solve the display issues with CSS in the template:

Code: Select all

container_serendipity_plugin_mycalendar .mc_date { font-weight: bold; }
container_serendipity_plugin_mycalendar .mc_interval { white-space: nowrap; }
The <SPAN> itself should be neutral in terms of rendering, but I can check on that one.
2b || !2b
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

That sounds like a perfect solution to me. :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Col. Kurtz
Regular
Posts: 450
Joined: Thu May 26, 2005 10:43 am
Location: Bonn, Germany
Contact:

Post by Col. Kurtz »

will you commit this to a new version or do Ill have to make those changes manually? i think there are other changes for that plugin discussed in a seperate thread also.
Anthem
Regular
Posts: 20
Joined: Wed Aug 03, 2005 10:28 pm

Post by Anthem »

Apply this patch after the other two: (patch -p1 < ..)

Code: Select all

diff -ruN cvspatch2/serendipity_plugin_mycalendar.php cvspatch3/serendipity_plugin_mycalendar.php
--- cvspatch2/serendipity_plugin_mycalendar.php 2005-08-04 10:49:18.000000000 +0200
+++ cvspatch3/serendipity_plugin_mycalendar.php 2005-08-04 11:00:56.000000000 +0200
@@ -112,10 +112,18 @@
 
             $days = ceil(($item['eventdate'] - $ts) / 86400);
             if ($days > -$showtime) {
-                echo serendipity_strftime($this->get_config('datefm'), $item['eventdate'], false) .
-                     ' - ' . $cont .
-                     ($days > 0 ? ' (' . $days . ' ' . DAYS . ')' : '') .
-                     '<br />';
+                $cont = '<span class="mc_date">' . serendipity_strftime($this->get_config('datefm'), $item['eventdate'], false) .  '</span>' .
+                        ' - ' . $cont;
+
+                if ($days > 0) {
+                    $cont = '<span class="mc_future">' . $cont . ' <span class="mc_interval">(' . $days . ' ' . DAYS . ')</span>';
+                } elseif ($days == 0) {
+                    $cont = '<span class="mc_current">' . $cont;
+                } else {
+                    $cont = '<span class="mc_past">' . $cont;
+                }
+
+                echo $cont . '</span><br />';
             } elseif ($autoprune) {
                 serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}mycalendar WHERE eventdate < ". ($ts - $showtime*24*60*60));
                 $autoprune = false;
This allows for the following stylesheet:

Code: Select all

.container_serendipity_plugin_mycalendar .mc_past { color: #888; }
.container_serendipity_plugin_mycalendar .mc_current { text-decoration: blink; color: #F00; font-weight: bold; }
.container_serendipity_plugin_mycalendar .mc_future { font-style:italic; }

.container_serendipity_plugin_mycalendar .mc_date { font-weight: bold; }
.container_serendipity_plugin_mycalendar .mc_interval { white-space: nowrap; }
2b || !2b
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

I think I am now completely out of synch with your plugin; I don't have that $showtime variable.

How about I give you CVS access so you can commit to the plugin? I then just need you to give me the name of your SourceForge.Net account (if you don't have one, apply for one, it's free)...and I hope you'Re famillar with CVS, but you sound as if you do. :-D

Regards and many thanks,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Anthem
Regular
Posts: 20
Joined: Wed Aug 03, 2005 10:28 pm

Post by Anthem »

$showtime gets introduced in part II of the patch.

Ok, I just made an sf-account: anthem2005
2b || !2b
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Thanks a lot, you're in. :-)

You'll also benefit from having realtime access to CVS now. :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Anthem
Regular
Posts: 20
Joined: Wed Aug 03, 2005 10:28 pm

Post by Anthem »

Ok, the official names are now
.s9y_mc for the entire line,
.s9y_mc_date for the date,
.s9y_mc_c for the text
.s9y_mc_day for "(... days)"

Should I insert the future/past/current classes as well ?
2b || !2b
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

I think that would help, yes :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Anthem
Regular
Posts: 20
Joined: Wed Aug 03, 2005 10:28 pm

Post by Anthem »

ok :)
The classes are .s9y_mc_past, .s9y_mc_current, .s9y_mc_future

I hope I didn't break anything with the cvs :), I always let someone else do the checkin
2b || !2b
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Your cvs commits all look propper, thanks a lot! :-)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply