faithfulgeek.org

Agile web development

Sprint 0 Completed!

April 6th, 2008

Tonight I finished Sprint 0 on the Ruby on Rails Blog Starter Kit. It’s not much, but it’s starting to take shape. In this sprint I implemented the following features:

There are still many, many refinements to be made across the board, but the initial work is done.

This coming week will mark the beginning of Sprint 1. The features targeted for Sprint 1 are:

These are some pretty big features, but I believe I should be able to tackle them for this sprint. I’m fairly excited about most of them, especially Akismet and Textile integration. Akismet is something I’ve wanted to play with for some time now, just to see how it’s setup & how it works. Textile will be nice because it’s going to make my posts look pretty!

Featured Code Snippet

For this sprint, I have one piece of code that I’m particularly proud of. It stems from the need to render (or do) something different based on the user’s authentication/authorization status. For example, if the user is not logged in, do not give them access to this action. Or, if the user is not an admin, show them this view, otherwise show them a different view. I accomplished this by adding two methods to my application controller: the first deals with authentication, the second with authorization. Let’s take a look:


    def for_admin_only
      unless @current_user
        redirect_to(root_url) 
      else
        yield
      end
    end

    def for_users_by_type
      if @current_user
        yield :admin 
      else
        yield :anonymous
      end
    end

These methods are consumed by the controller like so:


    for_admin_only do
      render :html => @posts
    end

    for_users_by_type do |type|
      case type
        when :anonymous
          render :html => @posts
        when :admin
          render :template => 'admin/posts/index', :html => @posts
      end
    end

In the second snippet, we call for_admin_only first, which says that if the user is logged in, then run the specified snippet of code, otherwise redirect to the homepage (this could also redirect to a 403 page, or whatever else you prefer). Next, we call for_users_by_type, which passes back a type variable saying if the user is anonymous or admin. If the user is anonymous we render the basic view, if s/he’s an admin, we render the admin index view.

So head on over to the official github repository and check out the source! It’s very pretty! (EDIT: Also, you may see a summary of these details on the project wiki)

Announcing Ruby on Rails Blog Starter Kit

April 1st, 2008

I am currently working a Ruby on Rails Blog Starter Kit. This will be an open source blog application to serve as a base for anybody else’s blog. Thus far I have been unable to find a satisfactory blogging engine written in Rails. I’ve tried a number of them, but they all seem abandoned, or at least development is quite slow. Because of this, and my constant urge to become a better Rubyist (Railsist?) I decided to write my own. However, I have no interest in writing or using a “full featured” blogging platform. I want something small, easy to use, with only the features I need, instead of the features I might use… someday. I also like looking at sample code. When I first started with Rails I would have loved a good sample application that I could customize. The Ruby on Rails Blog Starter Kit is that app.

The Process

I have decided to take a structured approach to developing the Blog Starter Kit (BSK). I will be heavily following the practices of “release early, release often” and TDD to efficiently create a stable, maintainable system. I am planning one week sprints in which I will complete a subset of the features on my blog and have them online, somewhere. I have yet to figure out the number of sprints that will be required, it will depend on my velocity, which I have yet to determine. For anyone unfamiliar with the terms I am using, a sprint is a period of implementing a feature of a product, at the end of which the team usually has a working product, whether or not it’s feature-complete. Velocity refers to the amount of time it takes a programmer to complete a feature.

The Features

This will be a fairly basic blog, with reliance on third-party plugins wherever possible. It will have basic posting features, commenting, feeds (RSS/Atom/etc?), Akismet integration for battling comment spam, adding to del.icio.us & digg, Gravatar integration, tagging, Metaweblog API integration, dynamic modules, and an admin login through OpenId for creating new posts/managing comments (edit/delete). As stated above, the focus of this blog is not creating the next great blogging platform; I’m building a very simple blog app that meets my needs. I’m opening it up to the community as a starter kit for anyone learning Rails (seasoned professionals, complete newbies, or anyone in between) to fork/customize for his/her own needs. I will not be taking feature requests. Instead, I would encourage anyone who feels this is lacking to fork it and add the features for themselves.

The Future

I’m sure over time I will add additional features as I see the need. This should be a good basic set to start off with. I could see this starter kit kick off a series of “starter kit” apps for other developers to build from. For example, who wouldn’t want a project management starter kit? I would love to see a Rails starter kit community spawn from this initial concept. However, that is the future, and the future doesn’t actually exist, so let’s concentrate on the present :).

I will begin by posting my code on github. I will do my best to update the source control regularly. I will post some more information to the project wiki, including details on what features will be in each sprint.

acts_as_currency Ruby on Rails Plugin Released!

March 26th, 2008

Some time ago I wrote an entry on using a dollar sign with fields that are stored as decimals in your database in Ruby on Rails. As of tonight, the code I showcased is now available as a plugin! More information (including robust installation instructions, as it’s hosted on git) on this plugin is available in the README. Check out the source and give it a try! As always I appreciate feedback; unfortunately, I’m having problems with comments in Mephisto at the moment, so please email me your questions/thoughts: joe at faithfulgeek dot org.