Hosting Scripts on Blogsome

Blogsome is great. You can blog, upload up to 25Mb of images, but unfortunately, you can’t upload your own JavaScripts and use them from the Blogsome server. Or can you? It is actually possible to host a JavaScript on your Blogsome blog, you just need to be a bit tricky. If you have a script called myscript.js, and you try to Upload it using the standard Upload menu item, it will fail. Blogsome only allows files with the extensions .jpg, .gif and .png. Note well that they do not need to be that type of file, but only have that extension. I think you know what I’m going to do next, and that’s rename my file to myscript.js.jpg: leaving in the .js reminds me that this is a JavaScript file, and the .jpg allows me to upload it. Which I did. When you include the script in your template, all you need to use is: <script type="text/javascript" src="/images/myscript.js.jpg"></script> Browsers are smart enough to allow this to happen.

Coffee Physics

rentzsch.com: I don’t understand Coffee Physics

Fresh hot coffee: yum. ** Day old coffee:** yuck. Cold coffee (day-old coffee that’s been stuck in the fridge): yum.

I’ve noticed this too: but even more so, if I brew some fresh coffee, it’s great. If I brew it, pour it over ice and put fresh cold milk in there, it’s great. If I put it in a thermos flask, and drink it two hours later, it’s still nice and hot, but no longer nice.

Stripper Light Poles

Boing Boing: In trompe l’oeil stripper ads, lampposts are strip poles In trompe l’oeil stripper ads, lampposts are strip poles Strip Club Pole Position: the cool hunter

Multi-line Tooltips

Firefox doesn’t display Title Tooltips very well. If they are too long, it just truncates them: Display of Tooltips (href title attribute) under Firefox Camino does a much better job: Display of Tooltips (href title attribute) under Camino So does Safari: Display of Tooltips (href title attribute) under Safari However, using the Popup ALT Attributes extension, you can get something a little better: Display of Tooltips (href title attribute) under Firefox, with extension installed. I’ll have a fiddle with the source code, and see if I can get it to break on commas, like the other X browsers do. Opera has a slightly different view of what should be happening. At least they are multi-line, but all of the commas have been removed! And the tooltip is rather wide, on my screen: Display of Tooltips (href title attribute) under Opera Internet Explorer (Windows) displays them as: Display of Tooltips (href title attribute) under Internet Explorer (Windows) Out of all of these, I like the way Safari and Camino display tooltips, especially in this case, where the list items are in fact seperate posts, and should be displayed on a seperate line.

999 Forum Posts

I just noticed I’ve written 999 posts on the Blogsome Forums: Whoa, that’s a lot of helping! (And a little bit of telling off, too!) And in less than one year!

DeLonghi Espresso Machine Faulty

For Christmas, we bought a DeLonghi Metropolis Espresso machine. I’m pretty happy with the quality of coffee it makes, however it seems to have developed a pretty major fault, since I last used it. The machine has two thermostats, one for heating the plate to the right temperature for brewing coffee, the other for heating to the right temperature for frothing milk. The coffee thermostat seems to be broken, so the machine will not heat up when it’s just in ‘coffee’ mode. I can get the machine to heat up by flicking the switch ‘frothing’ mode, but then I need to be there to turn it off as it gets to the right temperature. I’ll have to get this fixed. The machine is only three months old, and I’ve been taking very good care of it! I’ve sent off an email to DeLonghi customer service. It will be interesting to see how they respond to email.

First Comment Spam in Ages

Well, I got a Comment Spam tonight, and as the title indicates, it’s the first Comment Spam I’ve had since I implemented my Captcha. I know it’s a Comment, not a Trackback, as I have code that discriminates between the two. If I continue to get them, I’ll have to either modify my Comment Spam protection, or look into using the Blogsome one, which I don’t really want to do, as it doesn’t ‘look’ like my site when the page is loaded.

iTunes Random Songs

Here I am listening to iTunes on Party Shuffle, and on comes:

If You Have A Cross To Bear You May As Well Use It As A CrutchMolokoThings To Make And Do ★★

Hang on a bit! I heard this song earlier today. Let’s see when: That selected track is the one I’m listening to, and I last heard it at 12:27pm today. I thought so! And, as you can see, I stopped listening to music at around 2 pm. So, I must have only listened to it about a dozen tracks ago! Okay, so I’m using my Party Shuffle, maybe I’ve only got a small Playlist I’m selecting from. Nope. 6088 tracks. Hang on, I’ve got a playlist showing my Recently Played tracks. Morcheeba has finished now, but I can see how many tracks ago it was since I know the time it played. I heard the same track 25 tracks ago. That means when it first played, it was added immediately to the Party Shuffle again. I’ve read about the randomness of iTunes, but I still love it when something like this happens!

Starfuckers, Inc.Nine Inch NailsTriple J Hottest 100 - Volume 7 ½

Edit/Delete Comment

At times, it’s annoying to have to go into the Dashboard, just to delete a Comment that has appeared, or to Edit a comment I have made (or fix the text of someone else’s comment). Luckily, you can create links or buttons to allow you to do these two jobs while viewing a Post page: ✍ Edit ✗ Delete In your Comments.html template, find the location you want to put the links. To just have the Edit Comment link (you can delete a comment from it’s editing page), insert the following:

    {edit_comment_link}

To have both an Edit and a Delete link, try the following:

    {capture name=edit_comment}{edit_comment_link link="&#9997; Edit"}{/capture}
    {if $smarty.capture.edit_comment != ""}
        {$smarty.capture.edit_comment}
        <a href="http://schinckel.net/wp-admin/post.php?action=confirmdeletecomment&comment={comment_ID}">Delete</a>
    {/if}

I have mine all nicely styled, using the following (and some CSS):

    {capture name=edit_comment}{edit_comment_link link="&#9997; Edit" before='<span class="button">' after="</span>"}{/capture}
    {if $smarty.capture.edit_comment != ""}
        <div class="right">
            {$smarty.capture.edit_comment}
            <span class="button"><a href="http://schinckel.net/wp-admin/post.php?action=confirmdeletecomment&comment={comment_ID}">&#10007; Delete</a></span>
        </div>
    {/if}

Displaying Comments awaiting Moderation

It’s a neato feature to be able to show a reader the comment they have just posted, but which is awaiting moderation before it it displayed to everyone else. Newer versions of Wordpress can do this, and many templates also have this feature built in, but it does not work on Blogsome. The code that grabs the Comment data is found, in Blogsome, in wp-inst/wp-comments.php:

        $query = "SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date";
        $comments = $wpdb->get_results( $query );

This code was fairly easy to find, but the equivalent code in Wordpress was a bit tricker. Eventually, I found it in wp-includes/comment-functions.php:

        if ( is_single() || is_page() || $withcomments ) :
            $req = get_settings('require_name_email');
            $comment_author = isset($_COOKIE['comment_author_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_'.COOKIEHASH])) : '';
            $comment_author_email = isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_email_'.COOKIEHASH])) : '';
            $comment_author_url = isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_url_'.COOKIEHASH])) : '';
        if ( empty($comment_author) ) {
            $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date");
        } else {
            $author_db = addslashes($comment_author);
            $email_db  = addslashes($comment_author_email);
            $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND ( comment_approved = '1' OR ( comment_author = '$author_db' AND comment_author_email = '$email_db' AND comment_approved = '0' ) ) ORDER BY comment_date");
        }

I had to modify the code somewhat, but here is the code I have put on the private Blogsome test server:

        $comment_author = isset($_COOKIE['comment_author_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_'.COOKIEHASH])) : '';
        $comment_author_email = isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_email_'.COOKIEHASH])) : '';
        $author_db = addslashes($comment_author);
        $email_db  = addslashes($comment_author_email);
        if ( empty($comment_author) ) {
            $query = "SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date";
            $comments = $wpdb->get_results( $query );
        } else {
            $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND ( comment_approved = '1' OR ( comment_author = '$author_db' AND comment_author_email = '$email_db' AND comment_approved = '0' ) ) ORDER BY comment_date");
            $comments = $wpdb->get_results( $query );
        }

It could probably be tweaked (for instance, moving the addslashes() calls to within the else block would save a couple of CPU cycles when no author is set), but it works!. You need to have the following in your Comments Template:

    {if $comment->comment_approved == "0"}
        <p>Your Comment is awaiting Moderation.</p>
    {/if}

I’m also going to style the comment box a little differently for unmoderated comments.