well I think it's shiny

May 16, 2005 12:17

I'm too lazy to put up a notice every time I update www.jerith.net, especially since I haven't gotten around to putting a news interface type thingy up there yet. Anyways, I was fixing/updating a couple of things when it suddenly hit me: why not automate the thing?

A quick dig around the php manuals and I came up with the following function:

function isNew($url) {
if (filemtime($url)) {
if (time() - filemtime($url) < 604800) {
// 604800 secs in a week
return true;
}
}
return false;
}This basically compares the "last modified" time to the current system time and draws a star if it's less than a week old. This is called in the menu generation code, so it only looks at the main page, not anything that might be included. Thus, I still have to remember to touch phpmenucode.php if the menu generating code changes. Still, it's better than nothing.

Simple, but shiny. And now I can be lazy while still letting people know that something's new.

website, code

Previous post Next post
Up