Enter your email address to subscribe to this blog.

Recent Comments

Intro to Spring Security Core for Grails
Eric Pierce said: Thanks for these screencasts, Dan! You made it crazy simple to get up and running w/security core h... [More]

Removing duplicates from an array of objects
Arvind said: Great tip, can't thank you enough for this. [More]

Intro to Spring Security Core for Grails
Santosh said: Thanks much for putting up these screencasts. As the others here I'm a beginner and I've been having... [More]

Grails Spring Security Plugin - Logout postOnly setting
eriihine said: I still had some issues with this one. It seems that the href link is always generating a GET method... [More]

Intro to Spring Security Core for Grails
Dan Vega said: Just a heads up but I decided to write up a quick post on your question just in case it trips up any... [More]

BlogCFC mod rewrite rules

I just launched my new website this week and while I am happy there are still some things I want to clean up. Today we are going to take a look at cleaning up the urls in my blog a little bit. While I haven't pushed this into production at this time I have tested it on my local box so I thought I would share it with everyone. Let me stress here that I suck at rewrite rules and I am sure someone can point out a mistake here. So if you have comments or suggestions on how to do this better please speak up.

The urls for BlogCFC are pretty friendly out of the box but I think we can improve them a bit. Really when it comes down to it we are talking about 2 urls, the entry and category links. We want to take our links and strip the index.cfm out of them but it still needs to work with the index.cfm for links that already exist. Here is an existing entry and category link. Those URLS are ok but I want them to look like this

To accomplish this we actually need to create some rewrite rules and understand how BlogCFC works. First we will take a look at the rewrite rules, and more specifically mod_rewrite rules. Let's break these rules down starting with the entry. Before your actual rewrite rule you can make sure that a condition passes, think of it like a where clause in a sql statement. In this case we are using a special variable %{REQUEST_FILENAME} which is the full local filesystem path to the file or script matching the request. This will usually contain everything after host so in my case everything but With that we are using the conditions -f and -d which check to make sure its an actual file or an actual directory. We are telling the condition that we want to make sure these DONT pass, or not a directory or logical file. For the rewrite rule we are doing a few things. First we are making sure that it starts with blog/. In the next capture we are matching some regex. Basically we want to make sure its in the format of /blog/4 digit number/1 or 2 digit number/1 or 2 digit number/*(anything) Now that we have made a match we can rewrite the url to blog/index.cfm/$1. The $1 is basically everything we matched in our regular expression. Finally we add the flag QSA which stands for query string append. This just means that if there was a query string on the request, add it to the rewrite.

So that is the bulk of the work but there is still 1 step to go. BlogCFC has a setting in the blog.ini.cfm file for blogURL. Right now it probably looks something like this This is the url that blogcfc will use internally when you call functions like makeLink() or makeCategoryLink(). So to work with our new urls you will want to update that url and remove the index.cfm. That was not nearly as tough as I thought it was going to be. Like I said earlier, I don't have this in production yet but I plan to commit the code in the next couple of days. If you have any suggestions on how to improve these rewrites please let me know. As I said at the start of this, I stink at mod_rewrite rules and regex and its something I am trying to get better at.

Update: After committing the changes tonight I noticed one other issue. The captcha for the add comment was not showing up. The reason for this is pretty clear when you look at the add comment form. The url in our blog settings needs to be without the trailing / because of the way links are generated so I just updated this form by adding the / I suspect other small issues might pop up so if you see any please let me know.

Update:The other downer is that now that the links are technically different (no index.cfm) all of my facebook likes / tweets are reset to 0. booooooo

Update: I found another issue this time again with the way the url was being built in the email that gets sent after a comment has been place. I am not going to keep listing these out here but there seems to be inconsistencies on the way the full urls are being built. None of the links in templates use the / but methods that build the urls do.


BlogCFC Mobile Version

Just in case anyone didn't know, or forgot (guilty) BlogCFC ships with a mobile version. The mobile version was built by Dave Fergusion and I have to say he did a really nice job with it. The mobile version of your blog is built using the incredibly awesome jQuery Mobile. When you navigate to a blog powered by BlogCFC there is a detection script that will push you right into the mobile version. If you want to check it out for yourself you can simply browse to /mobile. The link below will take you to my mobile version if you want to see how it works. Just another reason why I love BlogCFC!


My New Website has launched

I have been working hard the last couple of weeks on putting together a new website. I am happy to announce that this site launched tonight. I still have some bugs to work out but nothing major. I needed a site that show of my hard work a little better so please look around and let me know what you think. A big thanks to BlogCFC, ColdBox and ColdFusion 9 for powering this site!


BlogCFC: Using cfmediaplayer in your posts

Yesterday I posted a video demo of my new ColdFusion Builder Extension. I recorded the mp4 demo using Jing Pro which I am really like. I was really tired of posted videos the way I used to. I would record a video, take a screen shot of the 1st frame, post the screen shot on my blog and link to a view in a new window.

Now that I am up and running on ColdFusion 9 I thought it was time to take advantage of cfmediaplayer. This tag does what all ColdFusion tags do, make something very easy to do. Just by passing a source you can embed a player that has all the controls as well as full screen capabilities. This is exactly what I needed, but how was I going to use it on myblog. I couldn't just use the following code in a blog post.

Continue Reading >>


Problems with Comments

I believe I have solved the issues I have been having with comments. There were some issues with the remember text that came up but I think we should be good going forward. Please let me know (danvega at gmail) if you have any problems leaving comments. Thanks for all of your help who let me know about this!

More Entries