Design questions on creating digg.com-like URLs (are they considered RESTful?)

Hi everyone, I'm working on creating a site that functions similar to digg.com (please no "no more digg clones" remarks please! :slight_smile: ). One thing I really like about digg is there URLs are very nice to read and I would like to emulate that without having a lot of actions spread out all over my application.

So in my app I have three main resources:

Users, Tags, and Items (equivalent of digg's bookmarks)

I want to create URLs that look like this:

/views/:when (where :when can be (today|week|month|year|upcoming) ) /tags/:tags/:when (:when same as before and :tags like rails+ruby+hannson) /users/:username/:type ( where :type can be (voted|submitted|commented|homepage) /users/:username/friends/:type (:type same as before)

I guess some obvious other ones are /users/:username/tags/:tags/:when and /users/:username/friends/:tags/:when

So given this URL design system, what kind of routes would one need and approximately how many actions (spread out over how many controllers - should I just have them all in the ItemsController)? I'm currently thinking of having four actions under the ItemsController (tags, view, user, userfriends), but I'm not sure if this is enough or too many. Because other than the top tab/subtab part of the view everything beneath that is the same (summaries of the items).

Apologies on the long post, I'm the kind of person that if I don't have something figured out before I jump in I kind of get into analysis-paralysis mode so even some confirmation that this system makes sense would really help!

Thanks!

-C

Hi,

I just saw your post, and I’m going to be working on a digg-clone for a client too over the next month. I haven’t figured out the answer to your question yet, but I wouldn’t mind exchanging design ideas throughout the process if you’re interested

-Sidney

You could try using a single main action in each controller, probably 'list' or something equivalent, that can take a hash of conditions to use as its finder string.

I'd say limit the controllers to things you are actually displaying. So mostly, people will be looking at items, right? So most of those urls are just ways of filtering down item views.

So you'd build routes like:

map.connect 'views/:when', :controller=>'items', :action=>'filter_by_time'

and then build actions like:

ItemsController < ApplicationController

def filter_by_time   conditions = { 'posted' => params[:when] }   list end

def list(conditions = {})   Item.find(:all,:conditions=>conditions) end

I'm not sure if that would work out quite right for you or not, but it seems like the way to go. You might have to build in more parameters for the finder, especially for taggable items, but I think that would probably work fairly well.

Of course, I could be totally wrong! Either way, hopefully this helps you.

caleb