Blog Archives

MovieBox demo app on GitHub


Just a quick note, I have a project up on GitHub called MovieBox. This was based on keyStream by Cory Fail, but is built on top of the ColdBox framework. Right now it is in a holding pattern because I am going to rewrite it using AngularJS for the frontend and Taffy for the backend REST API. I have been wanting a good learning project for Angular, bower, gulpjs, et al so this will be my guinea pig..

This project does have some pretty good bits, it can scan a directory of movies and pull the metadata from themoviedb.org and update your library accordingly. You will need to specify the default location of your movie directory which is set in /config/Coldbox.cfc under custom settings. Currently the indexer does not run automatically, it must be forced by calling http://localhost/wtf/indexMovies. There is a SQL script for the database creation (mySQL format, but may work on others) to setup the database schema. It expects a data source named moviebox to be setup in the web/server administrator. Additionally, it is assumes the movies are stored as X:/movies/moviename or even better X:/movies/moviename (year).

All videos should be available to the web server under the /media directory. Assuming you are using Nginx as the front end proxy it is an easy as creating an alias in your site definition, but it should be easy enough to do in other servers.

If your server does not support SES URLs you must edit the /config/Routes.cfm and add “index.cfm” to the setBaseURL() line. Also, I would definitely recommend using the development branch as it is the most updated (and also contains the SQL script for database generation).

Aside from that, everything should work great. 🙂  The indexer will attempt to download the movie poster and backdrop and will copy the data into the movie folder as well as the data folder under the web root. If the data folder does not exist it will be created for you. If you have a lot of data, expect the initial look up to take a while. Subsequent scans will ignore titles that are already known.

You can check it out here: https://github.com/robertz/moviebox/tree/development

Advertisements

CommandBox is not just for ColdBox


A few weeks ago I think it was Ray who had posted something about CommandBox. I had heard about it before its release, but I totally missed it when it was unveiled at Into the Box.

I have to say it has quite a few features that I really love. Being able to completely setup a ColdBox application scaffold with just one command is great. The package management system is another awesome feature in and of itself; one that other languages have had a leg up on ColdFusion for a very long time.

One feature that might be easily overlooked (I certainly did) is the embedded server. I did play around with it initially then I promptly forgot all about it. Which brings me to today when I wanted to check out a project from github (Taffy, but that is another post), I wasn’t anywhere near my home machine and I really didn’t want to install Railo Express just to test something out. Turns out it wasn’t an issue, I just extracted all the files out to a directory, fired up CommandBox, typed “server start” and fired up a Railo server I could play around with without any additional configuration needed.

Incidentally, you can access the web/server administrator and it will retain your configuration data for that folder so your settings will persist which also is really awesome.

If you haven’t looked into CommandBox because you don’t use ColdBox it might be worth a look. I look forward to seeing where this project goes in the future. You can see the intro video here: http://www.ortussolutions.com/products/commandbox

themoviedb.org API and ColdFusion


Last week while hanging out in the #coldfusion IRC channel I came across a nifty new app called keyStream created by Cory Fail. In a nutshell, it is a ColdFusion application that allows you to stream your media to your devices while you are attached to your home network. This appeals to my tender sensibilities since I tend to watch movies online more than on a TV.

KeyStream is a great application, one thing that was missing for me was being able to hit an API to pull down movie metadata. If you have a lot of media files it is nice to have an automated way of scanning through a whole directory of files in one fell swoop ala XBMC or comparable media applications. With that in mind, I set to see how difficult it would be to interface with tmdb.org in ColdFusion and I found that it actually was not that difficult.

Here is the TMDBService object for ColdBox although it could easily be ported:

First step though is getting an API key. Cruise over to themoviedb.org and sign up for an API key. It is free so even us starving developers can afford it.

Doing a lookup basically requires two steps. First we will pass the movie name in as a string to the findMovie(name, year) function which goes to the APIs /search/movie endpoint. This will return a list of matches back from tmdb.org, if there is an exact match it will be pushed up to the top of the list. Assuming the first position is the movie we want it is time to go to the APIs /movie/{id} endpoint(getMovieData(id) function in the gist if you are following along), passing it the id we got in the first call. This is where we get all the fun stuff such as the poster and backdrop data, overview, release date and IMDB rating. If you would want to see it when viewing your media, this is where you would find it.

To speed the process up a little bit I created the scrape() method that fires these two calls in one swoop. It assumes it will always have an exact match in the movie title, things get a little hairy when there isn’t an exact match but this is still a work in progress.

 

The final step is to call the APIs /configuration endpoint if you are wanting to download the cover and background art. This data tells you where to look on their image server for the images since they are sorted out by size and then it is just a matter of making a cfhttp call out and downloading the images to your local server. Assuming there is enough interest I could provide a more detailed accounting of getting this done. The finished product could look something like this:

Simple CF Chat updated to work with ColdBox


Over the long weekend I had a chance to really dig in to ColdBox. We use ColdBox pretty exclusively at work and digging into the framework and getting to the nuts and bolts of things just made sense. My first “hello world” application was porting my old CFChat application over to ColdBox and get it up and running using routes, services and handlers.

The code was pretty ugly when I first posted it up. I went ahead and rewrote the whole thing from the ground up and fixed some of the glaring issues that bothered me since I first “released” it. I also threw out the old javascript file and rewrote that from scratch. 

This was pretty much a dead end project as I could probably implement something much better as a web service, but it did introduce me to a lot of core concepts in ColdBox and that is what it was all about anyway, really.

If you are interested in checking out the shiny new stuff you can check it out here: http://demos.kisdigital.com/demos/chat.

Stripe.cfc now on GitHub


Just a quick note, the Stripe Java API I have been working on is now up on GitHub. I have not had a chance to work on it lately, but I have been meaning to get it up there. 

http://github.com/robertz/StripeCFC

 

Stripe Java API and Railo/ACF Part Deux


I wanted to go ahead and push out my latest update on the Stripe Java API I have been working on, but due to an extremely crazy schedule, I am afraid I cannot attach much documentation now. I hope to remedy that in the future as soon as my schedule lightens up a little. Here is the stripped down CFC. Currently it is able to process a charge as well as grab a list of events from Stripe. Here is the code.

As an example of how to use the CFC, here is a small demo.

A few things to note here. To get around having to javacast the expiration month and years to ints, if you pass them as string values they evaluate correctly. This also applies to the amount field. Any parameter you are allowed to pass according to the java API documentation should work just fine.

Stripe Java API and ColdFusion


I have been working on a pet project for a week or so and I thought it would be nice to add the ability to process payments. I remembered a post I read a while back about using Stripe to process credit card payments so I thought I would give them a shot.

Actually getting them going was not that hard. There are quite a few projects out there wrapping the Stripe API, however most of them are pretty big and I am just looking for something simple. They have a Java API available so I thought I would give that a shot. There is not much information about using the Java API in ColdFusion, so it was a little trial an error.

First, I needed to get two jar files and add them to my classpath; the latest stripe api and also the Google gson jar file (links to both may be found on Stripe’s web site.

The fun part was getting it to work which was easy enough by looking at the API documentation and examining the stripe-java test code on GitHub. Here is what I quickly came up with. Not all functionality is working of course, but at least there is a test charge going through and successfully completing.

I hope to have something more complete working later this week.

Nginx and locking down your WEB-INF folder


I was working on some URL rewriting rules on my server this evening when I was taking a break at work. Just out of curiosity I tried hitting some of the files that are available in the WEB-INF directory and was surprised to find out that I could easily view all my context logs and anything that was not a ColdFusion template. In retrospect, I should not have been surprised but I should have taken steps to prevent that from ever happening.

I have a drop.conf file that gets loaded on every site so blocking directory access on all my sites was just a matter of adding the directive to block access to the directory and restarting nginx.

In hindsight, I should have checked that a long time ago. Hopefully someone will learn from my mistake.

Demo site back up


The past year or so has been extremely busy. Between obligations at work and spending time with my family I really do not have a lot of “extra” time. I fell into the funk I guess every developer gets in to and as a result all my side projects fell off the map.

I have been doing my best to get in to a learning mindset instead of just coasting. To kick things off I started writing my own framework which lead me to wanting to get other things going again. The site is sparse now, but I will be adding things as I go along. The chat demo is working which shows how to setup a quick and easy CF chat as well as demonstrates automatically scrolling a div when adding text to it. A few new features are following as I get them ironed out and as time permits.

http://demos.kisdigital.com

 

 

Nginx connector for Railo/ACF part deux


Edit: This post is now outdated. See this post: https://kisdigital.wordpress.com/2013/03/04/my-final-nginxrailo-connector/

Almost a year ago I posted about an improved connector for nginx proxy to Railo. While I consider myself fortunate moving from Apache over to nginx, it is rather unfortunate that I did not have the time to really test my server setup and understand what was happening under the hood. Then I posted it.

Six months or so ago I drifted away from personal development. My family and work demand much of my attention and I don’t have a lot of “extra” time, but lately I have been trying to spend more time learning new things. As a web developer if your server stack is not solid you are going to be in bad shape so I figured it would be a good time to go back and revisit this.

I thought it would be best to look around and see what folks a lot smarter than me were doing which brought me to KBeezie’s Nginx configuration examples and it was a lot of help. My new server template is based off of his examples, I also went and did some digging in the Railo user group. Special thanks to Serge Droganov in the Railo group  for pointing me the right direction getting the administrator locked down.

This is my default new site template. First we have the default handler that looks to see if the URI exists, if not it looks at the rewrite rules to see if there is a match. If not I want to just load the default document. Here the rewrite rules are enabled SES URLs for the server that will work both with and without the index.cfm in the url (i.e., http://example.com/cool/page or http://example.com/index.cfm/cool/page). My preference leans toward SES URLs because they are much cleaner, but you know what they say about opinions. Standard URLs will work just fine as well.

Second I am hiding the Railo Administrator as it just makes sense. Adding the “internal;” directive to /railo-context/admin/ tells Nginx that you do not want to world to get to it, only rewrites coming from another rewrite rule on the server should be allowed.

Next I am moving my Railo Administrator to http://example.com/secret/location/(server|web).cfm. I was going to try to get a little bit fancier with it, but it works well. Since this is an internal rewrite, we are allowed to pass through to the administrator.

Finally we have the @rewrites named location block that is used by our default handler. If the page being requested does not exist it will try to find a match among these rewrite rules and dispatch the request. These can be built upon later to do some interesting things, but by default it just handles serving the SES urls.

The rest of the directives here describe how to handle static content and what URIs you want dropped automatically such as configuration files, directories, etc which are described in the dropped.conf file. I also included the railo.conf at the bottom of the file which handles passing off ColdFusion files to the app server. It has not changed much from my original post, but I will include it here anyway.

The only changes here are moving the railo-context code out and just keeping it in the server configuration blocks.

I definitely suggest you check out KBeezies. A lot of it is targeted towards PHP, but quite a bit of it is applicable to A/CF and also the Nginx Wiki.