This whole blog thingy is a lot of work…

November 20th, 2008 by Greg

 
The fabled King Midas purportedly had the ability to turn anything he touched, no matter how plain or how ordinary, to gold. I’ve found over the course of my life that I have a similar ability. Any task I put my hand to, no matter how menial or seemingly fun, turns to work. While I have to admit it isn’t quite as cool as King Midas’ ability it is also far less likely to result in the loss of a loved one; proof that life has its little trade offs, I suppose.

You are currently looking at the latest manifestation of this amazing ability: my blog. What started out as something I thought would be fun and perhaps a little therapeutic has somehow transmogrified into a swirling black hole from which neither time (that would be any free time I might have had) nor light (i.e. something worth reading) escapes. “But wait,” you say “I’ve read everything here and, well, you’ve spent all that time and this is the best you could do?” Well, yes. And no. It isn’t quite that simple. But then, it never is, is it?

See, the root of the problem is that I am a perfectionist. I mean a “if you’re gonna do it, do it right, if you want something done right do it yourself, almost isn’t good enough”, unrepentant perfectionist. While that may seem like a good quality to have, trust me, sometimes (perhaps even often) it isn’t.

A prime example of one of those times would be the sound system I put in my truck. I gave a small overview of what I’d done in this post last week, but really only a passing mention. The whole story (abridged version) is that a few years back I bought a brand new Dodge Ram Quad-cab truck. Almost immediately after purchasing it I stuck my brand new truck in the middle of my garage, opened all 4 doors and removed the entire interior; seats, carpet and all, excluding only the headliner and main dash section. I ripped out the center of the console (where the radio and a/c controls are located) and made a dense foam mold of the opening to shape and use as a mold for the cast resin replacement I made. You see, I had to re-cast it because the placement of things had changed. I’d removed the stock receiver (of course) and replaced it with a more suitable aftermarket one but, to accommodate the seven inch touchscreen I was building in I had to fabricate brackets to move the radio higher in the opening and another to move the a/c control unit lower. You may be wondering why I need a touchscreen in my dash. Well, how else will the PC I was building into the truck in be used? I bought triple shielded signal wires and after carefully routing them from the receiver to the amps to keep them away from any power, I cut them to length and soldered new gold plated RCA connectors on them. I added a separate power feed and power distribution block directly from the battery. I built custom brackets to mount my XM antenna inside the dash and more to place my front tweeters at just the right angle. I built a foam mold to make a factory like fit 12 inch sub enclosure under the rear passenger side seat then spent many many hours laying fiberglass to make it. I…well, I could fill several pages with the complete task list, but I think you get the idea. The end game was to have a great system that looked like it came from the factory that way. All the amps, etc were hidden but, even if you know where to look they look like they were put in when the truck was built. Every detail had to be right.

During the course of this whole adventure my truck sat squarely in the middle of our two car garage looking more like a vehicle that had been left overnight in Harlem than one in a garage in suburbia. Christy asked me more than a few times when I was going to wrap this silliness up and get the heck out of her spot in the garage. And she didn’t ask in a “I love you truly, madly, deeply and want to spend the rest of my life with you and bear your children” sorta voice. It was more of a “this was funny for the first week or so; now when are you going to wrap this silliness up and get the heck out of my spot in the garage” voice. It was a little tense for a day or two but, alas, perfection cannot be rushed. That obsession with getting all the details caused a bit of friction, but I couldn’t bring myself to just wrap it up and leave things slapped together.

While the blog is not taking up space in the garage, it has been much the same. Perhaps to a lesser degree, but not as much as you might think. It isn’t blocking my wife's access to the garage so the friction isn’t there, but it does involve a lot more detail than you might suspect. I’ve written the few posts that are published now and have a good running start at another four or five. While writing them takes far longer than I could have imagined, those only account for a small portion of the time I’ve spent thus far. What else is there, then?

Well, for starters I had to find a theme (the add-on that determines the layout and look of the blog) just to get out of the gate. I found a theme I liked in overall terms but still needed to make significant changes. To that end I’ve spent many hours substantially modifying the html portions and cleaning up the css bits. I also created the banner graphic you see above then had to match the other elements to it. All of the little things from the shadow below the banner to the footer at the very bottom of the page are all hand built graphics and the page contains about a dozen of them. All of those have to be re-done every time you want to try out an idea so it isn’t a fast process. I’m not entirely happy with it yet. I need to re-work the colors of the sidebars, for instance, but I’m close enough for now and have most of the heavy lifting done.

Beyond the theme, though, I wanted specific functionality added as well. One of the first things I wanted was the SMS box you see here so that readers can send text messages to my phone from the blog. Live comments, if you will. So I set out to find a widget (an add-on for the blogging software I am using) that would let me add that. And the widget I found was great if you ignore the fact that it didn’t work at all. If that bit bothers you, as it did me, then the only way to correct it is to dive in and find the problem. If you’ve not had the pleasure of unraveling someone else’s code then allow me to explain. It is a lot like taking a statement made to you by a stranger and trying to figure out the thought process that led them to it. Let’s just say it wasn’t a quick process.

Once I got that working I realized that, if someone took the time to text me from the blog, I had no way to reply to them. Well, that would just be rude now, wouldn’t it? So I set out to find a solution and happened upon the Twitter sidebar.

If you’re not familiar with Twitter, it is sort of a micro-blogging site. Think blogging done entirely with text message length posts and you’ll be close. It also adds a social networking component so all your little Twitter friends get updated every time you post something to your Twitter account. So now all of your friends can be made immediately aware of critically important events in your life like the fact that you are ordering at Taco Bell or you just saw a funny commercial or the vitally important information that you are right at this very moment in time having a bad hair day. It makes facebook look like serious content. Yeah, it really is that bad. So why go that route? Well, in spite of all it’s lack of substance or perhaps because of it, Twitter is the perfect sort of medium to use to reply to SMS messages in a more public, generic way.

So. Back to the Twitter sidebar I found. It was great, except that it didn’t work either. The fix was fairly trivial in this case but once I got it running I realized it was quite lacking for my purposes. The biggest problem was that the only way for a anyone to see if I’d sent a response to a text they’d sent me would be for them to repeatedly refresh the page and see if a new tweet (that’s what individual Twitter messages are referred to as) has shown up. Oh, snap. Not on my blog. I set out to change that, which ultimately necessitated re-writing more of the code than I kept, I think. While I was at it I fixed it so that some HTML-like characters showed up properly and made it so you could specify the name you wished to be displayed before each message. I’ve thrown some tech details at the bottom of this post for the geeks among you.

Once that was working I had the cool idea that I could integrate the SMS widget and Twitter widget in some neat ways. I think we’ve established by now that I am unable to resist the stray cool idea. It is my kryptonite. I won’t bore you with implementation details, but the end result was that as soon as a text message is successfully sent the SMS widget notifies the Twitter widget to look for updates far more often than usual for the next couple of minutes. That way my pithy responses get delivered to the, no doubt breathlessly waiting, reader even faster.

I will be adding a sidebar music player shortly so I can throw up playlists or play the random audio sample. No, it will not start playing automatically when you come to the page. Ever. I promise. That happens to be a pet peeve of mine. Excluding that, I am almost done with the changes for now. At least until another cool idea strikes me, that is.

So before that next big idea hits I think I’ll spend a bit of time trying to catch up on some of these posts that are backing up on me. While I’m at it, I’ll try to avoid touching anything new, lest my Midas-like abilities suck me into something even bigger. As always, I welcome any feedback on the the look or functionality of the site in general. Thanks for stopping by.

/g

Tech details for the geeks follow. The rest of you overt your eyes from the geekiness. For the uninitiated, looking directly at it could result in dain bramage or perhaps the sudden desire to watch an episode of Jerry Springer. Same difference. At the minimum you are likely to end up a little constipated for a few days. You’ve been warned.

The Twitter plug-in I used is wptwitter. The person who wrote it says her coding skills are weak but it was actually pretty well done, just not for what I wanted. She was using the Twitter API to pull back Tweets as JSON objects, sorta AJAX like but not asynchronously. She had just created the call as a standalone javascript within the page that loaded and ran with the initial page load. The resulting JSON object was then just eval’ed by the javascript interpreter and an object named Twitter appeared in the global scope. Her later javascript then just parsed through it and printed it out. I wanted to get it every so often. I initially considered using an XHTMLRequest straight from the AJAX playbook, but browser security didn’t like the cross-site pulls. What I ultimately ended up doing is creating a script DOM object with the Twitter URL as the script src property and appending it to the head section. That caused it to run automatically, thus pulling the data from Twitter. The Twitter API allows you to specify a callback function in the original call so, when the response from the call gets executed it simply calls the javascript function I specified with the posts in a JSON formatted data structure as the sole argument. My callback function places that into the global data structure then calls the main body of code. Works very well. I also started passing the twits in by setting innerHTML on a pre-created p type DOM object so the HTML would be processed rather than leaving things like &lt; in place of <, etc. I also put in a substitution that uses regular expressions in the javascript replace function to turn URLs into clickable hyperlinks in the tweets.

The call from the SMS widget was a bit trickier. Since functions are global in javascript I though I’d just set up a function in the twitter widget’s code and dump a small javascript call into the HTML stream from the SMS box to call it. I couldn’t do it from within the main loop since the SMS widget is in PHP almost exclusively and the twitter widget is almost entirely in javascript. The problem was that the SMS code loads higher on the page so it tries to call the function from the twitter code before it exists. I solved that by having it call the code with a setTimeout call with a 5 second delay rather than immediately. It still isn’t ideal, but it gets the job done. The twitter function that recieves the call sets a shorter refresh duration and a specified period before it should revert to the normal value. Both values are configurable through the plugin interface in Wordpress.

If you want more detail on either of these or want the code shoot me an email (firstname at lastname dot net) and I will be happy to answer. Once I’ve had time to perform some light regression testing I will release it back into the wild through the original authors if they want it or directly if not.

This entry was posted on Thursday, November 20th, 2008 at 11:18 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply