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

To use, simply download the CFC, and place it in your projects /farcry/projects/projectname/packages/formtools directory. Once there, you specify the metadata in your custom types as you would use any other formtool.

view plain print about
1<cfproperty ftLabel="Num. of Apples" name="numApples" type="integer" ftType="slider" ftMin="1" ftMax="100" ftStep="1" ftOrientation="horiztonal" />

The formtool is an extension of the numeric formtool found in core, so you can use any of the features found from that formtool in the slider (ftPrefix, ftSuffix, etc).

The slider formtool adds 4 new metadata options. ftMin, ftMax, ftStep, and ftOrientation. Min and Max are the lowest and highest values allowed for the field. ftStep is the increment factor the slider will use. If you specify one, each slide of the slider will move the value by 1, if you specify 0.5, it will increment it by 0.5 (1, 1.5, 2, etc). ftOrientation can be either "horizontal" or "vertical" and it will orient the slider either horizontally or vertically.

Your users can either type a value into the text box or use the slider to select a value.

This uses the jQuery UI Slider widget (http://jqueryui.com/demos/slider/) so you can use it with FarCry 6+ since core ships with jQuery UI built in.

If you find it useful, missing a feature, broken, etc please let me know. Consider it released under a "do whatever you want with it" license.

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.

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.

Integrate a Model-Glue Application into FarCry

I'm sure there are other ways to do this but this is how I was able to integrate an existing Model-Glue application into a FarCry site. I am using ModelGlue 2.0, the latest ColdSpring BER as of this posting, and the latest beta of reactor. My MG app in question is a events calendar. Its a pretty simple application using MG, Reactor, and ColdSpring. Because I don't want to use ColdFusion mappings (and its running on CF7 so no per application mappings) I copied modelglue, reactor, and coldspring into {farcry_root}/projects/{site_name}/www as www/modelglue, www/reactor, and www/coldspring. If you are using mappings you can skip that step. Next, I created a simple include file called _mgCal.cfm in {farcry_root}/projects/{site_name}/includedObj. The code for this is as follows:

view plain print about
1<!--- @@displayname: Calendar --->
2
3<cfsetting
4enablecfoutputonly="no">

5
6<cfinclude template="/mg/mgCal/index.cfm"
7/>

8
9<cfsetting enablecfoutputonly="no">
Now, in the FarCry webtop, under the site tab, navigate to the root node, and under utility, create a new navigation node called "Calendar" and under that, a new include called "Calendar". Publish both. The friendly URL should be /go/calendar, but it can be whatever you like. Now we have to copy our MG application into the site tree. Create a new folder called "mg" under the www folder. This is where all my MG apps will live. So I copy my "mgCal" folder from my test site into the "mg" folder I just created giving me a directory structure like so:
/www/mg/mgCal/
/www/mg/mgCal/config
/www/mg/mgCal/controller
/www/mg/mgCal/model
/www/mg/mgCal/views
/www/mg/mgCal/Application.cfm
/www/mg/mgCal/index.cfm
etc
Now we have a few modifications to make to the MG app to get it to run from this location. Depending on how you first created the MG app, your settings may be different. In your MG App's index.cfm file add the following line above the <cfinclude> that calls Model-Glue.
view plain print about
1<cfset ModelGlue_LOCAL_COLDSPRING_PATH =
2getDirectoryFromPath(getCurrentTemplatePath()) &
3"/config/ColdSpring.xml" /
>

Now MG can find your ColdSpring configuration file. In your ColdSpring configuration file edit the following properties: In your modelGlueConfiguration bean: The paths should be straight forward, but your defaultTemplate property must be set to the FriendlyURL of your include.
view plain print about
1<property
2name="viewMappings">
<value>/mg/mgCal/views</value></property>
3<property
4name="generatedViewMapping">
<value>/mg/mgCal/views/generated</value></property>
5<property
6name="configurationPath">
<value>/mg/mgCal/config/ModelGlue.xml</value></property>
7<property
8name="scaffoldPath">
<value>/mg/mgCal/config/scaffolds/Scaffolds.xml</value></property>
9<property
10name="defaultTemplate">
<value>/go/calendar</value></property>
In your reactorConfiguration bean:
view plain print about
1<constructor-arg
2name="pathToConfigXml">
<value>/mg/mgCal/config/reactor/Reactor.xml</value></constructor-arg>
3<property
4name="mapping">
<value>/mg/mgCal/model/data/reactor</value></property>
You will want the paths to match those you set up in the previous steps. Now for the tedious part. This was easy for me since I only have a few views, but a complex app with a large number of views will probably be a bit more work. In each view that calls #viewState.getValue('myself')# you will have to, prior to any of those calls run the following statement:
view plain print about
1<cfset
2viewState.setValue('myself',replace(viewState.getValue('myself'),'?','&amp;','ALL'))
3/
>

This is to prevent a url like /go/calendar?event=some.mgEvent from happening. The friendlyURL is hiding some other FarCry URL variables. So there is already a ? in the URL. This will replace the ? that MG creates with an ampersand so you can attach the MG url variables. easily. Thats all it took to get my simple calendar MG app running under FarCry. A more complex app may need more to get running, but at least this will get you started. If any one has any suggestions on a better way to handle this, I am all ears. I tried to find another instance of someone doing this in both the FarCry and Model-Glue lists to no avail.