Archive for the ‘Server-side Programming’ Category

PNG 24 Round Up

Monday, November 27th, 2006



PNG24’s are the answer to all our prayers. Now I know what you’re thinking: “PNG’s have been around forever…what’s the biggie?” Well the biggie is that IE 7 is now supporting PNG24’s which means that we can start doing some awesome stuff without having to hack our code to shit! Unfortunately it’s still going to take a wee while for IE 7 to filter down to most users machines so we’ll still have to do a little bit of hacking for our dear friend IE 6
(more…)

webdeveloper.co.nz goes semantic

Tuesday, January 11th, 2005

I maintain the New Zealand Web Developers Forum. I’ve recently moved it over to a new host and along with that I also upgraded to the latest version of the forum software.

Earlier this evening I went back to punbb.org to see if anyone had replied to my month old bug report. I noticed they released a brand new version - what a surprise!

I had to get it, and for good reason. The forum software produces the most beautiful, semantic XHTML. The guys at punBB have put in a lot of hard work, and many hours of front end coding to get it to look and feel so good. I think it may even be the only semantic web standards based forum product out there!

dontcom’s new insides

Thursday, January 6th, 2005

I’ve spent the last couple days upgrading to an unsupported ver of WordPress. You can see the full version information in the footer.

The biggest change I’ve noticed (other than numerous UI tweaks) is the way it handles the templates. It’s no longer just one index.php file in the root of the WordPress install - there is now an entire template directory structure and accompanying admin interface. There was talk of the upgrade script for porting one’s current template over to the new system but this feature didn’t seem to work for me.

If you are thinking about using WordPress I would suggest you get the latest nightly build rather than the stable ver, as you’ll just have learn the new templating method anyway.

So far I’m most pleased with WordPress 1.5. It took a bit of a kick start, but its now chugging along just fine, thank you!

By the way - Merry New Year.

ISO 8601

Wednesday, November 24th, 2004

The ISO 8601 date/time format looks like this: 1984-09-01T14:21:31Z. It contains all the information you need. The problem with this format is that it doesn’t look the more presentable.

This is where PHP and a little creativity come into play. Consider the following code:

$isotime = "1984-09-01T14:21:31Z";
$isotime = str_replace("Z"," ",$isotime);
$isotime = strtotime($isotime);
$nicetime = date("jS F Y",$isotime);

Pretty cool, huh?

delicious linkage

Tuesday, November 23rd, 2004

del.icio.us seems to be the flavour of the month! Bloggers around the world are turning their attention to this amazing system.

I’ve been using del.icio.us for a while now and have finally written some code to integrate it into this here blog.

Thanks to an awesome PHP API I’m now able to access the raw data directly from the del.icio.us web API. Its got method calls for everything in the del.icio.us API, namely:

  • Get posts by date - http://del.icio.us/api/posts/dates
  • Get tags - http://del.icio.us/api/tags/get
  • Get posts by tag/date - http://del.icio.us/api/posts/get
  • Get recent posts - http://del.icio.us/api/posts/recent
  • Get all posts - http://del.icio.us/api/posts/all
  • Add new post - http://del.icio.us/api/posts/add
  • Delete post - http://del.icio.us/api/posts/delete
  • Rename tag - http://del.icio.us/api/tags/rename

I use the PHP API to generate the list of link categories in the bottom navigation and all the links on the links page.

I needed to write three bits of code to get the links page to work as I wanted it to.

XHTML

This was probably the most difficult part. Trying to write perfectly semantic XHTML while still being able to manipulate it with both Javascript and CSS.

I decided to use DL’s for the list of links. The code looks something like this:

<dl class="closed" id="tag_auckland">
    <dt><a href="javascript://" onclick="changeState('tag_auckland')" title="1 links">auckland</a> <a name="tag_auckland">&nbsp;</a></dt>
    <dd><h4><a href="https://connect.aucklandcity.govt.nz/ePathway/0216/Web/default.aspx">Pay Fine</a> <small>[<a href="#top">top</a>]</small></h4></dd>
    <dd>Pay your parking fines in Auckland City online.</dd>
    <dd><small>Related tags: auckland new-zealand</small></dd>
</dl>

I don’t really know why I used DL’s…it may be because I’m totally in love with them at the moment. :) Nevertheless, the end result is totally what I was looking for.

javascript

I used a tiny bit of Javascript perform a sneaky little className change as you can see below:

<script type="text/javascript">
function changeState(this_obj) {
    var obj = document.getElementById(this_obj);
    if (obj.className == &#8216;closed&#8217;) {
        obj.className = &#8216;open&#8217;;
    }
    else if (obj.className == &#8216;open&#8217;) {
        obj.className = &#8216;closed&#8217;;
    }
}

</script>

The function takes the id reference of the HTML element and changes the className from either ‘open’ or ‘closes’ depending on the current className of that element.

CSS

The CSS is actually where all the magic happens. The mix of the Javascript and the below CSS allows for the dynamic showing and hiding of the links.

margin-left: 5px;
text-decoration: none;
clear:both;
background: URL(/images/plus.png) no-repeat 0 6px;
}

dl.closed dt a {
font-variant: small-caps;
font-family: Trebuchet MS;
font-weight: bold;
font-size: 140%;
color: #004675;
text-decoration: none;
padding-left: 15px;
margin: 0;
}

dl.open dt a {
font-variant: small-caps;
font-family: Trebuchet MS;
font-weight: bold;
font-size: 140%;
color: #004675;
padding-left: 15px;
text-decoration: none;
}

dl.closed dd {
display: none;
}

dl.open{
margin-left: 5px;
text-decoration: none;
clear:both;
background: URL(/images/minus.png) no-repeat 0 6px;
}

dl.open dd {
display: inherit;
margin-left: 5px;
}

dl.open dd small {
color: #7EA1B9;
}

dl.open dd h4 {
margin: 5px 0 5px 0;
font-size: 100%;
}

so…?

So now we have all the code we need to build a links page listed by tag name. There is just one more thing left to do…make del.icio.us happy.

‘How?’, you ask. Well, there is nothing del.icio.us hates more than getting its bandwidth raped so I decided to only run this script once every 6 hours. I added a line to the crontab to run the PHP code which then generates an include file (I’ve called mine delicious.inc) that I simply include into the links page of my site. Pretty cool, huh?

I’ve included a link to the PHP code I used. Download it, use it, make it better. Just remember where you got it! ;)

Download PHP file