2008-04-30 20:42Customising SerendipitySo, here we are in Serendipity Land, enjoying software that cares about security and stopping spam. One noticeable drawback is the lack of a built-in backup feature (although WordPress doesn’t any more either). My old system of manually performing a full backup after each post was, in retrospect, probably not the most efficient way to do things, though. I need to improve the backup system for the rest of my hosting anyway, so I will probably write my own backup script which integrates well with it. I imagine a system where my local machine triggers a new backup of my hosting provider’s database by requesting a hidden script file, and the backup it produces is a file inaccessible to the webserver but SSH-able to my local machine. Having a backup process is particularly important, however, for systems which you intend to use, and until I fixed the “No entries to print” bug, I didn’t think Serendipity counted as such a system. If you are reading this, though, that means I have successfully tamed the bug, and here is how I did it. I started in what some would say is the obvious place: index.php and found line 256 where the view key of the $serendipity array was set to To create a sort of minimal test case, I started the barely-usable PHP interactive mode on the command line and produced a session like this: preg_match("@/([0-9]+)[_-][0-9a-z.\_!;,\+-\%]*.html@i", "/~hagfish/blog/index.php?/archives/2008-02-29_78.html", $matches); echo $matches[1];
2008 What is going on here is that my file name format is Here you can define the relative URL structure beginning from your base URL to where entries may become available. You can use the variables %id%, %title%, %day%, %month%, %year% and any other characters. The quick solution was to simply change the format, which worked, confirming my diagnosis. As it turned out, I soon started to think about making the Serendipity install accessible at the URL of my old blog, and I realised that I could set up a mod_rewrite rule from URLs of the form
Finally came my favourite change, adding ISO validity to the dates. I was pleased to find a localisation file which lets the user specify locale-specific options (although doesn’t let the user specify separate locales for the strings and the date format), and for the en UTF-8 case the defaults are: Obviously I was happy with the short format, and experimented with some more verbose forms of it for the long format, but ended up just specifying the same format for both, to be the most compatible with international visitors and standards. Unfortunately, as with WordPress, there is no localisation option for the archive dates in the sidebar, and this information is burnt into the sidebar code. The first place I looked to fix this was the sidebar.tpl template file, but this made use of a $item.content variable whose definition was not easy to find. Turning to my trusty grep I looked for the sidebar text Older… and found the constant OLDER which in turn lead me to the file plugin_internal.inc.php. In the $ts_title = serendipity_formatTime("%B %Y", $ts, false);
on line 482 to: $ts_title = serendipity_formatTime("%Y-%m", $ts, false);
and that was that. But isn’t all the formatting of the article still wrong? And what about the syntax highlighting? And the abbreviations? Obviously there are some plugins I still need to install… |
QuicksearchCategoriesSyndicate This BlogBlog Administration |
Starting with the most dramatic problem, I am sad to say that the first time I went to visit my blog after installing it, I clicked on one of the “Continue reading” links and got the dreaded “No entries to print” message.
Tracked: Feb 26, 13:58