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.

Memberlist for Collaborative WordPress Blogs

In case you have a self-hosted Worpdress blog which has multiple authors you may have noticed that you don’t have lots of option to show information about each one. You can have each author create a post for himself and link it from the sidebar (Which is how Debunking Christianity does it), or you can create a page for each one after they provide you some information about themselves. Finally you can just leave each author’s page to be the default list of posts.

I wasn’t satisfied with either of those options so I looked around and found something better. So I have just finished with my custom member list setup at the Antichristian Phenomenon and I thought I’d share how I did it in case anyone wishes to implement it as well.

I started after I discovered this excellent guide from WPDesigner. Although I didn’t need the role manager, the rest of the instructions were perfect for my purpose. So I installed the necessary plugins (plus Register Plus to stop spammers registering) and started adding fields.

I then needed to display those fields in each author’s page somehow. In also wanted to do that without making the page totally different from the reast of the site. So I copied the archive.php file to author.php. I enterred the file and inserted all the necessary variables for my fields (as described in the guide) and deleted all archive loops except the author’s. This way the user visiting the author page could see the author profile but also a list of articles they have written.

The curauthor variable was used to grab information for some of the default fields. Unfortunately the Wp User Manager plugin does not give you the names for all the default wordpress fields but fortunately the documentation in curauthor is complete. I copied the html div the archive loop was in (so as to have the same format) and created a little list to show each author’s profile. Here’s how it looks like currently

Once that was done, I decided to see if I could also put comments in each author’s page as well. Unfortunately, just putting the php call for the comments template between the info and the archives did not work. Apparently WordPress does not expect comments on archive pages. However since I am using Intense Debate Comments at the moment I figured that they would be agnostic on where I am putting their script.

Unfortunately since IDC works through the wordpress comments template, where that does not appear, so does IDC. I managed after all to work around this by copying the script itself into the template. It wasn’t easy to get the code for this since IDC insists on providing you with a WP plugin instead of allowing you the option to paste the script somewhere. I finally got the code by telling IDC that I wanted to install it on my gallery. Unfortunately, the script then had the wrong ID and I needed the correct one to have my comments logged at the correct blog. For this, I was able to just edit the WP plugin code and copy the ID from there. So I pasted the script in the template itself and, lo and behold, it worked! I now had comment capability on each author’s profile page 😀

Once this was done, I made a quick test comment to check if it works and noticed that IDC was logging a strange page title for the Author’s profiles. It seems that my theme is using a title for author archives as if they were a category archive and that would not do. I thus edited my header file and placed an if statement to check if it is an author page. On a positive, I changed the page to show a more appropriate title as well as the author’s nickname (through curauth again). Unfortunately IDC still kept grabbing some weird titles (or not at all) but it’s not caused by the title anymore.

Finally, I listed the authors of the blog on the sidebar through a php widget, I looked at it, and it was nice.

Theme Upgrade Fail

I never understand why upgrading to the newer HemingwayEx is such a hassle. This is the second time I’ve attempted it now (once more on 1.0) and I just now gave up.

What is happening is that I get the theme to work, I can change the colours just fine and switch to finally using widgets, but for some reason I can’t get the suckerfish dropdown to work and I keep running into various other problems (like my gallery losing its theme etc).

It wouldn’t be such a great problem if I knew where to start but what is happening is making me scratch my head. Specifically, even drop-downs start to work once I put the code in, they get hidden behind the background. That is, I can see the dropdown menu appearing (the top of it) but its somehow placed behind the main content and even expanding the navigation does not make it appear. Grrr

Anyway, it’s too much bother to figure out what is causing this so I’ll stay with my current version which still seems to be working fine. I will however attempt to widgetize it and perhaps upload it as a different version from HemingwayEx. I’ve aready created a sourceforge page for it (waiting approval still) and then possibly more people might be willing to help.

It only annoys me that I spent so much time on it and I still couldn’t get it to work as the current version.

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.

Hacked Simplelife

At the request of a commenter who is also playing around with his simplelife plugin, I’m uploading my currently hacked version.

It’s not pretty so you won’t be able to change all options on the profile (only the ones included in the original) but I’ve included comments in the code so you should be able to figure out what is what.

You will need the Simplepie core WordPress plugin in order to use it.

Currently this version supports the following extras (Over the original simplelife)

In order to make it work for your own lifefeeds, you will need to edit the php code directly. You will have to edit either the ones I’ve set up (for example, change your digg username) or add your own.

To add a new feed you need to do the following

  • Add the new class for it (Defining colour, background and icon)
  • Add a new variable for the feed url
  • Add a new variable for the title that will be used in the chart. Optionaly you can set it to something specific but if you don’t want to, the script will just draw it out of the feed
  • Add a new variable for the counter.
  • Add the new feed url variable in the SimplePie array. Your new feed will need dates so don’t use something like Ponyfish.
  • Create a new if statement (just follow my comments)
  • Optionally, if you’re using getboo or something similar, add a new switch for the subtags
  • Add the title and counter variables to the chart if you want them tracked. You’re better off copy-pasting one of the current entries in the middle and pasting it below. If you copy and paste to the bottom of the chart, you’ll probably add an extra comma where you shouldn’t. Don’t forget to change the small chart as well.

If you have any questions, let me know.

PS: I am currently waiting for version 1.3 to come out so that I can merge all my changes in the new code but it seems to be taking too long. I think I might as well start beatifying it in order to upload it as standalone.

Download the hacked version of the Simplelife WordPress plugin here.

How to track anything and everything in your lifestream

Usually, most lifestream services out there only allow you to track specific places and usually these places are only the most popular like facebook, flickr, del.icio.us etc. Furthermore they only give you limited control on the look.

This is mainly the reason why I went for my own hosted lifestream. It allows me to track anything I can get a feed for as well as modify it as much as I want to look the way I want it.

However there is always the problem of how to track things that do not provide a feed of some sort. Sure, you might be able to use co.mments to track you blog comments but what if you want to log the comments you left on a forum, in a bug tracker or in a private location? How about when you need to track something completely different than that, like an email of yours to a mailing list or a new torrent you’ve uploaded?

The answer is: Simple. Bookmarking.

All you need to do is utilize an online bookmarking service like del.icio.us or getboo to tag your actions and then use the tag feeds to import them into your lifestream. Not only then can you get a feed for the various actions of yours, but if you utilize extra tags, you can categorize it further afterwards, provided your lifestream services can play with categories.

For example, I am currently bookmarking all the comments I leave on the internet and tag them as “mycomments“. If you check these bookmarks you will also see that they are further tagged as “blogcomments”, “comment_start” etc. Once a comment is tagged, Getboo provides it as a tag feed which I import into my google reader lifestream (for archiving purposes). Finally, my lifestream takes that and depending on the original tag feed the item comes from, it formats it appropriately in the list. Thus you will see all the comments use the same icon & colour while the FSD actions another. However they are both in the same service (getboo) and in the same feed (Google reader lifestream).

Not only that, but if you look deeper you will see that even items from the same source have further differences. Under the FSD class you can see items marked as “Voted Up”, “Buried” or “Commented on”. They are all however coming from the same original getboo tag feed and this is where the tags/categories of a bookmarking service come especially handy. Using the amazing capabilities of SimplePie and some newfound php knowledge I’ve cooked up a method to query the categories of each lifestream item and further format them based on what I find.

At this point, (with only free software tools mind you: getboo, wordpress, simplepie and simplelife) I have a lifestream that is much more inclusive than, I believe, any other option out there, and the capabilities I have are truly endless.

Currently, I am planning to getting logs for mailing lists, bug fixings, wiki edits and whatever else I do on the intertubes. Once everything is ready, I just need to wrap everything up and give it to you as an enhanced WordPress plugin 😉

PS: I suggest getboo throughout this article because del.icio.us is already used by many other lifestreams out there already. If you start bookmarking your actions there, you’ll get them double unless you unregister del.icio.us totally it from your service. That will mean however that your normal bookmarks won’t be tracked anymore. By using an alternative, you avoid that fate and get the best of both worlds.

Oh, and did I mention that if you really have to, you can also host your own getboo? 😉

So what are you waiting for. Start tagging 😉

Using a Google Reader as a lifestream archive

After I set up my lifestream to track a host of custom actions (like comments on other blogs, or votes on FSD) I discovered that many of the feeds I was using were having a item limit (from 10 to 20). That meant that if I made, say, 11 or more comments in various other blogs, the older ones would dissapear from the list, even if the date was still in the limit I’ve set. Only the newer 10 would always be shown and it would seem as If I made no comments below that date.

It was not a bigg issue but I really wanted it to work right so as to get a more accurate overall idea of where I am spending my time (graphs and so).

I remembered then, that Google Reader seems to always have the option to go back into older posts in the feed, up to the time that you made the subscription through it. This meant that it archives everything in that feed and stores it in its own server (Damn that Google storage is endless). Also, Google Reader has the option to put various subscriptions under a specific folder/tag, allowing you to read all the subscriptions together.

It also allows you to make that tag public. A Public tag allows anyone to see the feeds that you share through it but also gives you a feed to subscribe in turn. This feed, unlike the original ones, can provide feeds data as far back as the time you made the Google Reader subscription (and even further if someone else had subscribed to it before you, I believe). All I needed to to is append ?n=# at the end of my google reader feed where # is the number of items I want to see each time the feed is polled. (I selected 100)

So there I had it. An easy way to make an arvhive of my tracked activities without setting up my own database.

The only problem now was to make the lifestream plugin recognise from which feed in turn each item comes and then assign it the correct class. This was a more challenging question as my previous method to compare the original feed with the current item’s could not work. I discovered that I could filter by the items target link but since I wanted to use the same service to track different activites, it would always filter them the same way. In case you’re wondering, I use Getboo to bookmark pages that I commented on as well as FSD articles I’ve voted up, down or commented (Since, unfortunately, FSD does not provide such feeds by itself until now). The number of things I track through Getboo will only increase as I find more actions that don’t provide feeds.

Thus I needed some way to the original feed through my Google Reader lifestream feed.

Well, how very fortunate of me that Google Reader publishes an Atom feed and not only that but it includes the source of the original feed for your convenience. 😀

A little trial & error with the (truly excellent) SimplePie APIs, and I’d managed to find and write the code that I needed to use.


if ($feedurl == $greader_lifestream_feed) {
if ($source = $item->get_source()) {$source_url = $source->get_permalink();}
if (stripos($source_url, 'twitter') !== false) {
$class = 'twitter';
$tf_counter = $tf_counter+1;
$current_title = 'Status Update (Twitter)';
}
if (stripos($source_url, 'mycomments') !== false) {
$class = 'comments';
$extra_text = 'Commented on: ';
$getboo_comment_feed_counter = $getboo_comment_feed_counter+1;
$current_title = 'Comments Elsewhere';
}
if (stripos($source_url, 'fsd') !== false) {
$class = 'fsd';
$extra_text = 'Voted up: ';
$fsd_counter = $fsd_counter+1;
$current_title = 'Votes up on Free Software Daily Article';
}
}

And yes. I’m proud of my little code snippet. 😀

So now, if I have any feed with a sufficiently low item limit, all I need to do is subscribe to it through Google Reader and add the appropriate if statement in my plugin code and presto! Instant archiving. There is only a (very) slight problem in the sense that the lifestream update is delayed by the time it takes for google reader to refresh the original feed and then update the public tag.

All I need to do now is figure out a way to separate items in the google reader feed through the category tags that getboo provides. That would be sweet as it would cut down on line number but unfortunately the get_category() simplepie function does not seem to work as intended for me 🙁

Charted life

I’m not the one to pat himself on the back for the smallest thing, but I must say that I feed quite proud about my latest little hack in my lifestream.

I was initially inspired by yahooza’s lifestream (via the lifestream blog) after I saw that little chart on the right side. He used the google charts API to achieve which seems quite easy to use and very impressive for online use. Thus I digged in my Simplelife plugin and started hacking around.

You can see the result below. For my limited php knowledge, this was quite a achievement 🙂

My personal pie chart

Of course the above is a static image, but within my lifestream page, this is updated dynamically every time the page loads. I like 😀

Of course, this will soon be available to you all since the Simplelife v1.4 is coming out soon and the author would like to implement some of my ideas in it.

Now all I need to do is to find a way to get the dynamic image in a format that I can put in other places without having to run the script along with it 😀

Where're my damn icons?

I don’t get it. My lifestream icons are not loading for some reason even though you will see in the page source that they are loaded as part of the class. For some reason, initially the last.fm and facebook icons stopped loading after I hacked the SimpleLife plugin to make it play with all kinds of feeds. Then, I discovered why the colours of the custom feeds were not being used (a missing colon) and fixed it, and now <a>all</a> my icons are gone…

Grrr!

Nothing I do seems to fix this and I just cannot see why it is happening. There does not seem to be an obvious error in the code and the rest of the css class (text, background colours) are loading just fine. In the source of the page, you can see the css clearly loading correclty


a.lastfm {
background: 0c0c0c url(http://dbzer0.com/wp-content/plugins/simplelife/lastfm.png) no-repeat 10px 50% !important;
border-top: 1px solid 0c0c0c !important;
border-bottom: 1px solid 0c0c0c !important;
color: #BFBFBF !important;
}

And then the item call

<li class=”item”><a href=”http://www.last.fm/music/Machinae+Supremacy/_/Stand” class=”lastfm” title=”db0’s Recently Played Tracks”><span class=”timesf”>09:48</span> Machinae Supremacy – Stand</a></li>

And the icon exists…
Anyone have any idea what is going on?

At least now I can have feeds from any source (feedburner, del.icio.us, google reader) without losing formatting. I just need to wait for the next plugin version to add options for more streams 🙂

UPDATE: Nevermind. I found the culprit. Apparently I’m blind…

Mighty plugin hacking

Well…for my newbie standards at least 😛

I’ve been playing around with the SimpleLife WordPress plugin, trying to create a simple lifestream I can embed in my about page and perhaps in my sidebar as well. It turned out that this was a job which needed a bit more attempt to make it work.

Below are the changes I did in order to wrangle it.

  • Had to edit the plugin in order to get it to diplay correctly in the plugins page. For some reason it floods the screen with it’s contents. Apparently editing and saving should solve it but in my case I needed to delete some newlines as well.
  • Changed the classes .date and .time to .datesf and .timesf and modified where they were called. Leaving them as they were, they were screwing with other css classes on my site under the same name
  • Changed the if statement for last.fm to look for the string ‘last.fm‘ instead of ‘last‘ since that string may be a part of any other url.
  • Put three new if statements, similar to the ones that check for last.fm and facebook, that check if the link goes to this blog, the ACP or the Wesnoth Journals. Then set the class according to that. The way the plugin is setup, it does not assign the class depending on the feed url bur rather according to the current link url. This means that you cannot use feedburner as your feeds address as it will never trigger an if statement[1]. I actully find the way this is handled a bit weird as it would serve much better to check the feed url and assign a class, rather than check the current link. I’ll have to check if that’s actually feasible…
  • Commented away the if statements for the first three feeds. I’m using the custom ones instead now.
  • Manually set the colour of the last two feeds within the plugin. For some reason even though the php call takes the variable I’ve set in the plugin configuration page (I can see it in the source code of the page) the colour is not being used and the text stays black. Weirdly enough, the background colour is changed well enough and the “blog feed” works just fine.
  • I didn’t want all my delicious feeds to be posted because I seem to be doing an awful lot of them. I prefer to log only the ones that signify my comments for which I use the mycomments tag. Fortunately I’ve discovered that you can use a del.icio.us tag by using the form: username/tagname
  • Created a new page template and inserted the php code there.

All-in-all, the plugin seems very promising and it already seems to work fine for me. However it does seem quite error-prone and lots of people most likely won’t be able to use it yet. Fortunately this will be fixed in the short future.

Now I just have to see if I can add more stuff for it to track.