new SWFObject (1.5)

March 1, 2007

As you will know from my earlier post, I generally consider using SWFObject to be best practice for embedding Flash in a web page. It has recently been updated to version 1.5: Release note.

It is probably also worth noting that while the present is SWFObject, the future will be SWFFix. Lead by Geoff Stearns (SWFObject) and Bobby van der Sluis (UFO).

Mac OS X batch xhtml validation

August 21, 2006

While many development tools include report generators capable of testing the validity of your xhtml site wide, they can only act on the code they are aware of. Where pages are dynamically generated using server-side scripting such as ASP / PHP etc, the only real way of testing the resulting xhtml is to test the content at run-time. The w3c validator is a handy tool for doing this, but it can become tedious to use interactively across a large number of files or test-cases. Additionally, if the site files are part of an extranet, or carry confidential information, you won’t want to be pushing the content out to a public service for validation.

An approach I use from time to time is to batch test site files on an internal network. To do this I use the following tools…

  • w3c validator
  • wget
  • awk (this is already on your system)

There is a small amount of work to do in setting up your system for this approach.

1. Install the w3c valdidator locally

Apple have produced and maintained an excellent article on how to install the validator onto your Mac OS X system. However I found a few areas which at time of writing were not accurately described…

  1. The Base code and the DTD Library downloads are gz files not tar files. This means the 2nd and 3rd lines of the instructions will not work as written. If of-course you double-click the downloaded files on the desktop, they will first expand to the tar file, then expand to a folder on the desktop. At which point will now have the following files and folders on your Desktop:
    1. sgml-lib.tar
    2. sgml-lib.tar.gz
    3. validator.tar
    4. validator.tar.gz
    5. validator-0.7.2 (folder)
    6. validator-0.7.2 2 (folder)
  2. validator-0.7.2 2 actually contains the expanded content of the sgml-lib.tar.gz file and contains a htdocs folder itself containing a sgml-lib folder.
  3. The instructions also seem to fail to inform you where to place the sgml-lib folder. It is apparent from the validator.conf sample file, that the sgml-lib folder should sit inside htdocs. So before going further. just through the finder I copied the sgml-lib folder from validator-0.2.2 2 to validator-0.7.2/htdocs/
  4. We can now pick up the instructions on the 4th line which reads “cd /Library/WebServer/Documents”. The remainder of the instructions worked fine for me on Mac OS X 10.4.7
  5. To test your completed install, paste visit: http://localhost/validator/htdocs/

2. Install Fink Commander

As part of the process of installing the validator, you have installed Fink. Fink commander provides a GUI interface to Fink, I suggest you install it as the next step.

3. Install wget

Using Fink Commander, download and install wget. This is a command-line utility that we will use to automate the downloading of files.

4. Create a ‘batch’ file

OK, strictly speaking not a batch file, but a text file of urls for wget to request. We must first take our list of files and process the text for form suitable urls. For this I suggest the following steps…

In the terminal window, use the following commands…

Using the terminal window, navigate to your local webroot folder.To generate a single column list of all the files within webroot we can use the command…

ls -1

We can send the output of one command directly to the next command using the pipe symbol “|”. Ultimately we wish to create a file containing full urls to the files we want to process. So the next stage is to prefix the filenames with the start of the url. We can do this by ‘piping’ the results from ls into awk. Then finally directing the output to file sourceURLs.txt which will be created up one level so as not to infect the webroot. So on one line…

ls -1 *.asp |
awk '{printf"http://localhost/validator/htdocs/check?
 > ../sourceURLs.txt

Note: Currently I don’t have style sheet control on this blog. The above 4 lines should be typed into your terminal as a single line.

5. Process the urls

  1. move up one level so your working directory contains both sourceURLs.txt and the webroot folder…
    cd ..
  2. create a new folder to contain the validation reports…
    mkdir validationReports
  3. change to that directory
    cd validationReports
  4. execute wget using sourceURLs.txt to create validation reports of each page
    wget -Ei ../sourceURLs.txt
  5. The current folder now contains one html file per validated file. Open them in your browser to check the results.

round the corner

July 8, 2006

After years of dreading having to implement in xhtml/css, a designer’s efforts laced with rounded corners, I recently went and proposed a design of my own requiring them. (Doh!)

Over the last few years a number of tried tested techniques have been established…

I’ve never really been a fan of bitmap corners typically using variants of the long-standing “sliding doors” technique. However if there is a 3d aspect to the design this would probably be the best way.

In my case I just wanted a neat rounded corner between a foreground and background. I found that Nifty Corner Cube was just the job! Released March 2006 under GNU GPL License, the third evolution of Nifty Corners, these are really easy to implement in JavaScript and degrade gracefully. We are not limited two colours as a ‘transparent’ mode allows background gradients through. My only (limited) disappointment was the loss of the rounded border of previous version. However my final design can and will live without borders.

embedding flash in html page – best practice? (SWFObject)

July 6, 2006

For a long time I simply used the html published from the Flash IDE to embed a SWF. Expecting that to be the ‘best practice’ approach. Like others I was concerned at the impact of Microsoft’s upcoming changes to IE in response to EOLAS patent issues. I was dreading either having to write my own JavaSript or research countless approaches.

With SWFObject the problem is solved. It has been around for a long time (formerly known as FlashObject) and appears to be well tried and tested. I was really pleased with how simple it is to use, how it degrades gracefully. I’ve used this on a number of projects and now consider it to be best practice. In future I’d need a very good reason not to use it.

make my h1 look nice

July 5, 2006

I’ve recently been distracted from my flash ambitions back to the world xhtm/css design. One of the issue with the organisation concerned is that in print media they use what I think is a really nice font: ITC Century Light. Ideally this is what should be used for all h1 headers through this site. Obviously not many users are likely to have this font installed. The substitute font is Times New Roman which is not nearly as neat, or distinctive.

In the bad-old days we would have created GIFs for each heading and used them instead. The height of bad-practice in this new world of standards compliance and accessibility.

Prior to doing any research, I had expected use of Flash would fall foul of similar problems. Then I found sIFR. A combination of JavaScript, CSS and Flash, which at run-time replaces designated tags with a SWF containing the text rendered in your font of choice to the same dimensions. What’s better it ticks most of the accessibility boxes. I’m really pleased with how easy this was to set up, and how it gracefully degrades.

Ok I came to this late. But the current version (2.02 at time of writing) has been recently updated with bug fixes and changes relating to ELOAS. And there is a version 3 in development.

This is a good piece of work by the developers, who are looking for funding. Certainly if my client goes with this recommendation, I’ll be sending a donation.