0 Comments By Damon on Nov 29 in Programming and Website.

With all other sections of the site supporting pretty URLs, I thought it was only fair to take all those dirty URLs in the music section and giving them a bath for lack of better words. Tidying these up was no easy task. It was actually somewhat more difficult than I first would have expected. As it turns out, it was a blessing in disguise since at the time I was coding up the music section, my RoR kung fu was not even up to Mr. Miyagi's standards. Thus, it took some serious re-factoring to get things functional again. So what did I actually end up doing? Well, I thought URLs like the following were a bit bland and didn't provide any context for the user.

http://ruby.epartment54.com/music/track/1217
http://ruby.epartment54.com/music/album/389
http://ruby.epartment54.com/music/artist/445

As you might guess, those numbers above at the end of the URL are nothing more than the id of each track/album/artist. Boooorrring! I therefore decided that I would use a combination of the id and track_title to generate a unique permalink for each one. Now they look more like this...

http://ruby.epartment54.com/music/track/1217-freak-on-a-leash
http://ruby.epartment54.com/music/album/389-korn-greatest-hits-vol-1
http://ruby.epartment54.com/music/artist/445-korn

Ahhhh, much better. Now a user can infer some context just from the URL.

Why tag the id on, right? Well, I decided to add that to ensure a unique permalink each time as some tracks/albums/artists may have the same name (e.g., track title, artist name, album name) and thereby a permalink wouldn't work so well without some other unique value in the permalink.

With all that said, hopefully there aren't any bugs. I wrote a bunch of tests to make sure this is working, but if you discover strangeness, let me know!

UPDATE

After thinking about it a bit more, I didn't like the previous format so I've updated it to the following.

http://ruby.epartment54.com/music/track/1217/freak-on-a-leash
http://ruby.epartment54.com/music/album/389/korn-greatest-hits-vol-1
http://ruby.epartment54.com/music/artist/445/korn

I thought it provided a better representation of the 'thing' you are viewing in comparison to having the id included right in the title of the 'thing'.

Current Rating: 5.0 rating from 1 vote

  • Current rating is 5
  •  
  •  
  •  
  •  
  •  

No Responses to "Music Takes a Bath"

Comments are Closed

Name: (Required)
Website:
Comment:
Remember my info