Sorting Related Articles by Relevance

Posted by paul
Tuesday, August 29, 2006 22:29:13 GMT

As alluded to in my last post, I’ve been looking at enhancing my Typo plugin by adding some kind of relevance to the results.

Since I’m considering articles that share some tag to be considered related, I’m also going to consider articles that share more than one tag more relevant. This is a post that covers my adding that support, as well as some much needed Ruby-ification (is that a word? :p) and refactoring of the code following comments from Piers Cawley on the code in my last post.

Related Articles Plugin for Typo

Posted by paul
Monday, August 21, 2006 13:08:37 GMT

I’m not so sure how relevant this post is now that Piers has started removing the component-ness of Typo’s sidebars (kudos for changing it all so quick). But, it was again an interesting exercise, and hopefully people will take something from it.

Tonight I decided to follow on from my previous post and take a look at packing it all up into a Rails plugin. Well, move the `related_articles` method into a plugin, and have a zip file with the component until I figure out how I can put it all together. Piers’ changes sound like a really cool way of doing things, can’t wait to look at the code later.

Also, please note that I’ve tested this on my machine and it works, but of course that’s no guarantee I haven’t done something stupid :) So I’d love it if people did download it if they could let me know how it all goes.

Writing a Typo Sidebar Test First In Rails

Posted by paul
Tuesday, August 15, 2006 19:21:55 GMT

UPDATE: Sorry, I pulled the trigger too quickly on this and included some old code that I’d updated. I’m in the process of getting the right code up on Trac, all should be well now though.

I wanted to see how easy it would be to make an extension to the popular Rails application, Typo. Primarily, because I needed some extra functionality myself. Secondly, I thought it would be a nice exercise to write something test-first for an existing application I’ve not developed. This (rather large post) is the result.

The post covers most of my process and thoughts as I was working on the code (I started hacking away whilst on an early morning train journey for work).

Getting the Code

At the moment, I’m hosting the code at a Trac install I’ve put up for the (eventual) component. So far it’s just the Subversion patch file, and some notes for installation.

I’m working on changing it so it can be installed without changes to the Typo code, and packaging it properly but I’m learning so please be patient :) If people have suggestions, feel free to add comments!

Anyway, onto the main event…

Rails Security Update and Typo

Posted by paul
Wednesday, August 09, 2006 22:41:46 GMT

So it looks like there’s a security problem with a recent-ish version of Rails (well, anything older than the Edge as of a few weeks ago seem to be at risk). The hole has been described as

This is not like “sure, I should be flossing my teeth”. This is “yes, I will wear my helmet as I try to go 100mph on a motorcycle through downtown in rush hour”. It’s not a suggestion, it’s a prescription.

Fortunately, I’m running an up-to-date version of Typo which quite happily (at least currently anyway appears to) run against the latest Edge Rails (revision 4745).

How to Update Typo Rails

As of a few versions ago, Typo used to use the Rails gem. However, during the Rails 1.1 release a few shared hosts automatically installed the system-wide gem. This seemed to break a few applications, as sites ran code that wasn’t compatible with some breaking changes in Rails 1.1.

The solution was to freeze the version of Rails to 1.0 in the `vendor/rails` directory. Going forward, Typo was brought up-to-date against 1.1, and the repository was also changed to include an svn:externals link to the Rails trunk. The result is that all that is needed to do the update was

$ cd vendor
$ svn up 
...
Updated external resource to revision 4745.

Ahhh, I can breathe easy! Back to the Typo Sidebar hackery (an article will be coming soon)...

UPDATE: I also took the opportunity to upgrade Typo itself, after which, I ran the usual `rake migrate`. Sorry, made a mistake in my original post.

Adding Lightbox JS support to Typo Theme

Posted by paul
Tuesday, April 25, 2006 18:02:00 GMT

The final thing I wanted to do today was to get Lightbox support with the Typo theme I’m currently using (Brighthouse).

Fortunately, it’s an absolute snap.

Upgrading Typo and Rails

Posted by paul
Monday, April 03, 2006 09:20:00 GMT

Last week I noticed that Rails had officially had it’s 1.1 release, and since then I’ve used it for a few things, but my production server is still using the Rails 1.0 gem. Over the weekend I also noticed that Typo was being cleaned up a little ready for it’s 4.0.0 release that would also be compatible with 1.1, but that the trunk contained essentially everything from the upcoming release. So I decided to bite the bullet and give it a go! I couldn’t resist Piers’ advice.

However, since my current Ruby install was 1.8.3, I needed to upgrade a few things: Typo, Rails and Ruby itself!

Here’s what I did.

Flickr Pro

Posted by paul
Thursday, February 02, 2006 14:26:00 GMT

I’ve really started getting into digital photography now, to the point where I’m even considering going a little crazy when I have enough money to buy one of these bad boys (Canon EOS 350D).

Admittedly, so far I’ve really only taken simple one-press shots, rather than painstakingly tweaking apertures etc. to get the right look, but, it’s infectious.

A while ago I made a calendar through the nice people at PhotoBox (highly recommended by the way) for my folks as a Christmas present—it went down a storm. And, was easily one of the most fun days I’d had in the winter months in the run up to the holiday, walking around London with one of my old flatmates.

Although these images are just the ones dumped straight from my memory card, I ended up tweaking them in Photoshop for some time - ended up into the early hours the day before the deadline for Calendar orders, d’oh! - and it was a really, really interesting and rewarding experience for someone who spends most of their day with code—creative outlets are good! Incidentally, anyone else who has no idea how to use Photoshop, I can highly recommend Katrin Eismann’s Retouching & Restoring book, it single-handedly changed my opinion!

But back to Flickr, the limited account was just a little too limited, so I figured that $25 was a small price to pay for a whole lotta stuff, so I upgraded.

What’s really great is that since upgrading my Typo install I’ve also noticed the addition of filters for adding both Flickr images, and, Lightbox. Although the Typo codebase does look a tad complicated right now, I like that it’s got these kinds of things added.

So, to anyone who’s a little like I felt before (self-conscious of taking any photos and feeling like a tourist in my own City), I’d say get over it, give it a go, and Flickr-it-up there, it’s awesome fun! Now all I need is that Canon!

Updating Typo

Posted by Paul Ingles
Wednesday, January 25, 2006 08:07:00 GMT

I’m sure everyone will be glad to know I’m up and running with the latest trunk revision of Typo—the blogging software I’m using. Although it was far easier than expected, here’s a little guide to how I did it (in case others aren’t so familiar with Subversion).

Firstly, I wanted to make sure that if it didn’t go smoothly I’d have a full backup of my MySQL database, so I ran the following

mysqldump typo_production > before_migration.sql

That scripts all of the database to the `before_migration.sql` file, which can then be restored (if necessary) as follows:

mysql typo_production < before_migration.sql

All of my Rails based apps are now running under Lighttpd (a good choice by the way), with the current application folder as follows:

/var/www/servers/_domain_name/current

In most sites this is just a symbolic link to the actual directory created by Switchtower when doing `rake deploy`. However, for Typo, since I don’t deploy via. Switchtower it just has a current directory that contains the 2.6.0 release. So, I renamed the folder and linked to it from current as follows (note this is within the domain’s directory):

mv current typo-2.6.0
ln -s typo-2.6.0/ current

That ensured that I am now in a position to switch over to the edge revision whenever I want to.

Now, all I need to do is pull down the latest typo trunk as follows (again within the domain’s directory in my case):

svn checkout svn://leetsoft.com/typo/trunk typo-latest

That should display a little info about Subversion setting up your working directory, and at the end inform you which revision you’ve just checked out. Since at the time I did it, it reported revision 855, I then renamed `typo-latest` to `typo-rev-855`.

I then copied over my old `database.yml` configuration file, and double checked everything looked ok. As it did, I then performed the database migration:

rake migrate RAILS_ENV=production

You should see a little info as it goes through about what it’s migrating, and (assuming all went well) you should then be in a position to switch over from the 2.6 release to the trunk (again, within the domain directory for my setup):

rm current
ln -s typo-rev-855/ current

Finally, I then gave Lighttpd a boot and watched it come back up. Although this worked in the main, I tried switching over themes and viewing the blog and came across some Rails errors. Checking in the `production.log` revealed the some entries such as:

Errno::ENOENT (No such file or directory -
/var/www/servers/www.oobaloo.co.uk/current/cache)
Couldn't create cache directory: META/DATA/ACTION_PARAM/
www.oobaloo.co.uk/articles/index/ (Permission denied - /var/www/servers/
www.oobaloo.co.uk/current/cache/META)

To remedy, I created a cache directory with the necessary permissions for the app to write to, all now seems to be running well!

Updating Typo

Posted by paul
Wednesday, January 25, 2006 08:07:00 GMT

I’m sure everyone will be glad to know I’m up and running with the latest trunk revision of Typo—the blogging software I’m using. Although it was far easier than expected, here’s a little guide to how I did it (in case others aren’t so familiar with Subversion).

Firstly, I wanted to make sure that if it didn’t go smoothly I’d have a full backup of my MySQL database, so I ran the following

mysqldump typo_production > before_migration.sql

That scripts all of the database to the `before_migration.sql` file, which can then be restored (if necessary) as follows:

mysql typo_production < before_migration.sql

All of my Rails based apps are now running under Lighttpd (a good choice by the way), with the current application folder as follows:

/var/www/servers/_domain_name/current

In most sites this is just a symbolic link to the actual directory created by Switchtower when doing `rake deploy`. However, for Typo, since I don’t deploy via. Switchtower it just has a current directory that contains the 2.6.0 release. So, I renamed the folder and linked to it from current as follows (note this is within the domain’s directory):

mv current typo-2.6.0
ln -s typo-2.6.0/ current

That ensured that I am now in a position to switch over to the edge revision whenever I want to.

Now, all I need to do is pull down the latest typo trunk as follows (again within the domain’s directory in my case):

svn checkout svn://leetsoft.com/typo/trunk typo-latest

That should display a little info about Subversion setting up your working directory, and at the end inform you which revision you’ve just checked out. Since at the time I did it, it reported revision 855, I then renamed `typo-latest` to `typo-rev-855`.

I then copied over my old `database.yml` configuration file, and double checked everything looked ok. As it did, I then performed the database migration:

rake migrate RAILS_ENV=production

You should see a little info as it goes through about what it’s migrating, and (assuming all went well) you should then be in a position to switch over from the 2.6 release to the trunk (again, within the domain directory for my setup):

rm current
ln -s typo-rev-855/ current

Finally, I then gave Lighttpd a boot and watched it come back up. Although this worked in the main, I tried switching over themes and viewing the blog and came across some Rails errors. Checking in the `production.log` revealed the some entries such as:

Errno::ENOENT (No such file or directory -
/var/www/servers/www.oobaloo.co.uk/current/cache)
Couldn't create cache directory: META/DATA/ACTION_PARAM/
www.oobaloo.co.uk/articles/index/ (Permission denied - /var/www/servers/
www.oobaloo.co.uk/current/cache/META)

To remedy, I created a cache directory with the necessary permissions for the app to write to, all now seems to be running well!

Problems with typo and del.icio.us

Posted by Paul Ingles
Thursday, December 29, 2005 09:15:00 GMT

Unfortunately I’ve had to remove the del.icio.us item from the sidebar. It appears that there’s some bad timeout values set in typo for retrieval of del.icio.us content – longer than the FastCGI process timeout.

This was resulting in the server becoming unstable, and causing machine load to spike which is no good, so until I can either fix it myself, or upgrade to the latest trunk of typo it’ll be switched off. You can still access it via the web or an RSS feed if you want though :)

Problems with typo and del.icio.us

Posted by paul
Thursday, December 29, 2005 09:15:00 GMT

Unfortunately I’ve had to remove the del.icio.us item from the sidebar. It appears that there’s some bad timeout values set in typo for retrieval of del.icio.us content – longer than the FastCGI process timeout.

This was resulting in the server becoming unstable, and causing machine load to spike which is no good, so until I can either fix it myself, or upgrade to the latest trunk of typo it’ll be switched off. You can still access it via the web or an RSS feed if you want though :)