Arguments that don't work

I’ve come across several Smarty Tags that call WordPress functions that have listed arguments that don’t work. I didn’t bother too much about it - usually I can live with it. Then, I realised how I solved one instance of this happening: the Recent Comments plugin.

I downloaded the source to this, and looked at it. Besides there being some spelling mistakes, it had argument names which differed from the documented ones. No wonder it was failing when I tried to change the number of comments, and the comment length! So, looking at the code helped me solve the problem. Maybe it will with the other issues I have come across: most notably {previous_post_link} and {next_post_link}, and {edit_post_link}.

I’ll start with the {edit_post_link}. The codex says the argument I want to change is called text, but the source reveals it to be link. Changing this enabled me to change the text that is presented to whatever I want. The same goes for {edit_comment_link}.

I was originally using the tags {previous_post} and {next_post}, but was unable to change the previous post: next post: text that appeared. Changing the name of the argument from text to previous and next (as applicable) fixed this. Similarly, since {previous_post} and her sister are deprecated, {previous_post_link} has arguments that differ from those detailed in the Codex. The arguments it (and {next_post_link}) can handle are:
  • format - defaults to « %link. You need to have the %link where you want the URL to appear! You can add more stuff that you want to appear but not be part of the link itself.
  • link - defaults to %title. Add other text that you want to add into the link area.
  • in_same_cat
  • excluded_categories

Depending upon if you want an image clickable, you can either insert the code into the format or link argument. Just for fun, I included my favicon in the non-link section of the link text (ie, the format argument). I’ll leave it there for a while, just to prove it can be done…in the meantime, I’m going to fix the Codex.

NSLU2 Bootup

I noticed that for some reason some of the bits and pieces I had installed on my NSLU2 were not being restarted at boot time: notably dnsmasq, which is a Domain Name Server and DHCP server. I started using this just for fun, but found that after an NSLU2 reboot I wasn’t able to reconnect to the NSLU2. It turned out that for some reason the imac was being given a bizarre IP address, which wasn’t even on the same subnet as the NSLU2. In fact, IIRC, it wasn’t even a legal private domain IP address! Now, I have several things installed on the NSLU2: cron, inetd, portmap, appweb and dnsmasq. I had also installed mt-daapd at some stage. It turned out that mt-daapd was failing to load, and this was causing the script to bail out, without running the remainder of the items. I think. Moral of the story: ensure that you are only loading stuff you need, and that everything is running smoothly.

National Championships

I’ve spent the last week in Darwin, NT, coaching a team in the School Sport Australia National Touch Championships. This is my fourth year coaching the SASSSA 15s girls team, and I just thought I might share some thoughts on my experiences this time around. Coaching a junior girls team has plenty of it’s own challenges, but really this age group is my favourite. I couldn’t handle coaching a little bit younger: I see how much work the 12s coaches have to do just to get the players to take the field, and I certainly wouldn’t want to coach 15s boys. It’s nice that it **is **possible to get your players to comply with instructions. I had the experience this year of coaching some Mens teams: State League and then Mitchell Cup, and whilst I enjoyed it, I’m not about to stop coaching the 15s just yet. The tour began with a nice early plane flight to Darwin - we left Adelaide at around 7:30am on Sunday, after an early night before following the team (and parents) dinner. Obviously the girls were excited, and with only 3 second year players, I knew this was going to be a challenging tour - on the field at least. The other big change of this year was that the girls weren’t billeted. Instead, the 14 of them, plus the 14 boys, were all staying together, with 5 officials. Two coaches, two team managers and a tour manager. It meant we had to look after them each night every night, and couldn’t socialise with the officials from interstate to the extent we had in the past. Stepping off the plane into Darwin airport you already knew it was hot there. I’d tried to psych myself and the girls up for this, but unless you have been there you just cannot understand the climate. It doesn’t get below 25 C overnight, and is always 34 C during the day at this time of year. We had a light training session on the day of arrival, quite late in the afternoon, on the foreshore near the esplanade. Not quite enough room to train, but enough to get some idea of what the climate was going to do to us during a game. Rehydrate. The one word I would say more than any other during the week. Day one of competition brought us face to face with Queensland - who as it turned out would eventually go on to win the tournament. Now, for those a little unfamilar with Touch in Australia, it’s always Queensland v. New South Wales in the finals. No-one else really gets close, and it’s likely to stay that way for the forseeable future. When you compare a state like SA where no-one plays Touch that much, to a state where they all play Touch, there’s just no competition. So the result for the first game was a given. 18-0 in the end. Close to my worst result against them, but at least we kept them to 6 in the second half. The second game for the day was against Western Australia. In recent years WA have been quite strong, but their team was not quite up there this year. They still beat us 3-1, but we were competitive. Possibly my best result against the West. Day two had two very winnable games: Tasmania and NT, the home state. Both teams we beat last year, and comfortably too. Tassie up first, and we really looked the part. Unfortunately, they managed to outscore us, and we lost 3-2. A big break before the night game against NT, but it didn’t help us. The best NT team I’ve seen rolled over the top of us 10-0. One player short due to disciplinary reasons was not the deciding factor! The wednesday is a rest day, and this year we went to the Adelaide River, and saw the famous jumping crocodiles. Apparently our red shirts were distracting them, but they were still rather impressive. Especially stumpy.

Stumpy, the Jumping Croc

That night we had the officials dinner, and I had to give a speech. Ashley, our Tour Manager was receiving an award for 10 years (actually 12, but they forgot to award him the previous two years!) service. I loved how he started his speech:

I had prepared a speech for the previous two years, but didn’t bring one this year because I thought I wasn’t going to get the award this year either!

The most amusing thing was how Marie, who also received an award, started her speech (which, incidentally, preceded Ashley’s):

I wasn’t sure if I was going to receive an award this year, as I thought you had to do 12 years of service to get the 10 year award.

Do you notice the common thread? Day three of games, and the hardest day. A three game day, with Victoria, ACT and then New South Wales. Two games we should have won, and one I wasn’t even treating as a game. But again we struggled, only managing to hold a draw with Victoria, 2-2. ACT we looked all over them, but they managed to sneak a couple of touchdowns through our line, even though we held them up our end for nearly 95% of the game. In the first half, they only got down past their 10m line three times! And two of these were their run-through touchdowns! We managed only one, a great run from Mel. NSW up next, and we actually had to take this more seriously than I had planned, as it meant the difference between 7th and 8th, and games versus Tas or ACT in the finals. 7-0 in the first half, but we ran out of legs, and they finally ran over us 17-0. Still, we kept them to no scores for most of the second half, except the last two minutes when they ran in 10 quick ones. Or something like that! Finals on the friday, with a late start, and we played ACT first. Whether they were holding back int he round game, we really didn’t look competitive. 6-1, perhaps the largest difference I’ve had in an ACT game. Last year they managed to only beat us int he round game after the siren, but I’m yet to beat Toppies girls. Maybe next year. Last game of the tournament, and still yet to bag a win. It was the two winless teams, us and Vic, in the big 7th v 8th playoff. We looked to be all over them early in the game, but couldn’t manage to get the ball down over the line. Then, horror of horror, they got a couple of quick touchdowns. We continued to keep the ball up our end, and finally were rewarded with two ourselves. 2-2 at half time, and time to get pumped up. The game thus far had been rather hard, with Victoria being penalised 6 or so times for hard touches, and us none. Yet still the referees warned us of being sent if we infringed! Surely after 6 hard touches in the first half they might have sent one of their players, but alas. No juice. I warned the girls to be careful, and to their credit they were. Late in the second half, after a hard-fought game, Des, our captain, received a penalty around our defensive 10m line. A quick tap, and she was through their line, running hard for the scoreline. She made it, and we led for the first time that game - possibly the first time in the tournament. We managed to hold them out for the rest of the game: no mean feat considering we were down to 12 players, missing our best performing winger; and one of the key playmakers and vice captain. But, the game was ours. The sweet taste of beating Victoria. I was concerned the kids would play up a bit on the last night: we no longer had the stick of missing a game to hold over them, but they were pretty good. I stayed up pretty late, but noone even looked like sneaking out of their rooms. The flight back was routine - Fever Pitch was apparently remade recently starring Drew Barrymore and about the Red Sox, not Arsenal, but it was still a good film. Lots of the girls were pretty emotional at the airport - I even received a group hug from all of them as I prepared to leave. I wonder if they were just a more emotional bunch than I have taken away - perhaps that’s why they didn’t perform as well until I really pumped them up before and during the last game. Or perhaps having them stay together and with us helped us all create stronger relationships. Maybe looking after them wasn’t so bad after all.

No Posts = No Visits

I have noticed that my post hit count dropped off dramatically in the past week, when not posting any new entries. Hint for new players: post often if you want people to keep reading…

Back from Darwin

For anyone who noticed, I’ve been out of town for a little over a week. I’ve got a couple of posts to write: one about why I was away. I’ll get onto them soon. This is just a post to let you know I’m still alive, and will return you to your regular service soon…

Export Playlist(s)

I’m still kinda bummed out over how long it takes to scan through all of the playlists in iTunes and grab the details of each song, and write it all out to a file. I’m talking about Smart Playlists here, since it would be a trivial exercise to just grab the songs from the XML file that iTunes so nicely provides for normal playlists. Since I don’t use normal playlists (except when looking for missing album art - darn iTunes’s inability to search on missing artwork!), Bery Rinaldo’s Export Playlist to M3U didn’t necessarily do what I am doing any better.

But, I did pinch some ideas from him - the first was a snippet on how to get the name of the currently selected playlist:

tell application "iTunes"
    if (class of front window is browser window) or (class of front window is playlist window) then
        get name of view of window 1	
    end if
end tell

The second I haven’t implemented yet, is having settings, and a setup wizard.

Anyway, the updated version is Export Playlists.scpt, put it in ~/Library/iTunes/Scripts (User only) or /Library/iTunes/Scripts (System-wide).

OSX Application Startup Issues

I upgraded to iTunes 5, and also ran the latest Panther Security/System upgrade, and now my Finder, iTunes, and a couple of other random applications take ages (like about 5 minutes) to load. One of the programs that took a long time to load (and appeared to hang) was Quicktime Player: I traced this issue down to a dodgy QuickTimeStreaming.component bundle: I’ve moved it out of the /System/Library/Quicktime folder, and now Quicktime starts up super fast. I have tried the following techniques:

  • Repairing permissions. Apparently iTunes did have a file with dodgy permissions, but this wasn’t what was causing the slow loading.
  • Updated executable library prebindings. This did make every other app load much faster.
  • Cleaned the system and application caches. Again, other apps load faster.
  • Remove a heap of potential Finder problem cache files. I suspect that most of these were deleted by the above step, but I tried it again anyway. No joy.

I’m about to upgrade to Tiger anyway, so I’ll just backup everything and do that, I think.

Blogsome Gravatars

Note: this post is now out of date. Go to Gravatars in Blogsome instead. I did get Gravatars working in Blogsome to some extent a while ago, but it exposed the email addresses. What I’ve done now is obscure the email addresses, and it should be safe to use: <script type="text/javascript"> {capture name=reader}{comment_author_email}{/capture} var ob_email = "{$smarty.capture.reader|replace:'@':';'}"; var email = ob_email.replace(/;/g,"@"); document.write('<div class="right"><img src="http://www.gravatar.com/avatar.php?gravatar_id='); document.write(hex_md5(email)); document.write('&size;=50" /><\/div>'); </script> Basically, it grabs the Commenter’s email address, and changes it in Smarty from email@domain.com to email;domain.com - then JavaScript is used to change it back before passing to the hex_md5(); function. You will need to have the following code inserted in your template somewhere before this: <script type="text/javascript" src="/images/md5.jpg"></script> And the file md5.jpg stored on your server, or the following line (using the copy on my server): <script type="text/javascript" src="http://schinckel.net/images/md5.jpg"></script> If you download my version, clicking on the links won’t work: you’ll need to right-click and choose Save…

Comment Preview for Blogsome!

I’ve implemented Comment Previewing from Blogsome blogs. There is no way to install 3rd party plugins in WordPress MultiUser, so everything has to be done in JavaScript. But really, the plugin is just JavaScript packaged up nice anyway. You need four code fragments, all in your comments.html file. The first one I suggest goes after the line: {if 'open' == $post->comment_status} Because it is a JavaScript that uses { and }, you need to remember the {literal} tags. {literal}<script type="text/javascript"> <!-- function ReloadTextDiv() { var UseInstantPreview = document.getElementById("use_instant_preview").checked; if( UseInstantPreview == true ) { var NewText = document.getElementById("comment").value; splitText = NewText.split(/\n/).join("<br />"); var DivElement = document.getElementById("commentpreview"); DivElement.innerHTML = splitText; } } // --> </script>{/literal} It probably doesn’t matter exactly where it goes, but having it after the {if} clause means it will only be included in the file if comments are open. The second code fragment is: onkeyup="ReloadTextDiv();" And it goes in the <textarea id=comment> tag. In context, mine is: <textarea name="comment" id="comment" cols="60" rows="12" tabindex="4" onkeyup="ReloadTextDiv();"></textarea> The third fragment is the checkbox for enabling or disabling Comment Preview. It can go wherever looks good. <input onclick='ReloadTextDiv();' name="use_instant_preview" type="checkbox" id="use_instant_preview" value="1" checked /> <label for='use_instant_preview'>Use Instant Preview</label> The final fragment tells the browser where the Comment Preview goes: <div><p id="commentpreview"></p></div> And it goes where you want the Comment Preview to actually go. I suggest just after the Submit button, or other instructions. Righto, all of that in there, and it should work. You may need to add an entry to your Site Style Sheet to make the Comment Preview box look the same as your actual comments box. • If you wanted to, you can also have a Preview button that will preview what is in the text area then, rather than having Live Preview. This is good for a couple of reasons: I find that long comments slow down when trying to update every keypress. The big problem is that you cannot have a normal input field inside the form set to do this, it will just try to submit it (or at least, mine did!). So, I’ve replaced my input tags in my form with the following (You may need to insert name='commentform' into the form start tag.): <a class='button' href='javascript:document.commentform.submit();'> Post Reply </a> <a class='button' href='javascript:ForceReloadTextDiv();'> Preview </a> You’ll also need to add the following in just after the ReloadTextDiv function definition: function ForceReloadTextDiv() { var NewText = document.getElementById("comment").value; splitText = NewText.split(/\n/).join(" "); var DivElement = document.getElementById("commentpreview"); DivElement.innerHTML = splitText; }

Quicktags for Comments

Note: The seperate Quicktags toolbar is not supported. Please use the full toolbox script, or hack it any way you like. The remainder of this post remains for posterity only.

This was easier than I thought.  Alex King has done most of the work by having the Quicktags info already in a JavaScript file. I just grabbed my copy of the file (from /wp-admin/quicktags.js) and tweaked it.  To upload to the Blogsome server I had to call it quicktags.jpg, but that is allowed, since you tell the browser explicitly that it is a text/javascript file. So, you can get my quicktags.js file (Right-click and download it!), and upload it to your server, and use the following code in your comments.html. Where you want the toolbar to appear, insert this:

    <script src="/images/quicktags.jpg" type="text/javascript"></script> 
    <script type="text/javascript">edToolbar();</script> 

After the <textarea>, insert the following code:

    <script type="text/javascript"> 
        <!-- edCanvas = document.getElementById('comment'); //--> 
    </script>

Note: you may need to chage the argument of getElementById to whatever your textarea id is. I’ve also tweaked the JavaScript file so it includes abbr, acronym and strike tags, and doesn’t include the tags that aren’t valid for comments.  And I’ve added a button for inserting < and >, but I’m not totally happy with this.  If anyone wants to edit it so it works better (try it out to see what I mean), then feel free.

I’ve also created another version that uses links instead of buttons (since Camino doesn’t render buttons with style, only as Mac-buttons), but it’s not quite as nice: the labels don’t update. Still, if anyone wants to play around with it, you can get it here. Remember to right-click and download it, it’s not really an image!

Next task: Live Preview.