Habari: first plugin and theme adventures

Having seen enough of Habari and experienced its helpful community, I've decided to dive in a little deeper. It had become clear already that the latest stable 0.5.2 release was too limiting as many of the available plugins already depend on features only available in 0.6-alpha, so I upgraded to that. That was just a matter of replacing the code (and making a backup of the database, just in case): everything continued working while earlier errors I'd been running into disappeared.

The first plugin I really wanted to look at was the Twitter plugin, not so much because I'm active on Twitter (I have an account but I'm no longer active) but because I wanted to explore how to adapt it to work with the FLOSS laconi.ca microblogging software which powers identi.ca, as well as a growing number of other instances, like TWiT Army, which is probably the next-biggest. I'm quite active on identi.ca and remotely subscribed to some people on other instances as well. (Habari has an identi.ca account, too!)

The Twitter plugin comes with a little template that will show your latest tweet, so I copied that into my theme, and linked it into the sidebar. Something appeared, so the template-linking was working, but PHP complained about uninitialized variables, and nothing was shown. There was a missing link somewhere... a lot of trial and error and help from the community later I got it working: turned out that for a template populated by a plugin you need to use a different method to include it into another template. Now my latest tweet appeared (well over a month ago!).

The next thing I noticed was that the tiny URL in that tweet was not correctly “linkified” so I dove into the code (again) to see if I could fix it; the problem was that the regular expression used to match a URL didn't actually match all URLs (it assumed only letters after the domain part). I've temporarily “fixed” that so it now matches “most” URLs, but it needs more work to make it match all valid URLs. Next, I also wanted to have the @replies linkified (easy to do for Twitter since it's a closed silo: you cannot reply to someone outside Twitter, as you can with federated Laconi.ca-powered sites); once I had that working I also added an option for it in the plugin's configuration interface. Finally, I wanted a smaller version of the avatar to appear. The Twitter plugin actually pulls the tweet to show and its meta data from a feed (for this functionality the Twitter API isn't needed), and that feed gives a link to the “normal” sized avatar image (as it is appearing in front of a tweet on the web interface). URLs for other sizes are easily derived; I tweaked it so one can now actually choose between “mini”, “normal” and “bigger” - I've chosen “mini” for now.

Twitter plugin showing my latest (last) tweetFinally, I adapted the little template a bit so it's more easily stylable, and added some extra rules to my (k2-based, for now) theme's stylesheet.

Once I have the linkify regular expression made more robust, I'll submit my tweaks, of course! And then a variation to work with Laconi.ca should be easy, since that sports a Twitter-compatible API!

Update: I've now managed to break that regex once again, so right now the link in the Twitter quote is broken. I'll fix that later!


3 Responses to Habari: first plugin and theme adventures

  1. 5 Andy C November 27, 2008 11:43pm

    Welcome to the wonderful and frightening world of Habari !

    Enjoy the ride.

  2. 6 marjolein November 28, 2008 7:02am

    Thank you Andy! So far the ride is exciting and stimulating (if at times a little frustrating when I cannot find how to do something ;)).

  3. 16 Busby SEO Test December 12, 2008 3:37pm

    im im très heureux trouvé votre blog, vous faites vraiment un bon poste

Leave a Reply


Some HTML allowed (like a, em, strong, pre). If you want to embed a code fragment, its syntax will be highlighted if you surround it in pseudo-tags like this:
[geshi lang="php"]echo 'highlighted code!';[/geshi] (instead of using pre); specify language in the lang attribute. Do not enclose your code in tags like <?php … ?> as that will make it disappear.