Tonight I installed Ionic's ISAPI Rewrite filter on my server and set it up for this domain. I've always been a fan of the www-less URL, so now you don't have a choice -- I'm redirecting you here. In addition to that, I'm making urls like /page.cfm/projects/burnt-mango accessible as /page/projects/burnt-mango. I even took it a step further and redirect you to the new pretty format from the old ugly format, in case there are any errant URL's going around.
The first thing I had to do, once I got the ISAPI filter installed and running, was to define my rewrite rules:
###### force removal of www. prefix on all requests
RewriteCond %{HTTP_HOST} www.fusiongrokker.com(.*) [I]
RewriteRule ^/(.*) http://fusiongrokker.com/$1 [I,R=301,U,L]
This takes care of getting rid of "www." from the URL.
###### Mango Blog stuff
#redirect old url's to their new fancy url's
RewriteRule ^/post.cfm/(.*)$ /post/$1 [R=301,I,U]
RewriteRule ^/page.cfm/(.*)$ /page/$1 [R=301,I,U]
RewriteRule ^/archives.cfm/(.*)$ /archives/$1 [R=301,I,U]
RewriteRule ^/author.cfm/(.*)$ /author/$1 [R=301,I,U]
These will redirect you from the old page.cfm/page-name format to the new page/page-name format.
#standard mango rewrites
RewriteRule ^/post/(.*)$ /post.cfm/$1 [I,U,L]
RewriteRule ^/page/(.*)$ /page.cfm/$1 [I,U,L]
RewriteRule ^/archives/(.*)$ /archives.cfm/$1 [I,U,L]
RewriteRule ^/author/(.*)$ /author.cfm/$1 [I,U,L]
And lastly, these rewrite the new page/page-name format as page.cfm/page-name so that Mango can still interpret them correctly.
Notice that for all of my redirects ([R] flag) I'm using R=301. 301 is the status code for Moved Permanently, rather than the default of 302, Moved Temporarily. This will tell search engine spiders and other smart things to update themselves; as well as preserve any PageRank that the old URL might have had. The L flag stands for "Last" and indicates that no further rules should be processed after this one is matched. In this case, I'm using it to prevent circular references, where going to page/page-name rewrites as page.cfm/page-name, which redirects to page/page-name which rewrites as... yeah.
Update: As suggested by Seb Duggan in the comments, I've combined the above rules into these two simple lines:
#redirect old url's to their new fancy url's
RewriteRule ^/(post|page|archives|author).cfm/(.*)$ /$1/$2 [R=301,I,U]
#standard mango rewrites
RewriteRule ^/(post|page|archives|author)/(.*)$ /$1.cfm/$2 [I,U,L]
After the rules are in place, we have to tell Mango how to output URLs in the new format. It uses a special file called config.cfm which contains your blog settings.
<node name="blogsettings">
<map>
<entry key="searchUrl" value="archives/search/"/>
<entry key="postUrl" value="post/{postName}"/>
<entry key="authorUrl" value="author/{authorAlias}"/>
<entry key="archivesUrl" value="archives/"/>
<entry key="categoryUrl" value="archives/category/{categoryName}"/>
<entry key="pageUrl" value="page/{pageHierarchyNames}{pageName}"/>
</map>
</node>
These are just the relevant settings, I've left the rest out for brevity. They should use the format that you want the user to see the URL as, because this is what Mango uses to format its links.
I keep finding more and more reasons to love Mango. This is just another one of them.
Posted in
Mango
| 17 Responses
July 31 2008
This year is A List Apart's second year running their Survey For People Who Make Websites. I just completed it (18 pages, average 2-3 questions per page) in about 8 minutes, so what are you waiting for?

Posted in
Meta
| No Responses Yet
July 29 2008
Best Practices is something that I don't think anyone, anywhere,
ever gets 100% right. There's no "right" way to do everything. But
we're striving to do things better all of the time, right?
For example, in the ColdFusion world we have Unit Testing frameworks like MxUnit, CFUnit, CFCUnit, and Selenium. I know Selenium isn't just for CF, but it does integrate nicely! Test-driven Development is all the rage these days, and while that's a good thing it's not for everyone and certainly something very difficult to "get right."
Consider that in a large project -- one with 1,000 test cases -- if you refactor some code that affects 10% of your tests, you have to re-write 100 test cases. This isn't to say that TDD is a bad thing... far from it! Just that there is no silver bullet, and that you always have to be thinking ahead to try and do things right the first time, and not repeat yourself.
This brings me to a change I recently made in Grub.
Grub uses the Model-Glue framework to, as I like to say, "code less and do more." In Model-Glue's XML config, we have an <include> tag that allows us to separate our config into logical sections to keep maintainability high. But did you know you can do the same thing with your ColdSpring XML config?
Well, not with out-of-the-box 1.0... You have to download the Bleeding Edge Release, here. The feature was first mentioned in November of 2006, when Jared announced that he had written it. It was then blogged by a bunch of other ColdSpring users, but I don't think any of them mentioned that it wasn't yet included in the official release except Mark Drew, and even then I don't think I picked up on that fact until well after my second or third reading of his post. I ended up reading this bug report that clued me in, after about an hour of trying to figure out why the necessary method wasn't where it should be.
After you download the BER and update your local copy of ColdSpring, you can add lines like the following to your beans XML:
I used this code to separate out my Model Glue config -- which will be constant in every environment, but different between them (debug, reload, allow event generation in dev; no debug, no reloading, and no generation in production or staging) -- from my bean definitions, which change frequently as I work on the applicaiton. Now, with my ANT build script, I can build and deploy my project without ever thinking about config, and I know it will always be right because it will never change without me doing so manually.
I'm somewhat surprised that over a year has gone by and it's still not included in the official release. This means that I'm currently using two unreleased frameworks in Grub (the other being the Model-Glue 3 RC), and that I am going to have to include them both in the download to make it as user-friendly as possible.
Posted in
Best Practices |
ColdFusion |
Frameworks
| 5 Responses
July 29 2008
3 plugins released in 3 days?! Is this guy nuts?
Apparently? Yes.
Today I bring to you a Lightbox2 plugin for Mango. This was really
fun to build and is super simple to use. I'll let the project page do
the talking:
My new friend Mark Aplet asked me to take over development of the Lightbox2
plugin that he started, and I happily abliged. This plugin will add the
necessary JavaScript and CSS to every page Mango outputs (aside from
admin), and enables advanced linking in TinyMCE.
In order to use Lightbox, you then simply create a link (its
contents can be anything: image, text, etc) and in the link dialogue,
on the advanced tab, choose "Lightbox" from the "Relationship page to
target" drop-down. That's it!
Download the latest version: Lightbox2 Mango Plugin Beta1 (0.1)
Posted in
JavaScript |
Mango
| 5 Responses
July 26 2008