ComplexLife

window peeksSo finally my very first WordPress plugin is accepted into the official plugins repository 🙂

This is a historic event. I’m certain that fame and fortune will not be very far back!

In case you haven’t seen my recent page about it and you don’t care to read it, Complexlife is a lifestreaming plugin which is a fork from SimpleLife (You see what I did there? 😛 ).

After adding a lot of features and options to it and seeing that Simplelife is not progressing I thought I’d go ahead and just upload it as a new version. This will allow me to have a more organised development and also have the help of anyone who wishes to improve it.

I’ve already got a few features I want to add and I’m also going to be merging changes from other places where I find them, i.e. the trumblog.

So if you’ve got a self-hosted WordPress blog, give it a go and let me know what you think. I’m eager for feedback.

An easier way to track your comments in your lifestream

I’ve been trying to find a better way to allow my lifestream to track my comments that would require less manual activity from me as well as allow me to track my own comments in my own site.

When I started using google reader to archive and extend my lifestream, I briefly considered using it to track my comments as well but I decided against it as I wanted first to see if comment services like Cocomments or co.mments might work (they didn’t). I also could not see a way so as to get it to track only the thread titles where I’ve placed a comment (so as to insert it in the areas I am commenting) or how to get my lifestream to display only my own comments.

However, after managing to set up google reader as an archive, I discovered how much more information an atom feed is providing, part or which is the author or each comment post. Just what I needed 🙂

I quickly cooked up a bit of code to just keep the comments left from me in each thread’s feed. This is something I was not able to achieve with Cocomments and co.mments as they don’t provide you with an actual feed of the whole thread but rather they copy the text and provide you with a raw html formatted to simply look separated.

There was also a little problem that many feeds included various words in the title like “Comments on:” which just looked bad when I appended my extra “Commented on:” text. I needed to find a way to remove them so a little search and the php solution appeared. Perfect!

Last step was to trigger it even if I happened to comment with differing case in my alias. the “if” statement is quite anal about cases that way. All in lowercase then.

The end result is this:

if ($feedurl == $greader_comment_feed) {
if ($author = $item->get_author()) {
$name = strtolower($author->get_name());
if ($name == get_option('greader_comments_author')) {
$item_title_crops = array('Comments on:', 'Comments for', 'Σχόλια στο:');
$item_title = str_replace($item_title_crops,'',$item->get_source()->get_title());}
else {continue;}}}

Finally, all you need to do is setup a google reader public tag where you’re grouping in all the thread feeds of any place you comment in. You can see mine here for example. Get the feed of it, put the number of items you want to see (the default is 20) by appending ?n=# in the end, where # is the number of items you want. In this case you should put something sufficiently large as this will also include comments from others.

Unfortunately, once this was setup, I realized a limitation of simplelife. It still could not limit the number of items you received by date. This is apparently on the “To Do” list but seeing how long it is taking for new versions to come out, my only option was to code it myself. And code it I did 🙂


if (get_option('simple_datelimit') > 0) {$date_limit = get_option('simple_datelimit')*86400;}
if ($item->get_date(U) < date(U)-$date_limit) {continue;}

Not only that, but I decided to try my hand at adding it as an option on the plugins config page in the WordPress admin panel. This is why the “get_option” exists instead of hard-coded entries :).

What it does it take the number of days the user submits and multiplies it by the number of seconds in a 24h day (86400). After that, for each entry, I get the date in a UNIX epoch format and compare if the day the item was recorded is within the number of days I’ve set. If not, I just skip the current iteration.

The new option to set how many days of history you need.

Finally, since I already managed to edit a new option in the config, I thought why not to create the option for the Google Reader feed as well. And lo! There was code.

The Google Reader Comments menu config

Since this wasn’t really hard, I’m planning now to prepare the plugin for general consumption and perhaps upload it to the Codex. I’ve was waiting for the 1.3 version to come out so that I could take that as it has some more improvements, but it just does not seem to be happening.

I also have some nice ideas to improve the config, like Ajax dynamic menus etc but that’s for the future.