Routing around #announcement fstdt.com blog

Phew this is long, don't forget to check below for FOTY nominations, they're still open for the next week.

Routing, mentioned it before and most people probably have no clue what it means, so while I'm sorting it out I'll explain what I'm up to.

The last preview I posted requires a URL like this: http://localhost:60349/Quotes/Index?TagID=2&Year=2008&Month=12&Page=3 Very nice and clean looking right? Well, that's because I haven't handled a damn thing beyond the basics in the routing configuration.

I'll break this down real quick.

http://localhost:60349
This is just my local webserver, funny looking but keeps me from having to publish things to someone else's server

/Quotes/Index
These are the basics of the MVC routing system, /{Controller}/{Action}. I have a controller named Quotes to display the various quote listings and since I'm a lazy ass my default action within the Quotes controller is Index while I get things working. Later I'll be swapping out Index for the type of quote listing you're receiving since I need to make entirely different calls for the same controller depending on the request made. So eventually that portion will look like /Quotes/LatestComment, /Quotes/Newest or /Quotes/Random and each of these would take you to the first page for that particular listing. Notably, this arguably isn't exactly what actions are for as they are supposed to be distinct actions, but given the rather significant differences in calls and otherwise uselessness of doing otherwise I'm using the action to do this split.

?TagID=2&Year=2008&Month=12&Page=3
This mess, actually not too different from what we have now, but it's what I can do to the routing engine that is worth talking about. I cant take the above and turn it into this:
/2/2008/12/p3
Easily, with a bit more work I can do this:
Conspiracy/2008/December/p3
Which finally gives you a real idea of what page is coming up, it's the third page of CSTDT for December 2008. Only backwards because I have not yet been assed to consider routing validation that would let me swap the place of month and year. What sense does that make? Well, if I setup the routing well enough I can make sure it knows what to assume when part is missing so that this:
Conspiracy/2008/December/
Takes you to the first page for December or this:
Conspiracy/2008/
Takes you to the first page for all of 2008 or finally this:
Conspiracy/
Just takes you to the latest quotes in that tag.

So, routing lets me go from what we have today:
http://www.fstdt.net/QuoteArchives.aspx?Archive=2&Date=2008/12&Page=3
to
http://www.fstdt.net/Quotes/Newest/Conspiracy/2008/12/p3

Cleaner looking huh. Especially without the month getting converted to text, odds are I'll wind up supporting both number and text representations both at the same time with a bit of work on the routing system. Complex crap to make simple URLs without any of the things you don't have a clue what they are in the URL. It's all stuff that looks like it belongs there.

How this helps me handle the filters, well, what I'm looking at doing right now is having a little pop down menu where you go in and hit the tags and dates you want to read through and immediately take you through to the right page. If anyone cares about the loss of easily visible month numbers let me know, I'm still poking at this.

And a last thing, this also means with some more routing work I can support all of the old URLs you already have favorited. Relatively easily in comparison to what I'm pulling now.

2 comments

Confused?

So were we! You can find all of this, and more, on Fundies Say the Darndest Things!

To post a comment, you'll need to Sign in or Register. Making an account also allows you to claim credit for submitting quotes, and to vote on quotes and comments. You don't even need to give us your email address.