Tuesday, December 4, 2012

HTML5 Video

I recently had to post a lot of videos on a cfwheels site.
The videos needed to be behind a login, so to achieve that I put a little function in the Controllers/Controller.cfc. I was passing the videoid in the url so I just cued off that.

So then I just set a filter on my sitepages controller to run on the page.
<cfset filters(through="memberloginRequired", only="show")>

I had to report on the videos, so for the video playback, I used the Projekktor video player. It has a flash fallback and it had a tracking plugin that I bought to keep track of all player events and states.
http://www.projekktor.com/docs/plugins_tracking

To make the video available to the most people, we used mp4 and ogv
I had a little trouble figuring out how everything has to fit together, but basically you have to go into IIS and add support for the video types, so you have to add MIME types for video/mp4 and video/ogg with an ogv extension. This will add the following to your web.config file just under your rewrite tag:

One problem I ran into was browser's not recognizing the mp4 so I ended up taking the type out of that in the video page script:
Altogether adding html5 videos was very nice. However, we are still having some people reporting problems, so next I'm going to write a little script to help with debugging. I will try to post that later.

Thursday, October 11, 2012

CKEditor: Styling the Text Box

In the ckeditor/config.js file add:

config.contentsCss = ['/stylesheets/screen.css','/stylesheets/src/grid2.css',  '/stylesheets/print.css', '/stylesheets/style.css', '/stylesheets/tabs.css'];

Sunday, October 7, 2012

DBMigrate and References

Just wanted to blog about my issues using CFWheels DBMigrate with MySQL.
I am using MySQL 5.5 now, but up until recently had 5.1 on my local box and that meant tables defaulted to MyISAM.
I couldn't create foreign keys through DBMigrate on MyISAM tables. 
I would get errno 150 and errno 152 when attempting to create references.

Now that I've updated it's not so much of an issue anymore. But I am still having issues with removing references.

I can't seem to use dropReference or removeColumn to get rid of references, instead I have to
use a combination of:

dropForeignKey(table='videostatistics', keyName='videostatistics_ibfk_2');removeIndex(table='videostatistics', indexName='FK_videostatistics_agendaitems');
removeColumn(table='videostatistics', columnName='agendaitemid');


Wednesday, August 29, 2012

Disposable Laptops

I don't know why I call them "disposable" ... they always gather dust for a few years under the bed before I "dispose" of them. After a cup of coffee in the keyboard and a back flip off the bed that cracked the screen, I had to bite the bullet and buy another laptop.

 I vote for the man, not the brand so to speak so I try not to bring pre-conceived notions to the table when buying a laptop. I want power, speed, and portability. I want a mobile office that works as hard as I do, and that's hard to find! This one is an HP dv7 with the Intel Core i7-2670QM Processor 2.20GHz, 8 mb of ram and a terabyte drive and (we'll soon see) 9 1/2 hours of battery life.

Right away, I already see that I don't like the location of the power input right next to the disk drive. With it plugged in, it makes it too hard to get disks in and out.

Anyway I always cringe when I have to setup a new computer, so I thought I would create a deployment strategy. I'm going to give it my best shot, so that I can forget all this and come back here next time I crack my computer.

First things first, Adobe Master Collection goes on my disk.

MS Office (export all emails from Outlook - this is time consuming - export inbox, sent and deleted folders to csv and then import ) I found that the export didn't transfer all of my emails. Will have to look into that further. Had to set up all email accounts.

Next I really need to use IIS for my local server, but I have had problems in the past with setting it up with git so I end up using Apache. So SNAG. Let's see if this time I can set it up properly.

Am on Windows 7 Home Premium so had to enable the IIS server
That was easy:
http://technet.microsoft.com/en-us/library/cc731911.aspx

Next installed CF9 to work with IIS - ran into some problems here that were resolved by this excellent article: http://www.codecurry.com/2009/09/installing-coldfusion-on-iis-7.html

Basically installing IIS isn't enough. You have to go into Windows Features and turn on ISAPI filters and extensions and you have to check IIS metabase and IIS 6 compatibility.

So far so good - had to remember to edit the C:\Windows\System32\drivers\etc\hosts file to point the IP address to the header host name.

Then I had a major headache trying to save sites in the C:\Users\Cathy folder. Why do I want to save them there? Quite honestly, my reason is just because it's easier to use git from that folder. I ended up having to assign a username and password to the anonymous login. This was really not straightforward and there were no good articles on it that I could find. To do that, right click on the root folder in IIS and double click on Authentication, then right click on Anonymous Authentication and enter your username and password there. I used the username and password I use to log onto the computer. You also have to make sure the user you specify has permissions to at least read the contents of the directory where you are putting your site. On this, it was no problem since I am putting the sites in my own user folder.

But then, I ran into another snag with the URL rewriting not working. I tried installing this: http://www.microsoft.com/web/gallery/install.aspx?appid=urlrewrite2 with no luck.

After a lot of frustration, I decided it was easier to just leave the darn site in the inetpub wwwroot folder! If I ever figure that out, I'll post.

After that, I installed MySQL 5.5. They have made this a lot easier with a windows installer.

Installed mysysgit - now for this I had to generate another key for SSH. Here are the instructions: https://help.github.com/articles/generating-ssh-keys

I still have to figure out how to eliminate having to type in the passphrase.

Installed CFBuilder - had to add the details for the server

and installed WS_FTP Pro. On this, I had to go to the c:\users\cathy\appdata\roaming\ipswitch\ws_ftp\sites folder and copy the ws_ftp.ini file to my new computer to get my existing sites.

Navicat Premium (Transfer over all databases - this was easy to just export and import my connections).

then I just have to deal with my pet peeves like showing file extension types: http://support.microsoft.com/kb/865219






Monday, June 11, 2012

Simple jquery form in cfwheels

Quite often I find myself needing a simple contact form in my main layout. I want the form available on all pages, and I don't want a page refresh when the form is submitted. It needs some simple validation too. So here's how I accomplish that. First I build a form in the layout.
The important parts of the form are:
  • The form and all elements have id's
  • There are labels after form fields that need validation
Make sure you include jquery in the head of your layout

Okay, so now let's add some jquery. We have a lot going on here so I tried to put good notes in the script. The important thing to remember here is that on the ajax submission it's very important that you append ?format=json on the end of the url.

Now let's enable json in cfwheels.

Just go to your contacts controller, and in your init function, add the provides function that our cfwheels developers have provided for us.

Now we'll use the renderWith() function when we create our method.

So all that remains is to handle the form submission in a controller action.

The action should be self explanatory. We are taking the form fields and saving them to the database and sending out an email if the save is successful. If you want to use wheels to validate your email field, you could put validation in the model, and then send back the error message.

Couple of notes. Doing it this way, I don't get isJSON to equal true. If I stringify the form fields, then isJSON equals true but then I can't figure out how to pull out my individual form fields. Also, make sure you turn off debugging in ColdFusion to see the response. Otherwise, you won't see it.

So anyway, this works for me for now. Would appreciate any comments or suggestions to make it easier!

Tuesday, April 10, 2012

MySQL Time bomb at Midnight

I've been working around this issue for ages. MySQL won't store 00:00:00 as midnight. Apparently it's illegal to store that in MySQL. I never really thought about it until I "had" to store midnight in a time field.
The solution is really simple. Just add this to your database connection string in your datasource in the ColdFusion Administrator: useFastDateParsing=false