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.

ClickComments on Feed

I’ve hacked the clickcomments plugin in order to make it display only in the feed (since my layout places the script on the single post’s sidebar).

However I’ve been trying to see it and it is failing for some reason. It just won’t display in my feedburner human-readable feed. I’m not certain if feedburner prevents scripts from running or if the script is malfunctioning but I can see the correct code in the source of the feedburner page.

Can any of me feed readers else see the clickcomments panel under the content? If so I’d appreciate to hear from you.

Just in case you want to do the same with your own blog, in order to make the plugin display the panel only in the feed, you need to edit the plugin in your wordpress installation and just after the function begins, insert:

if(is_feed()) {

and close the bracket just before the return $content; part

In case you want to place the panel in your sidebar (in a widget for example) I’ve found that the folllowing code works just fine

<div class="postreachclickcomments"><script src="http://www.postreach.com/ccengine/display_iframe?perlink=<?php the_permalink(); ?><!-- &url=<?php echo get_settings('home'); ?>" type="text/javascript">
// --></script></div>

And this doesn’t even need the plugin to be installed (but you do need a postreach account)
Hmmm…perhaps I should wrap this in a widget…

As an aside, I’ve figured out why clickcomments stops loading for me eventually. Initially I thought it stopped loading from my specific IP (which is why it kept working from anonymouse) but it’s not that. Apparentlythe script saves a cookie on your browser which stops loading the panel after you’ve voted 3 times.

Unfortunately this created some problems for me as a web designer as I could not actually check if the clickcomments panel is working or not with the changes I made on the layout (I could only see that the source existed). By clearing out all cookies under the Postreach name, the pannel appears again and you can vote once more.

The problem is that this is prone to abuse. Anyone who wished to get a higher rank could just clear his comments and vote his posts once more. Since postreach does not require an account before you vote and it does not check the IP (or so it seems) it is bound to be played by any unscrupulous blogger who dreams of more visitor hits and tries to achieve it through the showcase.

I just hope that Postreach has not implemented a simple security through obscurity method to avoid it and they actually have some checkpoints that I have not seen.

Setting up a Brainstorm Clone

Ubuntu Brainstorm has recently gone live and it’s really a great project and idea. For those not in the know, it is a dell brainstorm/digg mashup for voting on which ideas people want the Ubuntu devs to work on first.

I wanted to set something like that as a project which would give me a chance to see Drupal as well which is something I wanted to do for a while.

Fortunately a little search showed me that the custom modules have already been provided here and all I needed to do was install them.

So I went for the latest and greatest version of Drupal, 6.1 and I must say that I was surprised on how easy the installation procedure was. Just copy to your directory, set up a mysql database & user and run the script. 2 clicks later and you’re through. Cheers for the Drupal team ;).

I then tried to install the modules, fortunately, even though I was confused a bit, I eventually managed to figure out that I needed to place them into my /sites/all/modules directory. Unfortunately, even though that allowed Drupal to see them, it informed me that they are not compatible with Drupal 6.1 🙁

Oh well, no great loss. I went for an alternate installation of Drupal 5.7. One mysql db and installation later, I was set. I copied the modules in the correct directory again and this time I could activate them. Unfortunately I couldn’t get them to work as they need specific database tables to work. Apparently there is a qawebsite.install php script in the module directory that will create table structures, but there is not mention on how to run it. Am I supposed to rename it to .php and put it on my browser or what (Doesn’t seem that way)?

I hate it when no INSTALL.txt is included 🙁

In the end, I created a brainstorm entry and a launchpad question for this, so hopefully someome might be able to give me some instructions. Lets see.

If any of my readers have any ideas, I would much appreciate to hear them 🙂

At least I get to play with Drupal in the meantime 😀

Dynamically expanding single-post sidebar

Yay, I’ve now managed to do something I always wanted for my site. It always bothered me that when I wrote a lengthy blogpost, the right side of the screen always stayed empty when you scrolled down. Unfortunately I did not want to just chuck a few random items to expand it as it would mean that even when I wrote a short post, the sidebar would draw the post down which would have the unfortunate results of making the reader scroll down too much to read the comments (as well as look ugly)

After I used the FSD Sidebar I thought to myself that I really should find a solution to my dilemma. Initially I though to use different post templates and then just select one depending on how lengthy the post came out. Unfortunately, after I created the first, I discovered that WP does not support different templates for posts but only for pages. Unfortunately I could not find a plugin to activate this functionality. This was a bit unfortunate but I didn’t give up.

I went for my second idea: To have the single-post sidebar expand downwards with more items depending on the word count of the current post. I looked around the documentation for a way to collect the word count of a post but nothing was built in WP. Fortunately a short Googling led me to the page of someone who created a plugin exactly for this reason. Perfect!

Now I only needed to figure out how to use a php statement so that the sidebar does this expansion. Unfortunately since I don’t have any php skills to speak of, I turned to the nets again and fortunately it was easy to find what I needed. Unfortunately this statement does not accept an actual sidebar item within the brackets {} but a quick look at other themes informed me to the use of <?php if() ?> and <?php endif(); ?> statement. I still don’t know exactly how to use it properly but I did manage to make it work for me so all’s well.

All in all what I did is test if the wordcount is over a specific limit and then insert the item between the if and endif. Use four of these statements for increasing wordcounts, and your sidebar will expand only when you write an appropriate number of words. Of course this doesn’t take into account pictures or videos, or even different screen resolution that might change the size , but I don’t know if there is a way to test this unless I start checking their resolution each time and changing the word count needed…hmmm…

Ack no!

FSDaily Sidebar

It was proposed to me by a member of FSDaily to add their new sidebar to my site. Apparently a few of my posts have hit their front page and that drew their attention 🙂

In case you don’t know what FSDaily is, it’s a nice digg-clone which focuses on free software issues. A good alternative since now that digg is heavily sponsored by Microsoft there are fears of conflict of interests (and also digg has become way-way to popular imho).

So I said, why the hell not and dived in. I didn’t want to put it in my horizontal sidebars above and below but thought that this might be the perfect candidate to fill up my empty sidebar on single posts. Unfortunately the way the theme is formatted, it means that when I write something long, there is nothing to see on the left other than the initial information above. I was thinking of a way to fill this and as luck would have it, I got this proposal.

I think I will create special page template that I will use for short posts and in there I will not put anything in the sidebar. However on longer posts it would be worth filling that lonely and empty part with something. Perhaps I should diversify even more and create different page templates for different content. For example, on pages where I talk about religion, I could put the atheist blogroll, and on the ones I talk about Free Software, I can have the FSD along with other related stuff.

Still, I will need to ponder on this. The best thing to do would be to widgetize my single-post sidebar and have it easily updated. I just need to figure out how to widgetize.

Oh, well. Tell me what you think 😉

PS: It is ironic that, had I left this post in the original version, you would not not able to see the sidebar on this page. This is because I’ve recently modified my theme (I’ll write about it later) to dynamically expand the sidebar items depending on the word count of the current post. Unfortunately since this was a really short post and in order to see the FSD item you need at least 400 words, it stayed invisible. My solution? Write this post script 😉 . As a matter of fact, I needed a post script with at least a 100 extra words which easily makes this the largest one I’ve ever written 😀

Comments and stuff

So I’ve put a two new tricks on my comment forms.

The first one is that you can now see a preview of what you are going to post. Just write your text and press the preview button and you should see it below. No more orthographical or html errors ;). This was done via the AJAX Comment Preview plugin. It needed me a little css tweaking in order to get it to display as I need it but fortunately I was able to find how to wrap the preview so that it fits with the normal comments.

The second one is the threaded comments option which is done through the plugin with the same name. Although at the moment you can have only one thread per comment, this might make it easier to follow the discussion in case it starts to derail (although I will admit that I don’t have so many commenters). The nifty addition to that is that the author of the comment will now receive an email notification when someone replies to his comment. The bad thing is that you can’t unsubscibe from that but given the low number of comments I get, I do not think that would be a big issue. You can still use the subscribe feature as well, but since this will inform you of every subsequent comment in the thread (even if you do not follow it anymore) most people don’t use it.

This plugin needed me even more time to get right as I needed to format the thread correctly and also test if more than one thread is viable. It is but currently the comment box is screwed on the second comment so I need to work on the css part of it. Until then I’ve enabled only a single thread replies.

One last update is that I expanded the comment field in order to give you a bigger view of what you are writing. I always found the one I had before a bit too small.

I think I’m now going to enable these on my two other blogs as well 😉

Gallery tags not working

So I’ve managed to fix the latest problem that stumped me. This was related to my latest WordPress-WPG2-Gallery combo installation and it was the fact that for some reason the Gallery tag plugin just refused to display the tag cloud correctly. No matter what I tried, the tag cloud always displayed as a list on the blog, (separated by a line, one under the other etc) instead of an inline big & small tag cloud you would expect. Not only that but anything I tried in order to fix this on the WP theme stylesheet did not work. I even tried disabling everything that had to do with <ul> and <li> tags and the damn thing still persists.

What was even more enraging was that by directly accessing the gallery the tag cloud would work as expected, colours and all. Exasperating.

So I spend the whole afternoon and I did manage to fix the tag cloud. I had to use the style injection box that is provided by the WPG2 plugin in order to put the style code that forced list items to be put inline and without line separators. However, no matter what I tried, I could not make the colours change.

Hopefully, while I was lying in bed, it clicked for me. I must have been the gallery theme I was using, wordpress embedded, which makes the gallery fit to your WP theme. However for some reason, the designer has hard coded the font and link colour to the theme, which as a result of being loaded after the WP theme, took precedence. This is the reason why my links had that ugly blue colour and my tag colours would not work. By commenting the colour lines for the <body> and the <a> tags, I was able to force the gallery theme to submit to the WP theme selections.

Just in case anyone is wondering, the stylesheet code I put in my WPG2 Output – Element header textbox is

.g2_column {
width: 100%;
margin: 0px 1px 0px 12px;
}

.tag1 {
display: inline;
background:none;
font-size:8px;}
.tag1 a {color: #828282;}

.tag2 {
display: inline;
background:none;
font-size:11px;}
.tag2 a {color: #AC6FCF;}

.tag3 {
display: inline;
background:none;
font-size:14px;}
.tag3 a {color: #00659C;}

.tag4 {
display: inline;
background:none;
font-size:18px;}
.tag4 a {color: #008200;}

.tag5 {
display: inline;
background:none;
font-size:22px;}
.tag5 a {color: #FFCB21;}

.tag6 {
display: inline;
background:none;
font-size:26px;}
.tag6 a {color: #FF0000;}

.tag7 {
display: inline;
background:none;
font-size:30px;}
.tag7 a {color: #1acdb6;}

Where tag1-7 is the class that the Gallery2 tag plugin uses for each level of tag (based on the quantity)

PS: Yes, I have insomnia again…

Yet another blog

So I’ve bit the bullet again and started yet another blog called The Wesnoth Journals.

Since I’m not in the mood of repeating myself, you’re welcome to check the second post on the reasons why I took the effort.

The whole issue took me around 6 hours to complete, between which my host suffered a load of doom which pretty much make my site unavailable as I was about to present it to the forum. Argh! In any case, fortunately they resolved it relatively fast and I managed to polish it before I went to bed.

Currently it is powered by a WordPress blog and a Gallery installation, linked via WPG2, much like my own site. This is the kind of thing why you love free software (and Dreamhost with their one-click installs. Without any extra money at all, within half a day, I’ve set up and configured a passable site that can fill a gap.

This is especially my opportunity to check out what Gallery can do when there are actually multiple users and need of correct categorization. Until now, my own gallery is used only by my which just does not give it enough to work with. Είδομεν…

So, take a look, and let me know if you see something blatant missing.

PS: If you can be bothered, remind me how to redirect http://wordpress.dbzer0.com to http://wordpress.dbzer0.com/blog

Cheers!

Broken Popularity

Hmmm, it seems that a part of the popularity contest plugin has broken too much for my limited coding capabilities to fix. I tried modifying a few entries but it did not work very well. Oh well, I’ll just wait until the newer version. Until then, just don’t expect to see the most popular posts by category 😉

I just hope that the version of the plugin I am using will be updated accordingly or at least that the original author will take this opportunity to implement the changes Richard made so that it can work with WP-Cache from now on.

Lost categories

Ok, I think I know what has happened with the upgrade to 2.3. Apparently, my wp_categories table has been renamed to wp_terms and nobody bothered to update the WP knowledge base about this little fact (at least not yesterday that I was looking for it). Good job![1]

I guess something like that must have happened since I was looking at my MySQL tables and I got a bit panicked when I noticed my wp_category and wp_post2category tables missing. I upgraded another WP installation I have for testing and noticed the change.

Now, for my problem with the “Zoulapia” error (which is part of my modified theme), I’ve managed to find the solution myself. I just needed to change the following in the function call.

("SELECT cat_ID FROM " . $wpdb->categories . " WHERE cat_name='" . $hemingwayEx_options['asides_category'] . "'")

to

("SELECT term_ID FROM " . $wpdb->terms . " WHERE name='" . $hemingwayEx_options['asides_category'] . "'")

And you can see it worked 🙂

Now I need to find out how to modify the popularity contest plugin so that it can search in the correct table when taking the popular category :-/

Oh, also the 2.3 feature that supposedly would use the previous tags you had, did not work. UTW has a (apparently) scary function to import them to [tag]Wordpress[/tag] db, but I’d rather wait a bit for that.

[1] UPADE: It seems they did mention it here