Bitten by browser caching

Written in the wee hours in English • Tags: , ,

Aaarrrggghh!

I ended up writing the bottom half of the previous article three times, thanks to not having been careful enough when upgrading WordPress. I had lost my fixes that send out the necessary headers to prevent the admin pages from being cached. I guess others don’t get bit by this because they don’t have ExpiresActive enabled on their web server.

Anyway, I’ve saved the changes in a patch file now, for future reference…

Export WordPress links as XBEL

Written in the wee hours in English • Tags: , ,

I wanted to see if I could have my WordPress links in the Firefox Bookmarks menu. I thought this should be possible, since it knows about RSS. From using reBlog I had learned about FeedCreator, which is a great package for quickly creating feeds. So I enhanced wp-links to support feeds.

However, I was to be disappointed — the links are in Firefox now, but they are all piled up together in a single huge menu. In the WordPress database the links are categorized, as can be seen on my links page. I was hoping Firefox would use the categories to create more subfolders.

I thought about another approach: XBEL. The format is simple enough to follow, so I added XBEL support to FeedCreator 1.7.2. This works perfectly with the Bookmarks Synchronizer plugin for Firefox. I’ve configured it to download a single subdirectory inside Bookmarks, and all my WordPress link categories show up as subdirectories inside it.

I’ve made some sample code available to show how I’m calling wp-links. The code won’t run as-is, as it calls some other libraries I’m using. It should be simple enough, though, to remove (or ignore) the “extra” stuff.

Paged browsing with WordPress

Written late at night in English • Tags:

I really like WordPress!

I had made some tweaks (e.g. setting the charset in Content-Type headers) and hadn’t really heard back on my emails to the developers. This made me a little worried about upgrading the code on my site. As I run code from CVS as opposed to a release, there might be major issues after running cvs update.

As it turns out, there were some conflicts, but they were mostly mechanical differences around the Content-Type header. One or two were related to patches I’ve written about before, but nothing major.

Since I hadn’t really thought about what the procedure would be, here’s a quick outline for any other “daredevils” diving into it:

  1. Fix any conflicts reported by cvs.
  2. Goto http://yoursite.example.com/wp/readme.html
  3. Click on the link in the “Upgrading” section (…/wp-admin/upgrade.php)
  4. Goto the admin section and enable any plugins you were using. (Oh, yes, you could make a note of them before you start the whole process…)
  5. If you use a custom URL scheme, cut & paste the .htaccess rules again — there are new rules to be added.
  6. Update your custom index.php (if you have one) by looking at the index.php from CVS.

In that last step you can also add calls to posts_nav_link() to enable paged browsing. This is a really great feature: no more huge pages when browsing a category. Also, from the index page it is now possible to browse entries as far back as you want, one nice size page at a time.

Since my blog is rather small, I had not worried about this until recently, and here is the solution already. Perfect!

Play nice with Markdown

Written early in the evening in English • Tags: , , ,

I’ve created a couple of small patches to improve how WordPress works with Markdown:

  • markdown-balancetags.diff

    The balanceTags function was preventing the Markdown autotags feature from working by thinking <http://server/page> is actually some sorf of an http tag. I didn’t want to completely disable balanceTags, so I added code to pass through http, https and ftp “tags” untouched.

  • markdown-first.diff

    The wptexturize function must be called after Markdown to avoid unwanted “texturizing” of preformatted and code blocks. The fix was easy once I learned that filters have priorities. The default priority is 10, so I modified markdown.php to install itself at priority 8.

I’m beginning to think I should import WordPress to my local CVS repository.

wp-links

Written late in the morning in English • Tags: ,

Storing links in a database is an excellent idea. Storing links in multiple databases is not. To avoid having links all over the place to manage, I wrote wp-links.php for accessing the links table in the WordPress database. The idea is to be able to get lists of links as a “standalone” feature on pages that are not using WordPress, while still being able to manage the links through WordPress as well as use the links on the journal pages. (more…)

WordPress character set fixes

Written at evening time in English • Tags: , , ,

PHP (or possibly Apache itself) inserts a default charset= field in the Content-Type: header. This can cause problems with the syndication feeds, if you are not using the exact same character set on your blog. In my case the character set I use on this site is iso-8859-15 while the default that shows up is iso-8859-1.

I modified wp-rss2.php to return the character set specified in the WordPress options, and then went through other files to apply the same change. You can download the full patch that should apply cleanly to WordPress 1.2.

WordPress formatting filters

Written at lunch time in English • Tags: , , ,

I think WordPress needs dedicated filters to be applied on content and excerpt immediately when they are retrieved from the database, to be used by formatting filters such as Markdown.

I like Markdown, but I was having problems with how WordPress does not pass the complete article to it when the “more tag” is used, and when forming RSS descriptions. Markdown uses shorthand link tags that would normally be resolved with references placed at the end of the document. With the truncation, links were not being resolved, and what’s worse, Markdown notation was left in the resulting display.

I created a patch that fixes the problem for my current articles. However, I think multipage entries would still have this problem, so this patch is not sufficient. Also, I’m not sure if I’m causing undesirable side-effects by moving the the_excerpt filter further up in the code.

Before I start working on the filters to be applied on database retrieval, I’m waiting to hear back from WordPress developers about the approach, to avoid wasted work.