Blog
Trailer-Review.com: A Drupal Weekend Project
I love microblogging and the social medias. I'm always looking for little social media experiments as well. Besides this blog, I'm always thinking up other ways to drum up interested readers, inform readers, and give out my opinions. Of course, one of those genres that I love commenting on is movies and the crazyness of Hollywood.
Microblogging services such as Twitter, Pownce, FriendFeed and their social media friends are also another fun place to express an opinion. Twitter has one interesting limitation - that is, all posts have to be 140 characters or less. In some ways, this makes it as much of an art form as a short form blogging service. For my personal account, one of the reasons I use Pownce is because I like to convey a unique thought without having to edit for 140 characters. But, for more rehearsed messaging, I figure that the 140-character limit can be a sort of editing challenge.
With this in mind, I created the trailer_review Twitter account. On this account, I post an 140-character or less review of the movie preview, starting with the title of the movie and ending with a link to the preview. But, after posting a couple trailer mini-reviews, I decided that I'd want a website to go along with that I could provide more information at a later time, if I wanted. Plus, not everyone is yet on Twitter, so maybe others would like a separate site where the could grab an RSS feed, leave comments, etc. Thus, thanks to the power of Drupal, it took a couple hours to get a functional, decent-looking website working. This is the store of Trailer-Review.com, my first-ever Drupal weekend project. (Full disclosure: It took me two weekends to do all these steps because I was working on a couple paying freelance projects and doing other things, but these processes could easily be done in one free weekend.) To paraphrase Strong Bad, "Feel free to follow along with my simple step-by-step instructions. I make [Drupal] FUN!"
Step I: Setting Up The Site
To set up a site, you need to have a LAMP (Linux, Apache, MySQL, PHP) server that you can set the site up on. OK, so I lied, you could run it on Windows, you can run it on IIS, and of course you and run it on Python (or even Oracle, I hear). So, basically, you need PHP, but the LAMP stack is the easiest. Set up the site, then download the latest version from the drupal.org website and decompress it. (We used Drupal 6.6.) Access the public URL of the site and follow the instructions to install the site. You will need database information and will be able to set up an administrator account.
Step II: Adding Contributed Modules
Download the following modules for Drupal 6.x:
Uncompress these folders and place those in a folder called sites/all/modules
folder. Then, go to "Administer"->"Site Building"->"Modules" and turn on these part of the modules:
- Content
- Link
- Trigger
- Twitter actions
Now we're ready to start configuring the modules we've installed.
Step III: Configuring Content and Link
To setup the content items, we want to have the title and body as well as the URL for the site to watch the movie trailer. The title and body are included in the default stories, but we'll use the Content Construction Kit to create that URL field and the link to that trailer. Here we go:
- Go to "Administer"->"Content Types".
- Click on the "manage fields" link next to "Story".
- Under "Add," type the label "Trailer Link", field name "field_trailer_url", and "Link" for the type of data.
- Click on "Save".
- On the next page underneath "Global settings," check "Required".
- Select "Static Title" for the "Link Title" section. Click "Save field settings".
- Towards the top of the page, click on "Display fields".
- Change "Label" from "Above" to "<Hidden>" and click "Save".
Step IV: Configuring Twitter
For this site, we want Twitter to be posted to any time new content is posted to the site. To do this, we use the Twitter Actions part of the Twitter Module. We will set up an Action and then use the Trigger module to make it run every time we create some content. Here's how we want to configure it:
- Go to "Administer"->"Site configuration" and click on "Actions".
- At the bottom of the screen under "Make a new advanced action," select "Post a message to Twitter..." and click "Create".
- Type in your Twitter account name and password and then type in the message. (Note the use of the
%
symbol with specific keywords allows you to add the new content - for my site, I used%title: %teaser %node_url
.) - Click "Save".
- Next, go to "Administer"->"Site building" and click on "Triggers".
- Under the "Trigger: After saving a new post" section, select the "Post a message to Twitter" action (or whatever you named it during Step 3 and 4).
- Click "Assign".
Voila! Now we've got a working site that posts to Twitter when we post and also provides a link to the trailer. However, there's a couple things more.
Appendix A: URL Shortening for Twitter
First, we want to give us more space on our Twitter posts so that, instead of Twitter using <a href="http://www.trailer-review.com/node/14
">http://www.trailer-review.com/node/14[/geshifilter-code] as our URL, we get a shorter URL. There are a number of fancy URL shortening services such as TinyURL, but I chose Bit.ly because it's a bit shorter than TinyURL anyways. After signing up for an account, I can write some code to request a shortened URL for my longer URLs via their handy API. Unfortunately, in order to get these in the Twitter Actions module, I have to hack the sites/all/modules/twitter/twitter_actions/twitter_actions.module
file. I took this part:
// Node-based variable translation is only available if we have a node.
if (isset($node) && is_object($node)) {
$variables = array_merge($variables, array(
'%uid' => $node->uid,
'%node_url' => url('node/'. $node->nid, array('absolute' => TRUE)),
'%node_type' => node_get_types('name', $node),
'%title' => $node->title,
'%teaser' => $node->teaser,
'%body' => $node->body
)
);
}
and replaced it with this:
// Node-based variable translation is only available if we have a node.
if (isset($node) && is_object($node)) {
$node_url = url('node/'. $node->nid, array('absolute' => TRUE));
$headers = array('Content-type' => 'application/x-www-form-urlencoded');
$short_url_json = drupal_http_request('http://api.bit.ly/shorten?version=2.0.1&longUrl='.urlencode($node_url).'&login=BITLY_API_ID&apiKey=BITLY_API_KEY', $headers, 'POST', NULL);
$short_url = json_decode($short_url_json->data)->results->$node_url->shortUrl;
$variables = array_merge($variables, array(
'%uid' => $node->uid,
'%node_url' => url('node/'. $node->nid, array('absolute' => TRUE)),
'%node_type' => node_get_types('name', $node),
'%short_url' => $short_url,
'%title' => $node->title,
'%teaser' => $node->teaser,
'%body' => $node->body
)
);
}
If you read PHP code pretty well, you can see that I added one more variable to the options for the configurable Action we made. I've created a %short_url
variable that has taken the old %node_url
data and retrieved a shorter version from the Bit.ly site. To get it to print out the shorter URL, though, you have to go back to "Administer"->"Site configuration"->"Actions" and configure the action we made in Step IV to use %short_url
instead of %node_url
. (Of course, to get this to work, you have to replace the BITLY_API_ID
and BITLY_API_KEY
with the ones supplied in your Bit.ly account page.)
Appendix B: Keeping Track of the Character Count
Since I want to post these pithy reviews to Twitter, I want to know how many characters long the title and body with all the formatting is. Therefore, I created the "count_characters" module. First, I created count_characters.info
file as follows:
; $Id$
name = Count Characters
description = Adds a custom listing of how many characters are left.
php = 5.1
core = 6.x
Then, I created the count_characters.module
file where I Add space to list the characters in all content add/edit forms and include the forthcoming JavaScript file:
< ?php
/**
* Implementation of hook_form_alter().
*/
function count_characters_form_alter(&$form, $form_state, $form_id) {
if (substr($form_id, -10) == '_node_form') {
drupal_add_js(drupal_get_path('module', 'count_characters') .'/count_characters.js', 'module');
$form['count_chars'] = array(
'#type' => 'markup',
'#prefix' => '',
'#value' => 'Character Count: Unknown',
'#suffix' => '',
'#weight' => '-5',
);
}
}
Finally, here's some JavaScript that uses the JQuery library built into Drupal to count up the size of the title and body and tell you how many characters this will be on Twitter. This is count_characters.js
:
if (Drupal.jsEnabled)
{
$(document).ready(function()
{
$("#edit-title").keyup(function() { calculateTotalChars(); });
$("#edit-body").keyup(function() { calculateTotalChars(); });
calculateTotalChars();
function calculateTotalChars()
{
titleCount = $("#edit-title").val().length;
bodyCount = $("#edit-body").val().length;
totalChars = titleCount + 2 + bodyCount + 1 + 19;
$("#character_count").html(totalChars);
}
});
}
Note that in line 11, we not only take the length of the title and body together, but add some more characters. The Bit.ly URL should be 18 or 19 characters, at the most, and then we have 2 characters for ": " between the title and the body and 1 for another space between the body and the URL. Save these files in sites/all/modules/custom/count_characters/
and then enable the module via the "Administer"->"Site building"->"Modules" page. Now we know exactly how many characters our Twitter post will be!
Final Thoughts
For a weekend project, this is a great start of a site hat may prove to be a useful little site someday. There were a couple other things I did, such as customizing the color of the Garland theme, customizing the comment settings, and enabling OpenID for commenters to login via OpenID if they like. Of course, there's always more work to do, such as creating a custom design, added embedded versions of movie trailers to each post, and maybe integrating with other social media services. But that's for another weekend project!
Steve Jobs Lied to Me
Last week, at this time, I was having major problems with my laptop. Sometime around 6pm on Sunday, my MacBook Pro suddenly decided it could not use DHCP anymore. (DHCP, for the uninitiated, is the ability for your computer to just work when you join a network. If you don't have DHCP, you have to know a valid IP address, the gateway IP address, and IP addresses of working DNS servers to connect to the same network. DHCP just asks the router to give this to you automatically.) So, upon realizing it was my computer only, I tried testing it at the neighbor's house (because our Internet connection is crappy, at best). While over there, I had Collin check the router and he said the router was handing me all the usual DHCP information, but apparently my Apple MacBook Pro was just not recognizing it. I went to bed early and hoped we could get it working tomorrow. During lunch on Monday, I checked at work to make sure their network was giving my machine the same problem. It was, so I signed up for a meeting with a "Genius" at the Apple Store. After waiting for 25 minutes for the Genius Bar to get to my turn, I spent a half hour working with the "Genius" to figure it out. Most of the stuff he wanted to do I had already tried, such as booting Mac OS X in safe mode and even resetting the power system. He booted from a FireWire external drive and the networking worked there, so it was a software problem. We tried deleting a number of network-related settings files, which magically recreate themselves with the default settings in case something has gone wrong. But, still, the "Genius" hadn't seen this problem before, and therefore he didn't know of any good solution besides the dreaded "Archive and Install" procedure. Why the "dreaded" Archive and Install? Well, because the process of backing up all your system and user files and then installing Mac OS X anew took two and a half hours! OK, so it only took an hour and a half, but there was another hour of running all those software updates to get my MacBook Pro up to date. That's a long time. Windows doesn't even take that long, I don't think. So what's the problem? I believed the whole Apple hype that the Mac OS X experience was better than Windows Vista. Yes, I got this issue fixed with only a day and a half of my free time taken away, but what would I have been out if I had a Windows problem? With this kind of networking problem on Windows, all I've usually had to do is get a newer version of the hardware's driver or slap the side of the tower and it would kick back into gear. I would've had better ideas of how to fix it on Windows because of years of experience with it, but with Mac OS X I had to go see an "Genius" who really had no insight at all. Is the romance with Apple over? Far from it! I've got an iPhone and everything on my laptop is working again. I like the fact that there is someone I can go to and try to get help for my computer - there's no such person on the PC world because the manufacturer and Microsoft just keep pointing fingers at each other. After getting Mac OS X reinstalled, I only had to move my Applications and User folder back into the live system from the backup and I was up and running with the exact same preferences and settings as I had before. On a Windows machine, most of my data is in my "Documents and Settings" area, but tons of my settings are scattered throughout the rest of the computer as well. People talk about companies that need to be more open and public. Companies should listen to their customers. Apple makes cool products, but they always do it their way. They never listen to their customers until a raging mob starts pounding down the doors at Cupertino. They develop software for Windows but purposely leave out the features that would really make the application useful and keep those for Mac OS X. And, for Windows, there's a Knowledge Base article with five solutions to fix almost every problem - for Apple's support website, they'll just tell you to restart the computer and then go to see the "Genius" if it doesn't work. I'm not too mad at Apple - I just wish Apple would wake up to the world they live in and start acting like a real company. I wish they'd really work to help their customers. But, then again, maybe that's what makes Apple cool and keeps people sleeping on the sidewalk for days in order to be the first to touch their product.
The Bad Graphics Ghost Shirt
When I saw that the Homestar Runner Store was selling this shirt, I knew I should get it. My original excuse was because I didn't want to wear a costume for Halloween but I did want to do something special to acknowledge the "holiday" (although work didn't count it as a "costume", not surprisingly). It's in that spirit, of course, that I turned to the experts of Halloween, the folks at HomestarRunner.com for inspiration (and merchandise):
For those who are not so well-versed in the Homestar Runner canon, the Bad Graphics Ghost first appeared in sbemail 48, where Strong Bad's old Apple II-style computer haunts him. The ghost is replicated in beautiful blocks on the front of this shirt, with an amazingly simple BASIC program below it:
Let's see... Geeky. Check. Homestar-related. Check. Halloween-related. Check.
Another fun shirt, and if you're not up to speed with Homestar Runner and Strong Bad, get into it.
The Jars of Clay Shirt
Finally! I've been a huge fan of Jars of Clay for over a decade and it took me until August 2008 to get a Jars of Clay T-shirt! But it's a beauty:
Plus, I got it during one of the best mini-vacations ever - a whirlwind weekend to Chicago to hang out with two of my sisters and see a bunch of my favorite bands! In late August, my sister and I traveled to Chicago to meet my sister who goes to college in nearby South Bend, Indiana. (We took the Megabus from Minneapolis, which is a very cost-effective way to get to Chicago from many places in the midwest.) That evening, we caught a stop on the Music Builds Tour, which featured Jars of Clay, Robert Randolph & The Family Band, Switchfoot and Third Day, possibly one of the most amazing lineups in my rather short music history. It was great to see the Jars guys rockin' it onstage since the last time we'd seen them was in 2002. Robert Randolph and hte Family Band rocked the place like only they can and brought a bit of Gospel flavor as well. Switchfoot, of course, put on an amazing and inspiring show and all the bands came back for a synergistic encore. Oh, and did I mention that it was outdoors on Lake Michigan on a beautiful August day? That too!
The shirt, as you can probably tell, is gray and has the outline of the word "Jars of Clay" on it with some little bird figures. It's rock and roll and kinda pretty at the same time. And now, I support one of my all-time favorite bands via my favorite art form: T-shirts.
The Classic Game Over Shirt
Today's shirt is a nice, black look at retro gaming. And thanks to my terrible camera work in the bathroom mirror, it looks even cooler because the motion applied while taking the photo gives the illusion of a drop shadow:
Yes, the words "GAME OVER" are printed in a large, pixelated font destined to remind classic gamers of their favorite Atari or original NES games. And then, it also says (in standard white text) the creators of the shirt: thinkgeek.com, the central place for all products geeky and cool.
For those who don't know, ThinkGeek has lots of great products, although they usually are a bit pricey. Back in the day, I outfitted myself with this shirt as well as a couple others. Also, you can get ties, mini-copters, airsoft guns, marshmallow guns, action figures, knives, sporks, squids, lots of clocks, batteries, tape players, caffeine, phones, and much more. It's tons of geeky fun.
The Drupal Man
A couple days ago I posted my quick attempt at Drupal artwork. A commenter questioned my reference to most of our no-so-great skills in drawing under pressure, which all of us cover up via the computer. I responded by saying that the best sketch artist is Shawn, our manager. Shawn didn't know this, but he proved my point this morning.
A number of months ago we all found these little wooden guys on our desk. Shawn took mine home last night and it came back as the Drupal man! I love it! Thanks Shawn!
Acquia Drupal: Drupal With Help
One of the major problems of the Drupal Open-Source Content Management System is that it can be hard to grasp. And despite many improvements over the last couple years, it can be very difficult without an experienced PHP developer. And finally, companies who use Drupal would like to have a company that they can call to get questions answered and help for issues beyond their knowledge. Thankfully, a new start-up from some of the biggest people in Drupal development, called Acquia, has been working hard to make sure these people are taken care of. A major step in that direction was today's accouncement of Acquia Drupal, a slightly custom version of Drupal with more features and more support options.
Acquia Drupal is, at heart, a special distribution of Drupal. It uses Drupal's extensible installer system to bundle and install a whole bunch of commonly-used Drupal modules, most of which I have used over the years on one site or another. For a Drupal 6.x site, these modules are the most stable and feature-rich available. Those just starting out with Drupal can play around with Acquia Drupal to get a better look at some of the most common extensions and the inherent power of Drupal beyond a basic CMS. Of course, any Drupal site manager could get these from the Drupal.org site, but then you'd have to wade through thousands of modules to find the really good ones, which are handpicked here.
A new template is included that provides a nice, basic look - a bit more colorful and friendly than the current Drupal look. I alos noticed some help text throughout Acquia Drupal was a bit more verbose and helpful than the current Drupal install, which I hope will make its way back into the Drupal configuration in some form or another. I bet I will find more and more tweaks as I play with the system, and Acquia says they will be putting out patch releases every two weeks, so I expect more and more improvements on a pretty quick timeframe.
Acquia Drupal is not just a list of cool modules that you can use, though - it's the set of features that Acquia supports through their Acquia Support services. There are various levels of services based on the size of your site and they are priced fairly affordably for both the corporation and the non-profit who want Drupal help. The Acquia Support site includes a ticketing system and the higher-level support groups get phone support and 1-hour response times, as noted in a detailed services chart. Through the end of the year, online forum-only support and some Acquia Network services are free, as well.
All Acquia Support customers get the Acquia Network features, which are possibly some of the most intriguing features for a fairly experienced Drupal programmer like myself. Once you activate the Acquia Network, the Acquia Drupal install communicates with Acquia's server to check for any updates. A great upside to this is that they can track when your server is working correctly because the site is probably "down" at least partially when the server does not check in. Drupal users who are not so savvy can use their service to run the cron maintenance tasks required to keep a Drupal site smoothly. Also, Acquia has partnered with a spam-blocking company called Mollom that makes sure no spammy content gets posted to the site. Acquia Network even keeps track of the contents of your files, so that Acquia knows when the files of the site were modified, either on purpose or inadvertently, and can help the site administrator assess the situation. And, of course, it gives some fancy graphs that show your site changes and growth over time.
Overall, I find that Acquia Drupal is a great service for those who want support or want to check out Drupal. However, at this point, I'm not sure that I will subscribe to their support services. Maybe it's my independent spirit or my over-confidence in my own abilities, but maybe I will warm up to it over time. For now, it's a great addition to the current Drupal landscape, and I only expect Acquia's work to make Drupal and their product better over time.
The Drupal Pumpkin
This morning at work, we found small pumpkins on our desk. During our staff meeting, we were told to increase our humility by drawing on these pumpkins. After a couple minutes of thinking about it, I decided doing a pumpkin based on the Druplicon, the Drupal logo/mascot. My major disappointment was that the pumpkin did not have a small stalk at the top, but here it is:
The Downside of RSS
Here's a little story of something that's happened recently. In the end, it goes mostly to making sure that the webmaster of the sites did his homework, but maybe I'm supposed to remember things better, I don't know.
So, as I mentioned in the blog post about the ILikeAndy.com T-shirt, I enjoy Andy Osenga and his music. I've also loved reading his blog over the last couple years in addition to his music. He's one of my favorite bloggers. But what I found while writing that story was that I've not been reading his blog for the last six months!
How does this happen? Well, I've just been reading his blog via the RSS feed in my Google Reader, so I haven't been visiting his site. However, about six months ago, he got a new site, and the new site's RSS feed was not the same. Google Reader doesn't notify me of this, so I probably at first assumed that Andy was too busy to blog and then forgot about his blog completely.
The great thing is that Google Reader keeps track of what's new for me. Google doesn't usually screw up, but what happens when the webmaster forgets a little detail like that? I miss six months of content and have to spend a couple hours on a Saturday catching up. Should I be checking people's actual sites more often? I hope not - there's way too many sites that I follow via RSS to do that.
I guess the moral of the story is to make sure that you're not missing anything that's important to you on the 'net. Unless you're a webmaster, in which case, you should make sure you got your stuff together. And speaking of which, I gotta go manage some sites.