Pardon the Mess as I Update My Design and Do Some House Cleaning

WordPress

Postie and Moblogging

Posted in WordPress on February 11th, 2007 by Dave S. – 1 Comment

Since I have been bitten with the blogging bug, I have found that ideas for post don’t always come when I am conveniently located at a computer. Many ideas hit me during my 60-mile commute to work or on the return trip home. Ideas also seem to magically appear during some of the most regular parts of my day. So what’s an aspiring blogger to do?

Enter Postie, a WordPress plugin that allows you to create and submit a posting to your blog pretty much regardless of where you are provided that you have some type of connection to email or webmail via PDA, cell phone, etc. Postie is an evolution of a plugin originally created by John Blade but had gone dormant. I find that this is the case with so many good WP plugins assumably because either the creators need was met and they simply released their work to the public or because the plugin literally assumes a life of its own and the creator either lacked the knowledge, skill or willingness to manage and maintain a software development project. Regardless of the whys or hows, one of the beautiful things about the Open Source Movement is that where there is a well-defined need or desire there is generally someone willing and able to pick up the cause where others have left off.

Fortunately for me and for others Dirk Elmendorf decided to continue from where John left off and the result has been further evolution of a what looked to be a pretty good plugin.

The premise is pretty simple. What if someone were able to post to their blog from whereever they were whenever they wanted via email using the device of their choosing while being able to include images and attachments while controling a number of the variables required to make posting easy, convenient and requiring little, if any, editing after the post was made. To that end, I think Dirk has himself a pretty solid plugin that does what it perports to with very little challenge in the set-up and ongoing maintenance.

To explain how it works lets start with the end result and work backwards from there. Below is a post that I created on my Motorola Q and posted from the convenience of my living room:

test

snow20907.jpg

test

As you can see, my test was pretty simple but very demonstrative of the true possibilities that Postie brings to the table. Now, truth-be-told, this entire post was originally created using Postie, I just decided to add in some commentary around the actual posting itself. Using the plugin, you can control posting variables such as the title, the category it is posted to, images and attachments and when it is posted. I won’t go into all of the details of the variables (as I think Dirk covers those pretty well), but I will say that they offer pretty limitless possibilities.

The biggest challenge for me (and many others it seems) is getting the back-end processing working. The true magic of Postie is the fact that if it is installed and configured properly it really takes care of itself. What I mean by that is the fact that through some server-side magic, Postie checks a designated (and hopefully very secret) email account on a pre-determined interval and posts the contents of those emails to your blog. What allows this transaction to take place is a cron job, a program that enables unix users to execute commands or scripts (groups of commands) automatically at a specified time/date.

There are two ways to do it: via plugins such as WP-Cron, a plugin that provides rudimentary support for scheduled exection of actions; a sort of “delayed action” processing for WordPress. According to the author: “It is nowhere near as robust as the actual UNIX cron facility, but should be good enough to “do stuff” on a fairly regular basis”. My other option was to run the cron via the shell from the command line.

Admittedly, I am a Linux newbie and it took me quite some time to understand how all of this worked. I initially took the path of least resistance (plugin) but quickly found that it wasn’t yielding the desired result and instead of simplicity, I got complication. Since the cron job is supposed to run at fixed intervals all I would theorhetically have to do is install the Postie plugin and the WP-Cron plugin, send an email posting the wait 15-minutes or so and voila, my post would appear nicely formatted and ready for public consumption. However, what I found was that the two plugins didn’t necessarily play as nicely as I had hoped. I don’t think this is a failing of either plugin but rather attribute it to the fact that I wasn’t entirely sure (a) if they were even meant to play nicely with each other and more importantly how the process was “supposed” to work. Just as a point of clarification, the WP-Cron did allow Postie to work it’s magic, but I seemed to lose most of my post formatting along the way.

This caused me to bite the bullet and look at doing it the “old-fashioned way”.

Since I am hosted by Dreamhost (who I highly recommend as a host if you are in the market) I have the ability to run cron jobs from the shell. At DreamHost, they servers they uses to host your website all run the unix-like operating system known as Linux (specifically, Debian Linux). Some of their hosting plans allow you to get a “shell account” on the server, which allows you to access unix commands. “Although it can be intimidating at first, learning even just a little bit of how unix works can really help make your hosting experience a better one!” The quote is taken directly from their Wiki, and while I may have disagreed when I started yesterday afternoon, now that I have overcome the learning curve, I couldn’t agree more.

Granted, I had to download PuTTY, a free implementation of Telnet and SSH for Win32 and Unix platforms, along with an xterm terminal emulator, figure out how it worked and what I needed to do to create a cron job, and it was pretty overwhelming. Thankfully, the combination of searching on Google, the Postie website, the Dreamhost Wiki, and the Dreamhost Forums along with some time and patience allowed me to get up and running with minimal frustration.

My biggest challenge wasn’t learning all that I didn’t know (Once you get a handle on the language used to explain everything and the commands required to use PuTTY it was pretty easy) or creating the cron itself (again a matter of using the right commands and syntax) but really resulted from how Dreamhost has their servers configured. The secret to this cron was finding the right path to PHP on the server and then pointing to the script that I wanted to run. I tried numerous iterations without success and then finally struck gold earlier today.

I had been trying the following:

*/10 * * * * /usr/bin/local/php /home/username/path/to/file/to/execute

which continously resulted in a file not found error. For the life of me, I cannot understand why it didn’t work. That increased both my frustration and resolve. I continued searching to see if anyone else had a suggestion and came across this solution:

*/10 * * * * curl http://mydomain.com/path/to/file/to/execute

Again, since I am a relative newbie, I didn’t understand the premise of cURL but after some research I learned that the main purpose and use of the cURL command line tool is to automate unattended file transfers or sequences of operations. It is, for example, a good tool for simulating a user’s actions at a web browser. With that understanding and seeing that my cron was running appropriately, I felt like I was finally off and running.

Now everything is running as it should and I feel like I could leave it alone, but I have yet to research what, if any, deleterious effects using this approach as opposed to the former may have. Likely I will keep experimenting to see if there is a better, or more efficient way to run my cron job. One potential idea that I came across on the Postie website, but have yet to try, may address my concern and open up some additional functionality included within postie. It seems that a user by the name of lipilee suggested that by creating the cron using the cURL command in the following manner:

curl -c [cookie file] -d log=[username] -d pwd=[password] http://[your blog’s address]/wp-login.php
now you stored the cookie WP gives you upon login. let’s use it:
curl -s -b [cookie file] http://[your blog’s address]/wp-content/plugins/postie/get_mail.php >>/dev/null

That curl will use the cookie from the file and it will run the get_mail.php script just as if you logged in before. This could be attractive as it causes the blog to think you are actually logged-in and adds additional code not present if you aren’t. It’s been quite the learning experience for me but the upside is the fact that I now have the ability to blog from just about anywhere and I also learned quite a bit about working from the command line. All in all, I would say it was totally worthwhile.

Flash Video Player Plugin for WordPress Test

Posted in Travel, Videos, WordPress on January 21st, 2007 by Dave S. – Be the first to comment

As I am getting ready for my trip to Hong Kong, I thought it would be fun to publish some videos / vlogs documenting my trip. I have all of the hardware (Logitech QuickCam Fusion webcam and my Panasonic Lumix FZ30) / software (Camtasia Studio) to make it happen, but I needed an easy way to include it on my site.

A quick search of the wordpress.org site led me to a pretty elegant solution. It leverages the feature-rich Flash Video Player created by Jeroen Wijering and a really slick Flash Video Plugin for Wordpress that integrates Jeroen’s player to simplify the process of adding a flash video to a WordPress post. The plugin was created by Joshua Eldridge @ mac-dev.net. Josh has a pretty cool photo gallery plugin igallery that looks pretty sweet as well and something I may try out.

If I installed everything correctly, you should be able to see the flash video player below. To play the included video click the play button or more simply just click the video player screen.

Get the Flash Player to see this player.

Look for more videos from me as I try to document my adventure to Hong Kong in words, pictures and videos.

fGallery Sidebar Widget

Posted in WordPress on December 10th, 2006 by Dave S. – 5 Comments

After a busy weekend of doing holiday related stuff including taking my son on a train ride with Santa on Saturday and having a special visit from Santa at our house on Sunday, I had a ton of great pictures to get in order.

This prompted me to take a good look at my family website which I have been neglecting for some time now. Among the many plugins I have using, I use fGallery by Frederik Fahlstad for our photo gallery because it is reliable, predictable and pretty easy to use. Up until this point it was well integrated into my template, but I decided to upgrade that as well, which in turn broke the plugin to an extent (the images aren’t displaying).

So since I was aleady under the hood, I decided to widgetize my new template and take the functions for fGallery that allowed me to display either the most recently added or random recently added images in my sidebar and create a widget for that as well. You can find the downloadable widget, which I am calling the fGallery Sidebar Widget here. It really isn’t that big of an accomplishment (although it is my first widget), but I think it is inherently easier to work with than having to hard code the function call in the template itself.

GeoPress

Posted in WordPress on October 10th, 2006 by Dave S. – 2 Comments

I am getting ready to go on the road and wanted to make sure that I had my newly established blog ready for the trip. One of the first plug-ins I searched for was a geocoding / mapping module so I could not only tag and track my travels. Instead of starting off in the usual locations (WordPress Plug-in DB or WordPress Codex), I decided to google the keywords to see what came up.

I was pleasantly surprised that at the top of my list was the newly released GeoPress. From the minute I saw it, I knew that the developers (Andrew Turner, Mikel Maron, and originally developed by Ravi Dronamraju) knew what they were talking about and had themselves a great addition for my site (If you don’t believe me visit either of their sites). Their plug-in basically does everything a mapping application should do and a whole lot more like embedding a dynamic map (Google Maps, Yahoo Maps or Microsoft’s Live Local Search – your choice), Microformat adr and geo output, and adding GeoRSS to your RSS output.

GeoPress is a tool to help you embed geographic locations into your blog posts, and also include this information in your RSS/Atom syndicated feeds using the GeoRSS standard.

Here is an example:
INSERT_MAP

There are a whole lot more features, but their site does a much better job describing it concisely. Needless to say, I decided to download it and give it a try. The site stated that it was as simple as downloading the zip, uploading it, activating it in your plug-ins screen, grabbing a either a GoogleMaps API or a Yahoo Developer key, configuring the settings, and you were off and running. Well, I can say for the most part, that was true. It was really easy to download, and get set-up, but getting it working right wasn’t. Now don’t get me wrong, this has more to do with documentation of using the hooks the right way…nothing with the application per se, so it shouldn’t diminish the coolness or usefulness of this plug-in.

What impressed me more than the functionality itself was how willing Andrew was to give me a hand, figuring out what I did wrong. We traded a few emails and he solved 90% of my troubles. I think we did unearth a bug, but that’s to be expected, especially since it hasn’t been around for that long.

All things considered, setting it up was pretty easy, but where this plug-in shines is in its ease of use. To begin using GeoPress, all you have to do is write a new post and enter a location name / address in the appropriate fields. Then you press enter, or click the Geocode button to verify on the map that this is the appropriate location. Additionally, you can click on the map to set a location. Once you save your post, the geographic location is stored with the post entry. If you are using a GPS unit or happening to have your coordinates handy, you can enter latitude and longitude, then enter into the address field provided by the plug-in.

I can’t wait to really leverage this as an integral part of my daily writing both when I’m home and on the road.