3 Dec

Implementation idea: .do templates

December 3rd, 2007 — 10:05 am Chris

It’s been awhile since I’ve posted, so: “Hello everyone!”

I’m tossing around a new idea for slate, and I thought I’d post it here to get some feedback. The idea revolves around the concept of “behaviors” for pages in slate. Please bear with me as this is going to be a messy post – the ideas are still swirling around my head.

Current implementation

First, some background information: when a request comes in, slate extracts the path and attempts to find a page matching the path. If it can’t find a match, it attempts to find a “behavior” matching the path. If that succeeds, the behavior is executed (which handles rendering the page based on the path).

The idea is that you assign a page, say blog, the blog behavior, and slate will now know that the page has certain routes. That is, /blog/2007, etc.

Well, that’s all well and good, but there are problems with this implementation. In short, it’s messy. It’s also confusing for the user. So, I’m planning on doing away with the current implementation, opting for something a bit easier to manage.

The .do template

The new idea is this: specialized theme templates, say blog.do.rhtml that handle the behavior without configuration. How will this work? When a request comes in, slate will check to see if the path contains .do. If there’s a match, it will extract that portion of the path and render the associated template.

For example, /blog.do/1/2007 would render blog.do. I’m thinking there will also be a blog.do.rb file which will act as a pseudo-controller for handling these .do templates. Or, maybe the theme will support a blog.do directory, containing custom view templates. Obviously, the details haven’t been worked out yet ;-)

Pros and cons

  • Pros
    • Consistent URLs for behaviors (blogs will always reside at /blog.do/:id)
    • Less configuration (no need to create a page and assign it a behavior)
  • Cons
    • Less end-user control of (no more /something/blog)
    • Slightly more ugly URLs
    • How to provide editable areas for behaviour-driven pages?

Thoughts?

Clearly, this concept is still up in the air. But if you can understand at all what I’m going for, please feel free to post your thoughts :-)

#1: Ryan said on Dec 4 at 4:04 pm

Assigning pages behavior seems to make sense, since it’s a CMS and users can manage their content how they see fit. And to me, implementing your blog.do idea wouldn’t take away from that, but it’d seemingly make it much easier for you and the users because it would just work.

I’m fairly picky about URLs, but that’s probably because I’m fairly picky about most things in my life. Anyway, /blog.do/2007 is a little more ugly than /blog/2007, but I think the fact that it takes care of itself overrides that. Plus, I think I’m picky about URLs because I’m a developer. The average user won’t care about that at all most likely. What about /blog/do/2007? Eh… I don’t know… I think I like blog.do better. I like the way it feels like it’s saying “do this” instead of a parameter. And I really like the consistency that all blogs would reside at /blog.do/:id/.

As far as the rest of it, I don’t think I could contribute to the issues of editable areas and directory or blog.do.rb. But from these spinning ideas, it seems like you’re on to something.

Who knows, it’s about 30 hours past the time you posted this… you could already have it done by now!

Add comment

You are adding a new comment