Another ColdFusion Builder Extension example

This post is more than 2 years old.

Every day I use ColdFusion Builder I like it a bit more. Last night I built out a new extension. Before I describe how it works, let me demonstrate with a video (and once again I apologize for the size - my 30 inch monitor spoils me):

This extension demonstrates how you can hook into the "New Project" action of CFB. In this case I added support for generating a "skeleton" application for Framework One. FW/1 doesn't ship with a skeleton application in the zip. I've logged a request for it - but honestly, with FW/1 having such a small amount of absolutely necessary files, it may not make sense. However - there are some things that I think a typical FW/1 application will need - hence the need for the extension. So what does the code look like? First, here is the XML for my ide_config.xml:

<application> <name>FW/1 Assistant</name> <author>Raymond Camden</author> <version>0</version> <email>ray@camdenfamily.com</email> <description>intro.html</description> <license>license.html</license>

<menucontributions>

</menucontributions>

<events> <event type="onprojectcreate" handlerid="projectcreate" /> </events>

<handlers> <handler id="projectcreate" type="CFM" filename="projectcreate.cfm" /> </handlers>

</application>

As you can see it has one event defined - projectcreate - that then links to my handler. The handler is pretty simple as well:

<cfparam name="ideeventinfo">

<cfset xmldoc = XMLParse(ideeventinfo)>

<cfset project=xmldoc.event.ide.eventinfo.xmlattributes["projectname"]> <cfset projectloc=xmldoc.event.ide.eventinfo.xmlattributes["projectlocation"]>

<!--- Create the following folders /controllers /layouts /services /views /views/main

Create the following files: /Application.cfc /index.cfm /views/main/default.cfm --->

<cfdirectory action="create" directory="#projectloc#/controllers"> <cfdirectory action="create" directory="#projectloc#/layouts"> <cfdirectory action="create" directory="#projectloc#/services"> <cfdirectory action="create" directory="#projectloc#/views"> <cfdirectory action="create" directory="#projectloc#/views/main">

<!--- copy my _App.cfc (named so as to not be a real app.cfc) ---> <cffile action="copy" source="#expandPath('./files/_App.cfc')#" destination="#projectloc#/Application.cfc">

<!--- copy my index.cfm ---> <!--- FYI, yes, index.cfm is blank, so why bother using a file at all? Well, if in the future stuff goes in there, this will be a bit more future proof. That's my logic for now. ---> <cffile action="copy" source="#expandPath('./files/index.cfm')#" destination="#projectloc#/index.cfm">

<cffile action="copy" source="#expandPath('./files/default.cfm')#" destination="#projectloc#/views/main/default.cfm">

Basically the extension simply makes a few folders and copies three 'template' files over into the new project.

I'm not sure if I'll release this as a proper RIAForge project. I'd like to hear what other FW/1 users think and see if they have ideas on how to expand it. (And yes, I'm also supposed to be working on the Model-Glue CFB extension - sorry - I get distracted easily by shiny objects.) I've included a zip to this entry. Enjoy.

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 Jason Brookins posted on 2/9/2010 at 7:53 PM

I, for one, would love to see this in RIAForge. I'm just now getting into FW/1, so this would be a time-saver.

Comment 2 by Zarko posted on 2/9/2010 at 8:25 PM

This could be extended over time, so thumbs up for riaforge.

Comment 3 by Joe Brislin posted on 2/9/2010 at 9:52 PM

I think skeletons are useful no matter what type of framework that you're using. It always gives you a clean slate to start with and helps speed up development. I would also love to see this in RIAForge.

Comment 4 by Dan Vega posted on 2/9/2010 at 11:05 PM

I always wondered how I could use the project create event, great example!

Comment 5 by John Allen posted on 2/10/2010 at 12:16 AM

Great example.

This post is ALSO cool cause it mentions FW/1, and FW/1 ROCKS!

Comment 6 by Dan Fredericks posted on 2/10/2010 at 2:32 AM

I like it...of course if you cf9 at a remote server, you have to create it locally, then copy it to your cf9 server...it beats remembering all the folders and files.
I was wondering why you did not include the org/framework.cfc folder into your install?
Did you not do this because that folder should be created outside your framework and just extend to it?

thanks for this CFB extension.

Comment 7 by Gary Funk posted on 2/10/2010 at 2:49 AM

FW/1 is the first framework I have seriously worked with. I picked it because I got in on the ground floor and am learning along with everyone else.

Honestly Ray, this extension will help me use FW/1 more, which I view as good.

Comment 8 by Raymond Camden posted on 2/10/2010 at 2:57 AM

@Dan: I made the assumption that you had already "installed" the FW/1 framework (I hate to say install when its all of one file ;).