Back to WordPress

Although Ben Johnson is talking about the Ruby on Rails weblog app Mephisto (tip #6), almost all the same arguments can be applied to the app I wrote in Merb that was running this weblog up until a week or so ago:

I can not tell you how much of a pain in the ass [it is]. If you want to customize [it], feature wise, you are SOL. Don’t bother modifying the source because you will not know what the hell is going on.

Yep. I was eating my own nasty dog food.

Okay, so my code may not be all that bad, but it did take a lot more work to adjust the layout, or to add even the simplest of features. One super-nice thing about WordPress is the number of plugins and source code that can be found online to easily adjust the app to do what you need. And, if you can’t find exactly what you’re looking for, it’s fairly simple to extend WordPress by writing your own plugin to do what you need.

So, that’s why I’m back to using WordPress to run this weblog. I need to update the about page and run down the crazy-long list of applications that have run this weblog over the years.


Sketching again

Looking out the window at Amani Coffee House

I’m finally breaking out the pencils and pens and trying my hand at sketching again. I’ve been at this position many times before, but then I’ll lose interest, or worry about putting down something crappy in the sketchbook. But from following the Urban Sketchers weblog for the last couple of months, I’ve been wanting to get out and draw, no matter the outcome. If I can someday get half as good as the artists posting there, I’ll be happy.

I’d like to challenge myself to draw something for a month straight, maybe for May. But I’m afraid that trying to get too serious too fast, is just setting the project up for failure. I think I will start posting some here on the weblog, and this Flickr set. Hopefully this will help a little with the motivation.


Use tags as meta keywords WordPress plugin

In the spirit of “as simple as it could be and still work” comes a WordPress plugin I wrote called “Simple Meta Keywords” that will take all tags specified on a post and use them to populate the meta “keywords” tag to help (a little, maybe) with search engine visibility.

For example, I’m using the plugin on this site, and it has added the following HTML tag to the <head></head> section:

 <meta name="keywords" content="weblog, brilliant, corners, pittsburgh, dallas, italy, merb, ruby on rails, ruby, rails, music, programming, web development, jquery, javascript, code, plugin, wordpress" />

At the end of the content there, you’ll see “code, plugin, wordpress” which are the tags on this post. The rest of those keywords are the defaults and are also specified in the plugin code (see instructions below).

Instructions:

  1. Visit the Github project page and click the “Download” button (to the right of the project/plugin name). You’ll be given a choice of .zip or .tar files to download.
  2. Unzip the archive that you downloaded to your computer.
  3. Edit the PHP file (simple-meta-keywords.php) and change the $default_keywords variable contents (if you feel the need to).
  4. Upload that .php file into your WordPress installation’s wp-content/plugins/ directory.
  5. Activate the plugin the from the plugins page in WordPress admin.
  6. That’s it!

Some caveats:

  • It will only work on single post archive pages. On the index, pages, tag archives, etc. it will display the tags specified by the $default_keywords variable.
  • It only uses the “tags” that are specified for a post, and not any “categories.”
  • If your activated theme or some other active plugin includes or does something with the meta keywords tag in your header, I’m not sure what will happen if you use this plugin as well.

Why?

After some searching through the WordPress plugin directory I couldn’t find a plugin that did exactly what I wanted. Some plugins did too many things, and some were needlessly complex. So I wrote my own. With all that said, I hope the plugin helps someone!


What was old is revived, updated, refreshed, and new again

Since we’ve been over our heads in a house remodel the last couple of months, the stack of home, kitchen, and bathroom design magazines gets taller and taller. One of them features 18 older homes (all built before 1930) that have undergone some kind of update. The houses and their new leases on life are nice and all, but what I was wondering if they would ever run out of adjectives to specify an updated old home. Here are just a few of the titles from the 18 home makeovers:

  • Rustic Revival
  • Southern Renewal
  • Preserved in Stone
  • Salvaged Charm
  • Elegance Renewed
  • Return to Glory
  • Second Life
  • Farm Fresh

These are just the most striking alternatives to “updated” or “saved” that the editors used in titling the features. I can imagine that it’s difficult to think of so many different ways to say the same thing, but I’m sure they could have been a little more creative.


Getting has_many :through working with Datamapper

Datamapper is a great little ORM (object-relational mapping), but it’s still a little rough around the edges (as of this post, anyway). This homebrew weblog application was initially using ActiveRecord with Merb, but with release of the 1.0.x branch of Merb, I thought I’d give Datamapper another try. So far, I’m both happy and not happy about the decision. I’m happy because of things like the way the finder methods work and how the migrations are created via the models. But then I’m unhappy with how unfinished it seems, and this makes me curious why the Merb team sets it up as the default ORM when creating a new project.

Anyway, I was trying to figure out the best way to implement tagging posts for this weblog and my (in need of an update) professional site. The Datamapper docs say you should be able to do it in this way:

@post = Post.get(1)

# append it to the existing tags with some pseudocode
tags.each do |tag|
  @post.tags << tag
end

# and save
@post.save

But, if you try something like that, you’ll get an “Immutable Association Error” or something about a “frozen array.” The associated tags won’t save like you want them to. The problem is described in this ticket at the Datamapper bug tracker.

So, instead of trying to save the tags through the association, I just create the join/association record itself. Here is what’s in my post.rb model (well, the important bits anyway):

class Post
  include DataMapper::Resource

  # set up taglist for editing
  # * Not a column in 'posts' table
  # * Shown on edit form as a text_field for free entering of tags
  attr_accessor :taglist

  # relationships
  has n, :taggings
  has n, :posts, :through => :taggings

  # callbacks
  after :create, :assign_tags
  after :update, :update_tags

  private

    # Set up initial tags on creation
    def assign_tags
      self.taglist.split(',').collect {|t| t.strip}.uniq.each do |tag|
        thistag = Tag.first_or_create(:name => tag.downcase)
        Tagging.create(:post_id => self.id, :tag_id => thistag.id)
      end
    end

    # Wipe out and then add the tags again
    def update_tags
      self.taggings.each { |tagging| tagging.destroy }
      self.taggings.reload
      assign_tags
    end

end

As long as I have a taglist field defined in the admin form it will save/update the tags (create the association) when I add/edit a weblog post. Here’s how I have that field in the view:

<%= text_field :taglist, :size => 50, :value => @post.tags.map{ |tag| tag.name }.join(", ") %>

Now, this may not be the most elegant way to make tagging work, but it works for me, and hopefully this may come in handy for anyone else trying to get this kind of a has_many :through relationship working and keeps getting stopped by the errors.


Tumbling

I think I’m going to abandon trying to keep the art inspiration posts here on this weblog. It’s sometimes more time-consuming than I wanted it to be. So, I’m moving the inspiration posts to Tumblr. Now, you can get your wonderful and inspiring art at http://billturner.tumblr.com/.

I think I’ll eventually roll those posts into the RSS feed here, but until then those art posts will live there, and there alone. Also, I’m really digging the Tumblr interface, so I’ll probably have something more to say on that at a later date.


THE PROJECT: Language? Framework?

One of the first things I need to determine about THE PROJECT is what I’ll build the application with. I’m positive I’ll take advantage of one of the frameworks (like Ruby on Rails or CakePHP) to build the application, but I need to nail down which language I’ll use. There are many many choices out there on what language to use, but for me there are only two I’ll choose from: PHP or Ruby. But, which one? I’ve done quite a bit of work with both, although less with PHP. Let’s see the options:

Ruby

For the last three years, most of the work I’ve done has been with Ruby, either with Rails or, more recently, Merb. I grow more comfortable with Ruby every day and I still have fun learning new tricks. This had been pretty much restricted to Rails up until I gave Merb a try a few months ago. I rewrote this weblog with Merb and I had a good time teaching myself something new. Yes, there are many, many similarities between Rails and Merb, but I think there are some things that Merb does better (and easier). Rails, on the other hand, is a little more robust and has a larger community behind it. It could be easier to do what I want to (in the scope of this project) with Rails, as opposed to Merb.

PHP

In the last year, I’ve built a few web apps using the CakePHP framework, and I found it quite a nice change of pace to work with. Since I had a strong Rails background, CakePHP was easy to pick up since they certainly had Rails in mind when putting the framework together. However, if I went with PHP, I’m not sure I’d go with CakePHP. I’ve heard many good things about another framework, CodeIgniter, and I’m eager to try it. There’s nothing that particular bugged me about CakePHP, but CodeIgniter has a reputation as being a little faster, but it may not have a community as big as CakePHP’s backing it up, or as many places to look for code examples.

The Decision

So, what will it be? First of all, I think I can narrow it down to using Ruby instead of PHP. PHP is more widely supported (and easier to deploy, etc., etc.), but I think my day-to-day experience leans me more towards Ruby. I’m just more comfortable with Ruby than I am with PHP. I do want to use the CodeIgniter framework for something in the future (and I think I may already know what that is), but I just don’t think it’s quite right for this project.

That leaves me with the Ruby language, but which of the frameworks? Merb is just about to reach the big 1.0 milestone, but while Merb may be ready, I’m not sure I’m ready to build something big on the framework. It’s still young and with many fairly drastic changes in the API the last few months, there’s not a whole lot out there in the way of documentation and sample apps and code. In the few years I’ve been working with Ruby on Rails, the community has exploded with plugins for just about everything, tons of sample code, and a growing reference library (thanks to the Rails-related weblogs and numerous tutorials). I know Rails is up to the task, and that it can handle all that I’m wanting to do (and more).

In my mind, that settles it: I’ll use Ruby on Rails.


Some ideas are good. Some are bad.

Jillian Tamaki on idea generation: Plunking yourself down in front of a pad of paper and scraping the inside of your brain is probably not the most effective way of generating ideas.


Written in David’s Journal

I simply ask people to write in my journal. What they write is up to them.”


Introducing THE PROJECT

I’ve had the idea for this web application for over a year now, but haven’t done much with it. Well, I take that back. I started and stopped it about three or four times, but I always stalled on some small detail or became distracted by something else. This time I’m going to do quite a bit more planning up front to avoid the traps I fell into in the past. I also thought I’d post about my progress here on the weblog. Hopefully, this exercise will help me organize my thoughts and ideas.

The last big web application project I built was Lists of Bests (archive of my version, current version), but it’s been two years since I sold the site to The Robot Co-op. I haven’t done anything of note since then. Well, I could mention the intranet app I work on for a small Dallas-based company, but no one outside of the company will ever see it, so that one doesn’t count (even though it is pretty awesome). It’s now well past time for me to start up something new, and the fact that I have the idea, that’s all for the better. I will say that the idea behind THE PROJECT isn’t an entirely new idea, but my plans are to make a good idea even better. We’ll see if I can deliver on that!

I plan on covering much of the progress of the application while I’m working through it: technology used; layout decisions; administrivia; and everything else. However, I will keep the actual focus of the web application secret until I get a little further along in the process, although some clues may surface throughout the series of posts. The next couple of posts will cover more general ideas and questions, before I start writing any code at all. Then I’ll get into the meat of building the full-on web application. So stay tuned!

As a final note, a bit of inspiration for putting this series together goes to Garrett Dimon and the blogging he’s been doing while building his app Sifter.


Brilliant Corners is the weblog of Bill Turner. Common topics include Ruby on Rails, Merb, art, and web design.

I'm also a web application developer (specializing in Rails, Merb, and PHP) based in Pittsburgh, PA.

Recently on Twitter: