Monday, 17 May 2010

Websiting

This morning I watered the garden. After that I looked into detecting a user's bandwidth in order to serve them with a high res or low res pano automatically.

I found this thread on the jw player forum to be quite helpful. Reading the comments there, it seems that Bandwidth detection is unreliable, and also requires approx 100KB for the detection. Since my small files are only around 400KB, 100KB is quite a lot extra for a low bandwidth user to have to download.

So for the moment, I think I'll stick with buttons where the user must choose if they want high res or low res. (Of course when using bandwidth detection you still need to give the user the choice of high res or low res, its just that they don't have to make a choice).

After this I tried to make a dialog box, using jquery tools, that would pop up to give the user a choice of viewing the pano in high res or low res. Unfortunately, the background overlay that blocks out the rest of the page didn't seem to be working. So I spent a lot of time trying to debug why the background overlay wasn't showing up.

Eventually I saved a copy of my page, then cut down the HTML and javascript to the bare minimum. But still no background overlay. So next I saved the demo from the jquery tools website (which did work). I then modified this step by step, slowly changing it to make it into my cut down page. When I changed the jquery script src from the one used in the demo to the one used in my page, the overlay stopped working.

The script src I was using (where the background overlay doesn't work) is the one recommended on the jquery tools website: http://cdn.jquerytools.org/1.2.1/jquery.tools.min.js
Whereas the script src used in the jquery tools (where the background overlay does work) is: http://flowplayer.org/tools/download/combine/1.2.1/jquery.tools.min.js?select=full&debug=true

So while jquery tools might be much lighter than jqueryUI, it's no good if their live version doesn't work properly. So I think I'll try jqueryUI instead. I also prefer the jqueryUI dialog boxes since they can be moved and resized, unlike the jquerytools dialog boxes.

Actually, since I'd already done the work of writing my script to create the dialog box using jquerytools, what I did was to download the jquerytools version used in the demos (without debug=true), and then host this on my own site and point to that instead of the hosted jquerytools script. Now the overlay works, and that was less hassle than downloading jqueryUI and changing my code to work with jqueryUI instead.

In the afternoon I read a few articles about HTML5 and Flash
Basically, Flash currently performs better than in-browser technologies. And I'm pretty sure more people have browsers with Flash support than have browsers with canvas support (let alone things like 3D support that are only available 'in-browser' in the lastest webkit nightlies).

After that I spent most of the afternoon working on a perl script to rename my existing cube faces on the web server. It took so long because although I have used perl before, I don't use it enough to even remember the basic syntax. After spending ages on my script and it just giving the error "No such file or directory" when it came to renaming the file, I found a (nearly) complete solution that did what I was looking for: HOWTO: File Renaming and Directory Recursion. If only I had found that before attempting to write my own script!

My script is modified slightly to find files that start with an underscore, and end with a .jpg extension, then appends 'hd' to the start of the filename:
#!/usr/bin/perl

use warnings;
use strict;

use File::Find;

find(\&underscores, ".");

sub underscores {
next if -d $_;
next if /^\./;
if (/^(_.*\.jpg)/){
print "Renaming ".$_." to ".$1."\n";
chdir($File::Find::dir);
rename($_, 'hd'.$1) or die $!;
}
}

At the moment my pano website uses cube faces with names like _f.jpg (for the front cube face). But when I update it to have high res and low res pano versions, the current cube face names need to become hd_f.jpg (for example) and I will also need to upload the low res cube faces, which will have names like sd_f.jpg.

While it probably would have been much quicker for me to manually rename the current cube faces than spending so long trying to write a script in a language I don't know, the benefit of the scripted approach is that there is very little downtime on the website front. The website will have to be put in maintenance mode while I upload the modified PHP and javascript files, and while the existing cube faces are renamed, so using a script to rename the cube faces makes it much quicker.

In the evening I wrote a perl script that renames the cube faces produced by PTGUI to a format suitable for FPP and my pano website, and also watched 'Ambush at blood pass' with Mauser. The film was quite good, but at the end they had a couple of twists that just made it so the plot didn't make sense.

I was hoping to get all the files etc. ready for the update to my pano website by the end of today, but I haven't even started converted the small cube faces for each pano, let alone uploading them to the website.

The weather started off sunny, then was cloudy most of the morning. In the afternoon there were still a few clouds around, but it was mostly sunny. It looked like there was probably a nice sunset.

Food
Breakfast: Strawberry Toast Sandwich; Cup o' Tea.
Lunch: Breaded Ham with Dijon Mustard, Iceberg Lettuce, Sliced Cherry Tomatoes, and Sliced Raddish Sandwich; Satsuma; Home-made Biscuit; Rocky; Cup o' Tea.
Dinner: Slice of Spicy Chicken Pizza; Potato; Peas. Pudding was a slice of Strawberry Cheesecake.
Supper: Chocolate coated Shortcake biscuit; HobNob; Cup o' Tea.

No comments: