Go
Decent Blogging using Foswiki Read on
28 Sep 2005 - 20:58 in tagged , , , by Michael Daum
Could not resist and ported the WordPress TimeSince plugin to perl and added it to the BlogPlugin.
The original TimeSince WP plugin was only able to display a time diff as at most two expressions: ``1day, 2hours ago'' or ``1 week ago''. It displays only one time expression if the difference does not occure in two adjacent time units. Time units are year, month, week, day, hour, minute. If a time interval differs in week and hour the TimeSince WP plugin will only display the week difference and not the hours as week and hour are not adjacent. Fixed that in the TIMESINCE tag for TWiki. And added a parameter to specify how accurate the diff should be displayed in terms of number of units. So a TIMESINCE{units="3"} will display the topic age using three time expressions to get it accurate. TIMESINCE will also display seconds and wont stop at the minutes level. There's a parameter to specify the string to be displayed if the time interval is zero: TIMESINCE{from="dateA" to="dateB" null="immediate"} will display ``immediate'' of dateA equals dateB. dateA and dateB can be expressed in a format that TWiki's parseTime() understands and need not to be epoch seconds as in the original plugin.

Anyway you might have noticed it already. It is appearing all over the blog now. Note, that comments are tagged ``SomeGuy replied xyz minutes later'', that is diffing the time of the commented and the commenting posting.


11 Comments

1 SimonRaven replied 1 month, 2 weeks later

hi,

BTW, nice job on the plugin, i really like it. only problem i'm having with it however, is that it uses the file's ctime in displaying the post's time it was posted - a problem when the data (e.g., post, page, etc.) is older than that (importing it from blosxom, imported from wordpress).

how about adding an extra $META:FIELD called creationtime or posttime where the date and time the post was made is user settable, and the plugin fetches that to display it as the post's time of creation? you then still preserve the creation time, and you aren't dependent on a hard to edit system variable modifiable only by root and some *nix magic, but still allow people to have the post be listed in the right month in the archive ;). then you can have an extra field in the BlogEntry to set that date.

something like, in the BlogEntryXXXXX itself:

%META:FIELD{name="DateTime" attributes="M" title="DateTime" value="12223132"}%

(the value= being in epoch seconds)

and in the BlogEntry:

DateTime select 1 MonthJan, MonthFeb, etc. month posted M

and so on for the day, time, etc. … reply

1.1 SimonRaven , 3 minutes later
ergh, sorry, forgot something

wordpress has a similar function, you can change the timestamp of the post to whatever date/time you want, or leave it as-is. … reply

1.2 MichaelDaum, 25 minutes later
Ah, ok. I'll look into that. Hm, must tell the DBCacheContrib that it has to generate the createdate property of an topic using either date formfields if they are there or fallback to the timestamp of the first revision of a topic**, converting it to epoch seconds. Actually an early revision of the BlogPlugin had explicit datetime formfields.

(** Note, that file ctime is not used but the rcs time stamp of the first revision.) … reply

1.2.1 SimonRaven, 5 days, 3 hours later
> must tell the DBCacheContrib that it has to generate the createdate property of > an topic using either date formfields if they are there or fallback to the
> timestamp of the first revision of a topic

good idea.

> (** Note, that file ctime is not used but the rcs time stamp of the first revision.)

Oh, I see. So I technically could create the thing, change the timestamp in the RCS file (or on, depending) and have the posts show up at the time I edit / touch / whatever I set them to (?).

> Actually an early revision of the BlogPlugin had explicit datetime formfields.

That's a nice feature that's in WP, and blosxom has as a 3rd-party script. … reply

1.2.1.1 SimonRaven, 1 day, 3 hours later
Ahhh, that change to BlogPlugin is really nice. Took a few minutes to figure out what format the date took, but then i went "Doh! check the TestEntry0 for the format", and voila, it even takes seconds - very cool.

Thank you thank you thank you, you just made my week :). … reply

1.2.1.1.1 SimonRaven , 4 minutes later
Oh, oops, meant to say that maybe it should be documented - the date format I mean, here it is, just for that reason:

Date: 31 Feb 2003 - 00:01

(impossible date, but it makes it easy to search, and sticks out wink ) … reply

1.2.1.1.2 MichaelDaum , 26 minutes later
Oh, yea. Forgotten to mention the datetime format. But as soon as you create a new BlogEntry you will see it anyway as it is added automatically. Never mind. I could easily add more datetime formats snarfing them from the TimeSincePlugin.... … reply
1.2.1.1.2.1 SimonRaven , 16 minutes later
Whatever turns your crank :). Well, you'd probably get actual requests for it, so might as well be proactive about it I guess. Again, thanks a whole bunch :). … reply

2 MichaelDaum replied 1 month, 3 weeks later

Implemented explicite Date formfield

That got in in BlogPlugin v0.10. Right now only the BlogEntries have a 'Date' formfield. Maybe we need that for BlogComments too. … reply

3 MichaelDaum replied 1 month, 3 weeks later

More fixes in v0.10

Note, that there was an anoying bug in RECENTCOMMENTS that got fixed in this version. … reply

4 MichaelDaum replied 1 month, 3 weeks later

What comes next?

Stored procedures smile Stay tuned. … reply

Leave a Reply

You may have to login or register to comment if you haven't already.
r5 - 27 Feb 2006 - 16:22:22 - Main.MichaelDaum
Copyright © 1999-2012 Michael Daum Consulting. All rights reserved. Impressum.