Matthew Hutchinson

about

Matt is a web developer from N. Ireland. He currently runs Hiddenloop and works in Dublin. Want to find out just a little bit more ?

An audio feed is available for the latest articles at matthewhutchinson.net, find it here.

Typo Flickr sidebar problems (2)

posted 11 months ago in , ,

The recent downtime here had me stumped – the site was throwing a rather vague ‘controller stack out of kilter’ Rails error from Typo. Looking further at the Rails production.log it seems that the problem stemmed from the Flickr sidebar model. A little googl’in brought up this discussion – It seems that Typo’s default Flickr sidebar implementation is ropey at best.

If you look in /app/models/aggregations/flickr.rb you’ll see that the model relies on a string scan (regex) to match the image url from Flickr’s description field text (in their RSS feed) like so;

1
2
3
def image
    description.scan(/(http:\/\/(static|photos).*?\.jpg)/ ).first.first
 end

So basically if Flickr change the URL they serve images from – this will break. And that was exactly the problem – Flickr’s URL was now http://farm1.static.. blah blah etc. I modified the regex a little to quickly fix it;

1
2
3
def image
  description.scan(/(http:\/\/(farm|static|photos).*?\.jpg)/ ).first.first
 end

This was supposed to be a quick post, but I’ll go on;

Why Typo doesn’t switch to using the Flickr API – I don’t know. You could argue it is more flexible and versatile if the data source is a simple RSS feed- (no need for API keys or security issues) – But the sidebar could at least parse the xml better and avoid this scan altogether. Its got me thinking what else could be ropey in Typo…

For one, a broken sidebar takes down the entire public-facing site with this ‘controller kilter’ error – which is a bit crazy if you ask me. If I have some time I might look into helping Typo fail a bit more gracefully in the future.

2 comments

Liquid error: Expected /u/apps/matthewhutchinson.net/current/config/../app/models/tagging.rb to define Tagging
  1. Tom

    11 months ago, said;

    Hey Matt,

    Have you considered Mephisto ?

    http://mephistoblog.com/

    Tom

  2. matt

    11 months ago, said;

    I might give it a go – new year and all that. On the surface it definitely looks faster – and Dan Webb approves