Timestamps in Blosxom
March 09, 2005.    

On its own Blosxom uses the "last modified" information from your entry files (here after called entry.txt file for clarity) to figure out what date to use when rendering your blog. This works perfectly well for most people most of the time, but if you go back and fix a spelling error on a month old entry.txt file you'll notice it pops back to the top as if it were brand new. Another problem can be if you are moving from one hosting provider to another; a direct copy can change the "last modified" tag to the moment you copy the entry.txt files. This article attempts to address a few methods you can use to fix this problem drawing from a recent discussion on the MailingList and my own observations.


One method, used here on the UNBLUG, is the entriescache plugin by Fletcher Penney. It creates a cache file that lists all of your entry.txt files and associates a time stamp with each file. Blosxom uses this file's time stamps to determine what date to use when rendering your site. You can also add a meta tag in your file to specify the time yourself. As an added bonus you can have entriescache write the meta time stamp into your file if Blosxom has write access to the entry.txt files.

Another plugin similar to entriescache is entries_cache_meta by Jason Thaxter. They work, more or less, the same. I highlight entriescache simply because it's what I am familiar with; try them both and see which one you like best!

In addition you can use the *nix touch command to change the date for your entry.txt. This command:

touch -t 200503091430 myfile
Where the long string of numbers is year, month, day, hour and minute (YYYYMMDDHHMM).

If you are moving files from one server to another there are some other measures you can take to insure time stamps remain true.

Highly recommended is archiving your $datadir using .tar, .zip, or .sit compression. You can use the command line on most unix/linux systems to tar your files, or programs like WinZip or Stuffit to create zip or sit files. Compressing the files maintains time stamps and can all insure the integrity of the files in transfer.

Using either of the previously mentioned plugins you can then use the created cache files to enforce the caches time stamp. Before starting the transfer make sure your cache file is current by reindexing your site. At the new location you may have to edit your cache file with the correct absolute path. I would recommend using a simple find and replace to edit the file quickly and efficiently.

Others recommend using the command line tools rsynch or scp (with the -p flag) to move your files, both of which should maintain the correct time stamp.

There are many other methods of saving the time stamps, like using Stu MacKenzie's permtimez plugin, which cements the time stamp in the name of your entry.txt file. If you've got more ideas, throw them in the comments!

Many ideas for this article were lifted from the MailingList. Many thanks to Frank Hecker, t.whid, Dana Hudes, Ken Ross, and Bahrpfeife.

Click the button to

 

t.whid wrote
2005/3/9 08:50:15
using entriescache
This method is good for folks who don't have SSH/telnet/shell access to their site (many hosts restrict this). So if you only have (s)FTP access, this is a fairly simple way to go. I described the process I used here: http://groups.yahoo.com/group/blosxom/message/10305
Douglas Nerad wrote
2005/3/9 13:55:48
cache_timestamps
Another plugin was mentioned on the list today that I'd never heard of called cache_timestamps. You can read about it here:

http://svana.org/sjh/diary/2004/10/28#2004-10-28_02

It seems, upon a quick cursory glance, to be similar to the other plugins mentioned in the article. Both files are now hosted locally, too (the plugin in the v2 registry and the .pl file in the files registry).

Luddite Geek wrote
2007/8/8 11:19:48

Isn't it possible to write a Perl script to touch a given file using the utime() function? This would be for users who have only FTP access to the web server. You could invoke it like this: http://MyBlog.com/mytouch?f=myfile&?t=2007-04-15
douglas.nerad wrote
2007/8/11 01:23:31
Absolutely!
It would definitely be possible to write a Perl script to "touch" files. There are loads of plugins that will take care of much of the difficulty, though. What might be nifty would be to write the Perl script you're describing with a web interface; could have other applications...