Saturday, July 23, 2005
Well that was easy...
Getting my "Reading, listening, or watching" section up on Blogger ended up being surprisingly easy.

PHP seems to be back up on the UPL server, but my old blog still doesn't work, as the permissions on the database tables weren't preserved in the upgrade. I still have SSH access to the UPL and would fix them myself, but they seem not to have user authentication up for aftermath, where the database lives, so I can't go fix it myself.

The media section on the old blog would just pull the newest five items from a table with two columns: ASIN and a date. The ASIN can then be used to make two URLs: one for the image of the item and one for the link. Amazon, kindly, has them all standardized.

But since it's such a simple table, I don't really need a database to do it. So I just made a file named data that has an ASIN on each row. Another file named amazon.php reads data into an array (with file) and generates some JavaScript to write HTML to display an image and a link. My blogger profile now has a script tag that references amazon.php and runs it right after the section title.

Really, it's not that hard at all. It probably took me more time to describe it than to do it. I still have an aversion to doing anything that requires JavaScript to work properly, but now that I work at Google, I need to just get over it.
Slight fix to the Javascript. The UPL PHP script now generates Javascript for a function called displayAmazonItems(). The script is now included in the head so that the function is loaded before the browser sets up the rest of the page, and then the function is called where the items need to be placed.

This prevents the lag I was seeing before when the browser would get to the included Javascript and would have to pause while it loaded the script and rerendered the modified HTML.
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?