FarCry LESS Plugin

Today I released a plugin for FarCry that will automatically compile your LESS files into CSS. No more need to compile on your development machine before you push to production, and no more need to punish your users by compiling on the client side with Less.js. While those solutions are perfectly acceptable, this plugin will let you simply code in LESS, then let FarCry do the work of serving compiled, minified CSS to your users.

The plugin uses a similar syntax to FarCry's built in skin:loadCSS tag so it should be instantly familiar. Be sure to read the installation instructions to avoid a couple of potential "gotchas".

Check it out on Github, and let me know if its useful for you, or if you would like to see any additional features.

FarCry Solr Pro

Jeff Coughin and I just launched a new FarCry plugin to enhance the search capabilities of your FarCry website. Check out his announcement or the plugin website for more information.

Github Gist renderer for BlogCFC

I created a quick renderer for Github Gists for use within BlogCFC entries. You can see it in action right here. If interested just grab the code from the gist below and save it to /org/camden/blog/render/gist.cfc. You can then use

view plain print about
1<gist id="[gist id]">
to include the gist in your entry. If you want to constrain the height you can use CSS like:
view plain print about
1.gist .gist-file .gist-data {
2max-height: 250px;
3}
Here is an example of what the output looks like, using the Gist I created to hold the code for the renderer. Feel free to grab it for your own BlogCFC install.

FarCry Slider Formtool

I posted this on the farcry-dev mailing list but thought I would post it here as well to help future googlers in need.

I have created a slider formtool for a client and thought it could be useful to others in the community. You can find the source for it here: https://gist.github.com/1230366

[More]

FarCry YouTube Plugin

One of our clients asked for better integration of their YouTube hosted videos on their FarCry website. They had been linking to the youtube.com URLs directly, leading traffic away from their website. Obviously, they would have preferred to keep those visitors on their site and engaged.

As some other clients have also expressed a desire to display YouTube videos on their sites, I decided to build the functionality as a FarCry plugin. This would allow me to move this feature set to any FarCry site.

At its foundation, the plugin works via two custom types and a scheduled task. The scheduled task runs and uses the YouTube API to grab the playlists and videos on the specified account (configurable via a FarCry config). If it finds those objects already in FarCry, it updates them with the latest data from YouTube, if its new, it adds it to the FarCry database. Any items found in FarCry that aren't returned by the API are deleted. The plugin gives you the ability to reorder the videos on a playlist via the FarCry webtop. All data is managed on the YouTube side. I may consider adding the ability to completely manage the videos and playlists on the webtop, but that will greatly increase the complexity of the plugin, and I don't see a great benefit to doing so. To me, it makes more sense to go straight to the source to upload new videos, manage your videos, etc rather than try to stuff all that functionality into a FarCry form. No need to reinvent the wheel, in my opinion.

The plugin also includes two rules. One lists videos based on selected playlists or videos, the other displays an embedded video.

To interact with the YouTube API, I made use of Raymond Camden's awesome YouTube CFC.

I am happy to say that I have also posted this code on Github for the entire community to use. Give it a try! If you have any ideas for improvement please open a ticket, or better yet, fork the project and send me a pull request.

You can find the project on RIAForge and Github.

How I Got Started in ColdFusion

Steve Bryant suggested that Aug 1, 2011 be "How I Got Started in ColdFusion" day. I think that is a great idea, and would like to share my story.

[More]

FarCry Poll Plugin

I have released a plugin I have had for a while. I'm not sure why I never got around to releasing it. Its a very simple FarCry plugin that gives you the ability to create a one question poll and display it on the site. It uses a couple content types and a rule.

To install, copy the files to /farcry/plugins/spcPoll and add "spcPoll" to your "this.plugins" setting in your FarCry constructor. Deploy the content types in the COAPI manager and restart the application. You can now create a question, assign answers to it, and deploy that question using the "Poll: Display Poll" rule.

You can grab the code on Binpress or Github. Its also attached to this entry via the download link below.

Let me know what you think!

A FarCry plugin for Hoth: ColdFusion Exception Tracking

Just a quick note to mention that I have released a FarCry plugin for the Hoth exception tracking framework. If you are interested take a look at the code on GitHub and let me know what you think. I have also included a zip file of the code attached to this entry.

SVN, Apache, and mod_caucho, oh my

I recently set up a new Viviotech VPS and ran into an issue that was easy to fix once I realized what was happening, but difficult to debug. I set up Railo running on the Resin server using Apache as a front end with mod_caucho. In my httpd.conf file I had the following lines:

view plain print about
1LoadModule caucho_module /usr/lib/httpd/modules/mod_caucho.so
2ResinConfigServer localhost 6800
3CauchoConfigCacheDirectory /tmp
4CauchoStatus yes
This causes Resin to handle all requests from apache. The resin configuration files tell resin which URLs to handle. I also had an SVN server set up so I had a configuration file in /etc/httpd/conf.d/ to set up subversion. All my SVN repositories are under the location /svn. So reading SVN repositories worked fine, but I kept getting "path not found" errors when committing new files. After debugging this for quite a while using Fiddler, and other means, I finally realized that Resin was actually handling the PUT http request and, finding no file, returned a 404. So to fix this, and simply have Apache handle any request to /svn/ I modifed my httpd.conf file as follows:
view plain print about
1LoadModule caucho_module /usr/lib/httpd/modules/mod_caucho.so
2<LocationMatch ^((?!/svn/).)*$>
3ResinConfigServer localhost 6800
4CauchoConfigCacheDirectory /tmp
5CauchoStatus yes
6</LocationMatch>
then restarted Apache. Now apache handles any requests to /svn/* and Resin handles all other requests. Hopefully this helps future Googlers in need.

Filtering a CFGrid

So you want to filter a CFGrid huh? ColdFusion makes this easy!

First you need a CFC method that will return the query used to populate the grid. This method should take the cfgrid parameters and the value you want to filter on.

data.cfc:

view plain print about
1<cfcomponent>
2<cffunction name="getdata" access="remote" output="false"
3returntype="Any">

4<cfargument name="page"
5required="false" default="1" type="Numeric" />

6<cfargument name="pagesize" required="false" default="10" type="Numeric"
7/>

8<cfargument name="sortcolumn" required="false"
9default="" type="string" />

10<cfargument name="sortdir"
11required="false" default="ASC" type="string" />

12<cfargument name="filter" required="false" default="" type="String"
13/>
>

14<cfset q =
15queryNew('id,name','integer,varchar') /
>

16<cfset queryaddrow(q,1) />
17<cfset querysetcell(q,'id',1)
18/
>

19<cfset querysetcell(q,'name','sean') />
20<cfset queryaddrow(q,1) />
21<cfset
22querysetcell(q,'id',2) /
>

23<cfset
24querysetcell(q,'name','phillip') /
>

25<cfset queryaddrow(q,1) />
26<cfset querysetcell(q,'id',3)
27/
>

28<cfset querysetcell(q,'name','steve') />
29<cfquery name="q" dbtype="query">
30select * from q
31<cfif
32len(trim(arguments.filter))>
33where name like <cfqueryparam cfsqltype="cf_sql_varchar"
34value="%#arguments.filter#%" />
35</cfif>
36<cfif
37len(trim(arguments.sortcolumn)) or len(trim(arguments.sortdir))>
38order by #arguments.sortcolumn# #arguments.sortdir#
39</cfif>
40</cfquery>
41<cfreturn
42queryConvertForGrid(q,arguments.page,arguments.pageSize) />

43</cffunction>
44</cfcomponent>

You can see here that I am just hard coding the query in, you would replace this with your cfquery call to your database or a call to your service layer, etc. Once you have your query results, you want to use the queryConvertForGrid method to format the result to a value that CFGrid can work with.

You then need a cfgrid! The trick here is how to get the grid to refresh as the user types a value in the filter box. ColdFusion Ajax UI tools have bind expressions that let us bind one control to another, and to react to events.

index.cfm:

view plain print about
1<cfform>
2<p><label for="filter"><cfinput type="text" name="filter"
3id="filter" />
</p>
4<cfgrid format="html"
5bind="cfc:data.getData({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},{filter@keyup})"
6name="grd" bindonload="true">

7<cfgridcolumn name="id" />
8<cfgridcolumn name="name" />
9</cfgrid>
10</cfform>

You can see my bind expression in the cf grid. It will call the getData method of my data.cfc and pass in the value from the "filter" input box whenever the key is released. ColdFusion provides other events you can react to as well, check the docs for details.

So now if you run index.cfm you will see a simple form with a text input and a grid. the grid will load when the page is run (bindonload="true") and as you type in the text box, the results are filtered.

EDIT: removed the example link as I have moved this blog to Railo

More Entries

Fork me on GitHub