So, another in a series of posts where I package up some code I often use into a reusable library, let me introduce a simple PHP library for creating virtual pages.

Virtual pages are pages on a website that are generated in code, and are sent to the client’s browser, but don’t correspond directly to a physical file. This process requires mod_rewrite on Apache, but similar functionality exists in other web servers.

Defining your endpoint

You must specify your endpoint, and then a handling function. This function can be anything callable; functions, methods or an enclosure.

\simple_page_handler\Page::create('my/page/', function($page, array $subpages) {
        // Your page handling code
});

Writing your endpoint handler

You then trigger the handled pages by writing a page handler, and then directing Apache to redirect unhandled requests to this endpoint.

Example endpoint:

try {
        if (!\simple_page_handler\Page::call(\simple_page_handler\Input::get('page'))) {
            \simple_page_handler\Page::set503();
            echo "Something went wrong.";
        }
} catch (Exception $e) {
    echo $e->getMessage();
}

And your redirect code:

# Redirect anything that isn't a real file to our example page handler
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ example_page_handler.php?page=$1 [QSA]

Hopefully this’ll be useful to someone!

» Visit the project on Github...

I recently had to reinstall Raspbmc for the 4th time in as many days, thanks to an automatic update, sunspot activity, and possibly an intermittently dodgy SD card.

Latest attempt seems to be working (touch wood); the Pi hasn’t bricked itself yet, and the networking is still working. However, fan art is not being downloaded.

This is a note to self, but might be of use to those of you in a similar situation.

The Problem

You’re running XBMC/Raspbmc on a box in your home network. This network sits behind a combined Squid + Privoxy proxy, to provide network level object caching and malware/advert filtering.

You update your library, and while TV season descriptions are loaded, season images and fan art are not.

The Solution

What seems to be happening is that Privoxy is incorrectly identifying fan art images as adverts, which is causing Privoxy to return a 403 error when XBMC attempts to retrieve the resource. This only seems to be happening with the thetvdb scraper, the IMDB scraper for movies seems to have no issue.

The fix is simple, all you need to do is add an exception for thetvdb.com in your /etc/privoxy/user.actions file:

{ allow-ads }
.thetvdb.com

Now you should find that season fan art is accessible once more!

Just a quick post to bring you an update on the email posting support for Idno.

The email posting plugin is a handy plugin that allows you to make posts to your Idno site via email. Unfortunately, since the way POSSE syndication buttons worked was changed a little while ago, it hasn’t been possible to post out to your silo followers in twitter/facebook/etc.

No longer! Now, you are able to specify a syndication destination by putting one or more pipe tags in the email subject line (these will be removed from the post). So, for example to post to twitter, you’d use the “|” (pipe) character before the service, and add a |twitter to the subject line.

Have fun!

» Visit the project on Github...