Welcome to the second entry in the ColdFusion Builder Contest. Today’s entry is Pastebin by Dan Vega. As you can probably guess, this is an extension that gives you integration with the Pastebin.com service. Pastebin is a quick way to share code with others. They have many code highlighters (including one for our framework) that will “pretty up” your paste as well. Let’s take a look at Dan’s extension.
After installing his extension, you get a right click option for both files and within the code editor to run Pastebin. Once you've done either, the extension pops open a window with your options:
The Paste Format drop down is where you pick the formatter for your code. ColdFusion is there of course, and I've told Dan it would make sense to put it on top. Not because I think ColdFusion is more important than any other language. (Wait, I do actually.) But I think it is fair to assume the 99% of the use of this extension will be for ColdFusion. In fact, I'd probably put CF, JS, XML, and CSS on top for quick access to your common formats. (A really smart extension would store data about your picks and move them up to the top automatically. That brings open a whole other discussion about "self-evolving" CFBuilder extensions.)
Once you finish selecting your options and hit submit, you will be presented with the URL to your paste. Do not click that URL. It never worked for me. I was able to cut and paste the URL into my browser though...
Sorry, that isn't the best screen shot, but wonder over to Pastebin.com yourself for examples. You can also click here to see an example of something I just pasted via the extension. (Something from BlogCFC6.)
It worked well - except when I right clicked on a folder. His extension didn't filter on files so that's something he will need to fix. Of course, I brought it up with him and we had this great exchange:
I swear I'm not that flippant on IM most of the time. ;) But it brings up the issue we saw in the previous entry. One of the things extension developers really have to look out for is proper handling of the file and folder resources sent to their code. As I prepare for my SOTR presentation on extension development, I'm seeing a lot of interesting things folks should be aware of. It's not something that makes extension development hard per se, but you really need to keep it in mind. A great example: You can filter a right click menu on a type of file, like *.cfc, but the filter allows you to select a CFC file and any other file. If your extension assumes it only got the proper file than it will crash and burn. I'm a bit off topic now but I think you get my drift.
On the code side, I don't have much to complain about. Dan, too, makes use of the Application scope to get around Session issues. As I said before, I'm definitely going to be using that as well in the future. I will point out Dan's org.vega.builder package. He has some utilities there to help parse the XML CFBuilder sends to extensions. I was thinking today that a nice library to help automate that parsing would be nice. I think I may try to talk Dan into possibly packaging this up and posting it to RIAForge. I've got some ideas about other common utilities that I think could be added as well.
All in all - this is really a very simple extension. It does one thing and does it well - but I really think it demonstrates just how darn powerful CFBuilder's extension support is. I know some folks who use Pastebin multiple times a time, and I bet this would really come in handy.
A quick note. I'm including the extension as an attachment to this blog entry. However, later tonight I'll be approving Dan's RIAForge project for the extension. Please grab that version when posted. I'll post a comment so folks know when it is available.