Falcon web programming on DreamHost
Monday, November 21, 2011 6:32:42 AM
Installation of Falcon 0.9.6.8, http://www.falconpl.org/project_dl/_official_rel/Falcon-0.9.6.8.tgz on DreamHost (without sudo root permissions) is a breeze.
You'll need CMake from http://www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz and the above Falcon sources.
Step by stepLogin to your DreamHost shell. I'll use wip for the work in progress directory for the sample, and /home/me as a made up DreamHost shell login directory. So, as you'll see below, the binaries for CMake and Falcon will end up in /home/me/wip/bin and you need to tweak your shell PATH to suit. Same for the shared object library path. I use LD_LIBRARY_PATH for the development setup, but for production, it would be far better to use LD_RUN_PATH during the build of Falcon so the web server won't have problems finding things for us when we start exposing web applications.
$ mkdir wip $ wget http://www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz $ tar xvf cmake-2.8.6.tar.gz $ cd cmake-2.8.6 $ ./bootstrap --prefix=/home/me/wip $ make $ make install $ cd .. $# The line below links in cmake and ccmake $ export PATH=/home/me/wip/bin:$PATH $ wget http://www.falconpl.org/project_dl/_official_rel/Falcon-0.9.6.8.tgz $ tar xvf Falcon-0.9.6.8.tgz $ cd Falcon-0.9.6.8 $ mkdir build $ cd build $# config with shipped defaults $# which also gives the build/ directory starter files for ccmake tweaks $ cmake .. $# tweak for more appropriate development use on DreamHost $# you need to set the install dir to /home/me/wip $# and want to turn on WOPI, and falhttp $# for Nest framework website development $# ccmake is an ncurses frontend to the build options $ ccmake . $ cmake .. $ make $ make install $# Now test our shiny new Falcon in wip/emptynest $ cd /home/me/wip $ mkdir emptynest $ cd emptynest $ export LD_LIBRARY_PATH=/home/me/wip/lib $ falcon -i > "woo hoo!" > "Falcon!" > "YELLING!" Ctrl-DIf you plan on much interactive Falcon, that would be a good plan, turning on EditLine in ccmake is worthwhile.
Falcon Web Oriented Programming Interface
Falcon comes replete with net capable modules. The basis being WOPI and the current top-level being the Nest framework. See the Falcon site for a lot more information.
The empty introductionAn empty Nest project only needs two source files. We need a sample index.fal in /home/me/wip/emptynest
// index.fal load nest // Tell nest to start. Nest.route()and then a nest framework starting with
$# inside wip/emptynest $ mkdir -p nest/pages/and put the code below in nest/pages/home.ftd
<html> <head> <title>My first Nest site</title> </head> <body> <h1>Welcome!</h1> <p> Welcome to my first Nest Site. I hope you enjoy it,</p> <p>Running with Falcon <?= ".".merge(vmVersionInfo()) ?></p> </body> </html>then start up a test web engine (which starts up the Falcon testhead web server, homed on the current dir, /home/me/wip/emptynest, using port 8084 for connects and looking in our local install for Falcon modules).
$ falhttpd -h /home/me/wip/emptynest -p 8084 -L /home/me/wip/lib/falconand a browse to http://mydreamhosteddomain.moc:8084 should show something akin to
Welcome! Welcome to my first Nest Site. I hope you enjoy it, Running with Falcon 9.6.8plain, but extremely satisfying, being so smooth and easy.
That's it. A Falcon MVC framework (or the TLA Giancarlo uses, Server-Database-Script) installed and ready to explore on DreamHost hosted shell accounts.
small sidetrip into these Falcon code samples
The home.ftd is a Falcon Template Document, which is loaded by the Nest.route() in the index.fal script as a default start page to this web application. A cool bit, in my humble opinion is the merge() call. The Falcon vmVersionInfo() function returns an array. The string "." is used to trigger the merge method converting the array [9,6,8] into the handy and human friendly "9.6.8" in a beautifully concise fashion. ".".merge(vmVersionInfo()). One of my favourite things about Falcon scripting is the assistive (by being pervasive) forfirst, formiddle, forlast semantics. Excellent for proper defensive fencing in code, while being efficient to wield.
For a lot more information, including nest application design, skins, menus, data managers and all the other fun, read the Nest quickstart at http://falconpl.org/project_docs/falcon_nest/quickstart.html from http://falconpl.org and look in the Falcon-0.9.6.8/tests/frameworks/nest/ directory of the source tree for quick start sample source code.
From start to finish while going at a "read all the READMEs" pace, the CMake and Falcon source package installs and the Nest test pass took just under an hour. Woohoo! YELLING!Cheers,