Archive for May, 2005

Ye olde man cometh

Thursday, May 26th, 2005

It’s official. At the ripe age of 27 I am old. My wife found a grey hair growing on my head today. Soon I will have a head full of white hair, slippers and excessive nose and ear hair cannot be far away.

Patio, check!

Wednesday, May 18th, 2005

It is now the end of a long weekend here in Denmark (technically, only Monday was a holiday, but bear with me). As I mentioned – when I complained about the gravel, sand, and tiles – this weekend would be spend laying our new patio, as well as all the groundwork needed.

(more…)

International Characters in Textile 2 (Improved)

Wednesday, May 18th, 2005

Recently, I received a comment on the Super Archives about the lack of support for international characters in the implementation. Being a dane I should of course have caught this, but I guess I write too little of my native language.

The comment, however, tipped me off to a problem with both the live preview and the Textile 2 (Improved) plugin. The problem with the live preview was in the Javascript and has been corrected by Jeff Minard, while I haven’t been able to contact Adam Gessaman who’s responsible for the textile plugin (for some reason I can’t leave comments on his blog).

Anyway, for the rest of you who also use the Textile 2 (Improved) plugin I have here included the corrections needed for international character support (this also includes characters like ‘ and – ).

Changes

Change line 2721 from


$html = htmlentities($html);

to


$html = htmlentities($html, ENT_NOQUOTES, $this->options['char_encoding']);

This makes sure the character encoding is taken into account when converting characters to their relevant HTML entities. The default character encoding for the plugin is utf-8 (see below).

Optionally, change line 37 from


$textile->options['char_encoding'] = 'utf-8';

to


$textile->options['char_encoding'] = get_bloginfo('charset');

This is only necessary if you use a character encoding on your blog which is different from utf-8 (not likely, but could happen).

Music Baton

Tuesday, May 17th, 2005

Joen and six hours later Chris passed me the musical baton which I guess I’ll try to pass on.

Total volume of music files on my computer:

4.11 GB, 1073 songs, 2 days 22 hours.

The last CD I bought was:

Kent – B-Sidor 95-00

Song playing right now:

Safri-Duo – Played-A-Live (The Bongo Song)

Five songs I listen to a lot, or that mean a lot to me:

Kent – Dom Andra
Rammstein – Moskau
Linkin Park – Faint
Smash Mouth – Walking on the Sun
3 Doors Down – Kryptonite

Five people to whom I’m passing the baton:

Susan (of course)
Maria

and then I’m in a bind, I was going to say Joen, Chris, and Michael, but they’ve all been batoned up.

I guess I’ll live with two.

Gardening

Thursday, May 12th, 2005

When I talked about our new gate I neglegted to mention that we would also “get” a new terrace. We will of course have to do all the work ourselves (helped by my parents). Today was the day we were getting the tiles, gravel, and sand. My mom had said they would come sometime late morning, so I had set my alarm clock for 8 am. I was woken up by the phone at 7.40.

I got up and went to get ready for the arrival of the gravel. Before that happened, however, the truck with the tiles showed up (he was also supposed to call before he came, but nevermind that). There is a path with a wide green area behind our apartment building where people often get stuff for terraces delivered, and I had planned for that too. What I didn’t plan on, however, was that the truck with the tiles was 10 cm too wide for the opening to this path. The tiles were dumped just inside the path, and of course the gravel truck couldn’t get any further in and dump his gravel. After they left I had 5 m^3^ of gravel, 3 m^3^ sand, and 840 tiles lying 100 meters from where I thought I would have them.

I spent the next 10 hours moving the tiles and gravel in a job which would be fit for the military: “You take this pile of gravel and move it over there”. A man was kind enough to let me know that the 8 m^3^ of “dirt” was approximately 75 full wheel barrows. Having done my first 45 today (plus the 30 something for the tiles) I am thoroughly beat.

If anyone wants to come over and help me friday or saturday with the remaining gravel, sand, and the dirt I have to remove from our garden as it is now, be sure to let me know, I am not sure my body will forgive me for another two days of this hard work.

Where was I again?

Wednesday, May 11th, 2005

I visited a site sometime Sunday or Monday and thought: Hey, this is cool, I should remember this. Now, however, I have no clue what the site was. I don’t know if you ever do that, but it seems to be happening with increasing frequency for me.

If you’re interested in helping me find this site I will provide what I can remember below.

I am pretty sure it was a blog entry, but I don’t remember the main subject of the entry. If I had I might even associate to the place I found it, but alas. The reason I wanted to find the entry again was some of what came further down. The author described some “trends” he would warn us as readers that we would see more of in the coming year. Of the things I remember were: Starbursts, big buttons, and plastic look on buttons or menu “bars”. If you have any idea which entry this might be, please leave a comment.

Help needed with the javascript event model in Internet Explorer

Monday, May 9th, 2005

My Super Archive plugin is quite dependent on javascript and uses XMLHttpRequests to fetch the lists that make up the live archive. For each item in the list of years and list of months a function is attached, to run when the item is clicked. In Mozilla based browsers and Safari this is done using the W3C event model and the function addEventListener(), in Internet Explorer I use the attachEvent() functions. So far so good. To find out which item was clicked I rely on the current event being passed into the attached function. This is appearantly part of the W3C event model, and doesn’t work in Internet Explorer, and that is where I’m stumped.

Question: How do I figure out which item was clicked in Internet Explorer, for several items having onclick events attached using attachEvent()?

Super Archives Plugin for WordPress

Sunday, May 8th, 2005

Comments have been closed as the plugin has not been updated almost forever. I would refer people to the Extended Live Archive which is the Super Archives with extra features.

As I mentioned earlier I had problems with javascripts interfering with each other while loading. While I sorted out my problems with regards to the javascript, the reason why I was playing around with javascripts has already been leaked, and by none other than Michael Heilemann of Binary Bonsai. Since this is inspired by his ideas I guess it’s only fair.

Introduction overwith, I hereby give you: The Engineered Boulderer’s Super Archives Plugin to WordPress

For a demonstration, head over to Michael’s archives page, I am going to put it on my archives page, but it requires a minor redesign before I do.

IMPORTANT The javascript functions in my script have been tested, however, if there are other function set to run when the body loads, and they have problems then the super archive Will Not Run. The process of debugging javascripts is arduous work as they simply fail silently, because of this I do not have time to perform technical support on other people’s javascripts. That said, if Michael could get Super Archives to run on the B with the combination of javascripts he uses, then you can too.

I have included some documentation below, and in the plugin package.

Changelog

Version 1.6.2: Fixed a bug where draft posts in a month would make it show up in the list of months, thanks for the heads up Matthew. Requires a rebuild of the cache (edit a post or post a comment to rebuild).

Version 1.6.1: Fixed a regression which would prevent the php script from reading the settings and cache.

Introduced a more robust Javascript method of attaching events to the loading of the window.

Version 1.6: Fetches the character set from the blog to show international characters correctly.

New functionality for truncating post titles, see documentation below or with the plugin.

Version 1.5.2: Added a missing " in the description. Check the result from each use of document.getElementById() so as to not call null objects.

Version 1.5.1: Put a more stringent check on the FAT object for the Fade Anything Technique.

Version 1.5: Fixed bug where moderated comments were counted. Also, made sure cache was updated for new comments, and post deletions, and pingbacks, etc.

Updated cache structure so the cache can update (for example due to a new comment) while people are browsing the archives without requiring a reload (the plugin should automatically update your cache if you are using an old version).

Included new functionality, see the documentation included below or with the plugin.

Version 1.2: Implements support for Internet Explorer. Many thanks to Chris Boulton for his solution which worked wonders.

Version 1.1: Fixed a bug in the javascript (simple typo, oops).

System Requirements

  • Wordpress 1.5 or later
  • PHP 4.3.0 or later
(more…)

Problems with the (Real) Live Textile Formatting

Saturday, May 7th, 2005

As I mentioned earlier I implemented the (Real) Live Textile Formatting (RLTF) to enable comment previews. I thought all was honky-dory until I tried working with some hefty javascript which was also initialized by the onload function of the body. My javascript initialize function was set to be called after the RLTF initialization, and it wouldn’t get called. A day and a half of debugging and I found the error which was in the javascript for the RLTF.

The RLTF is initialized by the liveReqInit function. In this function the “key down” (or whatever browser dependent) event is assigned to the “search field” using the addEventListener function. The problem occurs on a page where the search field doesn’t exist. The element is found using getElementById which returns null when the element doesn’t exist on the page, and the addEventListener is therefore called on a null object causing the javascript to crash. The crash means the chain of functions for the body onload will abort.

One solution is to check that the search field exists on the page. I do this by inserting the following code at the beginning of the liveReqInit:


	var searchElement = document.getElementById(searchFieldId);
	if( searchElement == null ) return;

Similarly, we should check that the result field exist by inserting


	var resultElement = document.getElementById(resultFieldId);
	if( resultElement == null ) return;

before if(emptyString == '') { near the end of the function.

I hope my headaches will prevent some for others.

Word Count Plugin for WordPress

Friday, May 6th, 2005

Inspired by Chris’ discovery of odd behavior in the wp-word-count plugin I set out to create a version which would not be cheated by occurrences of the word “img” in an entry. I am a coder and web-developer myself and could see myself writing snippets of HTML in my posts.

The solution I found was to run the relevant filters on the content, after I get it back from the database. Using the function apply_filters I was left with a chunk of real HTML. I could strip the tags of this HTML to count the words, and search the HTML for occurences of the <img ... /> tag by searching for the string “<img”.

So there you have it: The Engineered Boulderer’s Word Count Plugin.

Changelog

Version 1.1: Does not count wordpress included smilies as images. Added an argument to allow the plugin to count smilies as images.

Version 1.2: Corrected a bug in the implementation of version 1.1

Documentation

The template function the plugin provides is teb_word_count(display) which accepts two arguments.

display
(boolean) sets whether the function should display the number of words and images, or if it should return them.

  • true (default)
  • false

count_smilies
(boolean) set whether smilies should be counted as images. If false, the plugin will simply disregard smilies (neither count them as text, nor images).

  • true
  • false (default)

Disclaimer: This plugin has been tested to work on my test blog and here, but it could break in real life. If you see any problems with my implementation be sure to let me know.