CFBuilder Contest: Pastebin

This post is more than 2 years old.

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.

Download attached file.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Edy Ionescu posted on 5/6/2010 at 12:29 PM

'Do not click that URL. It never worked for me. I was able to cut and paste the URL into my browser though... '. This works as supposed to, at least on Windows (7).

There is a problem though with the editor selection being heavily cached. Updating line 12 in newpaste.cfm solved the issue.
<ide url="#adobeUtil.generateURL('pasteform.cfm?rnd=#RandRange(1,1000)#')#">

Comment 2 by Edy Ionescu posted on 5/6/2010 at 12:40 PM

Errata: I meant the cfm file being cached, not the editor selection.

Comment 3 by Dan Vega posted on 5/6/2010 at 4:58 PM

Thanks for the review Ray and thanks for putting on such a fun contest. I will update the extension tonight to address some of the issues.

Comment 4 by Adam Tuttle posted on 5/6/2010 at 5:11 PM

Neat idea, Dan. I may have to fork it and make it worth with Github's Gists, though; as that's my preferred paste/share workspace.

Comment 5 by Dan Vega posted on 5/6/2010 at 5:13 PM

Maybe we can come up with a universal name and create a code sharing plugin that has many options. It would be nice to share code using service x...

Comment 6 by Raymond Camden posted on 5/6/2010 at 5:15 PM

Yeah I was gonna say - I see no reason why one extension couldn't do both. Right click could show both "Share on Pastebin" or "Share on Gists".

Comment 7 by Dan Vega posted on 5/6/2010 at 11:10 PM

Nice find Edy! Does anyone know why that caches like that? What is doing the caching there and is there a way to prevent that? In my case I don't ever want that screen cached, well maybe everything but the the text area with the code.