Now that FW/1 is available for Clojure, you might have looked at the examples that are in the FW/1 github repo and wondered how to create your own FW/1 application from scratch.
Assuming you have Leiningen installed, the easiest way to get started is to install the lein-newnew task and the fw1-template plugin:
> lein plugin install lein-newnew 0.2.2 ... > lein plugin install fw1-template 0.0.6 Copying 1 file to /tmp/lein-c52739ef-eef2-485c-834c-59b4983fafb2/lib Including fw1-template-0.0.6.jar Created fw1-template-0.0.6.jar
That's a one-off task (you'll only need to do that when a new version of the plugin appears). Now you can easily create a FW/1 application:
> lein new fw1 fw1-test
Now you can drop into the new project and run it:
> cd fw1-test/ > lein run [INFO] artifact org.clojure:clojure: checking for updates from clojars [INFO] artifact org.clojure:clojure: checking for updates from central [INFO] artifact org.clojure:clojure: checking for updates from clojure [INFO] artifact org.clojure:clojure: checking for updates from clojure-snapshots Copying 21 files to /home/sean/clojure/fw1-test/lib 2011-11-10 09:28:46.557:INFO::Logging to STDERR via org.mortbay.log.StdErrLog 2011-11-10 09:28:46.565:INFO::jetty-6.1.25 2011-11-10 09:28:46.679:INFO::Started SocketConnector@0.0.0.0:8080
Now browse to http://localhost:8080 and see your new FW/1 app running!
NOTE: This assumes you have nothing running on port 8080. If you need to use a different port, you can specify it on lein run like this:
> PORT=8123 lein run
After you edit your Clojure code, just append ?reload=secret to the URL to pick up the changes. If you edit main.clj to change the app configuration (in the (fw1/start) call), you'll need to quit the process (control-C) and restart it (lein run).

0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment