Date difference counter plugin

Creating and modifying plugins.
deurk
Regular
Posts: 40
Joined: Wed Jun 21, 2006 5:36 pm

Date difference counter plugin

Post by deurk »

Fellow serendipiters...

Here is a plug-in that can display a difference between the current date and a specified date (either in the past or in the future). It is straightforward to use and is ready for multilingual blogs.

Here is the syntax to use inside 'title' and 'displayed text' fields:

Code: Select all

<en>text in English</en>
<fr>texte en Francais</fr>
<de>Ich spräche nicht Deutch!</de>
You can also use some variables (without which the plug-in would be pointless):

Code: Select all

%Y: years difference
%M: months difference
%D: days difference
%h: hours difference
%m: minutes difference
%s: seconds difference
Current Features of version 0.24:
(bold items have been updated in the last revision)
  • It can count both ways (past or future) compared to present time.
  • It is stackable.
  • It provides an usage example by default.
  • The text displayed is completely customizable
  • It supports any language you currently have via an easy syntax.
  • It supports the non-use of the mentionned syntax for basic plugin configuration.
  • The syntax now supports singular/plural terms like shown in the default text exemple
Features missing so far:
  • It lacks no display of values like 0 units
Want to see it in action?
Visit Gaïa's blog

Want to try it?
Download version 0.24 here

Comments, ideas and code changes are more than welcomed :D
Last edited by deurk on Wed Sep 13, 2006 5:23 pm, edited 8 times in total.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Age plugin

Post by garvinhicking »

Hi!

Even though I personally don't need that plugin, it's great to see that you have succeeded in creating one! Good work!

Also your blog looks very nice. Which was the reason I thought to reply here :) Very pretty pictures of your baby. :-)

I hope you'll have fun with Serendipity,
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/
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

I'm with Garvin... I don't really have need for the plugin (though I have thought about something similar before, I have never really found a good use for it).

BUT, your blog is great and your daughter is adorable! (Your pictures are terrific, too!)
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

deurk, well done. I actually can think of several uses for your plugin, unfortunately not for my own site, but let me tell you anyway. Perhaps other users might agree with me.

School teachers could use this plugin to create a project blog for their students, perhaps where a science project is aged instead of a person.

Also, scientists, bioligists, physicists, laboratory trials etc might find it useful. Add pharmaceutical companies and hospitals who might want to show the age of a drug trial.

Political strategists or fund-raising charities might want to show the age of a campaign contribution program, and perhaps they could have the plugin modifed to show the dollars received.

If this plugin could also be amended to show a countdown from a defined point, then this might become even more useful to Serendipity users, I'm not sure if we have a countdown plugin and if we do then maybe they should be merged.

Carl
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

Actually I've thought of a reason why I want it for my own site, simply to show the age of my blog, duh, all that longwinded stuff above and then kapow it hits me, I want that plugin
Harald Weingaertner
Regular
Posts: 474
Joined: Mon Mar 27, 2006 12:32 am

Post by Harald Weingaertner »

So finally someone should be interested ;) I am :)

I will find an area in one of my blogs. Where can i get this plugin?

Regards, Harald
d_cee
Regular
Posts: 603
Joined: Wed Jan 18, 2006 6:32 pm
Location: UK
Contact:

Post by d_cee »

Hi deurk

What a great plugin idea it would go well in my 'Being a Dad' blog. Are you going to make it available to download.

And I agree with all the previous posts - you have a beautiful daughter

Dave
Dalif
Regular
Posts: 40
Joined: Mon Aug 21, 2006 9:33 am
Location: Under your bed
Contact:

Post by Dalif »

Yeah.. That would be kind of fun to have around.

Like your site (looks a spitting image of my own..). I like the english/french feature. Well nifty.

Keep it up!
..|., 4tw
deurk
Regular
Posts: 40
Joined: Wed Jun 21, 2006 5:36 pm

Post by deurk »

Wow :)

Thanks for the cheers: Gaïa will be delighted to know she has such a fan club :P

And about that plugin, let me allow it to be used as a counter too and I will release it :)
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

yeah, then I can use it to age my blog and count the number of templates released!!! looking forward to your plugin
deurk
Regular
Posts: 40
Joined: Wed Jun 21, 2006 5:36 pm

Post by deurk »

Ok, I have included the possibility to go inwards or backwards in time to your liking. Now I am trying to get it to be text customizeable (and in several languages).

Not so sure about that yet.
Might release it first in one language :P
deurk
Regular
Posts: 40
Joined: Wed Jun 21, 2006 5:36 pm

Post by deurk »

All right.

Here is a first version (named 0.2 since I added multilanguage option to it) of the date counter plugin.

DONE:
- It can count both ways (past or future) compared to present time.
- It is stackable.
- It provides an usage example by default.
- It supports any language you currently have with a stupidly easy syntax:

Code: Select all

<en>text in english</en>
<fr>texte en francais</fr>
<de>je ne parle pas allemand!</de>
...
- Title support the same syntax since I hate having little details like a title not translated (boohoo for the blog title though :P).

TO DO:
- It lacks plurial handling
- It lacks no display of values like 0 units
Those will be coded soon.

Please test it and tell me what you think of it, what can be improved, etc... and PLEASE REMEMBER that I am NO PROGRAMMER, I do network stuff for a living so my code my be as dirty as a sewer rat (no idea why this idea popped into my brain).

Thanks :D
Last edited by deurk on Fri Sep 08, 2006 10:33 am, edited 4 times in total.
deurk
Regular
Posts: 40
Joined: Wed Jun 21, 2006 5:36 pm

Post by deurk »

Updated it to 0.21 to add some exemples default values and correct a few little thingies.
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

I'll be looking at this later this evening!

Meanwhile, you may want to consider switching to the Serendipity internationalization standard: create a variable for each text string you may want to substitute in different languages. Then define each variable with its English text string in a file called lang_en.inc.php. Do the same for German in lang_de.inc.php, for French in lang_fr.inc.php, etc.

Your example might be named PLUGIN_DATECOUNTER_TEXT, and then in lang_en.inc.php you'd put @define('PLUGIN_DATECOUNTER_TEXT', 'Text in English');, while in lang_fr.inc.php you'd put @define('PLUGIN_DATECOUNTER_TEXT', 'Texte en Francais');.
Judebert
---
Website | Wishlist | PayPal
deurk
Regular
Posts: 40
Joined: Wed Jun 21, 2006 5:36 pm

Post by deurk »

Already done but CONTENT of the plugin should be editable without touching the files... So that's my proposal to it. Try it and tell me ;)
Post Reply