tjg / reagent-template

A Leiningen template for projects using Reagent.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reagent-template

A Leiningen template for projects using Reagent.

reagent-template

A Leiningen template for a Clojure/ClojureScript app based on Reagent, with a focus on providing a batteries included setup for development and deployment.

Development

The template provides dynamic reloading of Clojure, ClojureScript, and CSS and a browser-connected REPL via Figwheel.

Deployment

The template uses lein-ring to provide support of standalone runnable jar or war for container deployment. A Procfile along with the necessary artifacts for Heroku deployment is also provided.

Getting Help

For any questions or discussion please come join us at the Reagent Google Group.

Usage

Create a new application project:

lein new reagent <name>

To enable clojurescript testing with PhantomJS, use +test flag:

lein new reagent <name> +test

To run the tests, please use lein cljsbuild test. For installation instructions of PhantomJS, please see this.

To enable cljx support use +cljx flag:

lein new reagent <name> +cljx

When using cljx make sure to run lein cljx to cross-compile cljx namespaces.

Development mode

To run the development server, run

lein figwheel

Figwheel will automatically push cljs changes to the browser.

Wait a bit, then browse to http://localhost:3449.

Optional development tools

Start the browser REPL:

$ lein repl

The Jetty server can be started by running:

(start-server)

and stopped by running:

(stop-server)

The browser REPL can be started by calling the following command:

(browser-repl)

Building for release

lein cljsbuild clean
lein ring uberjar

Deploying to Heroku

Make sure you have Git and Heroku toolbelt installed, then simply follow the steps below.

Optionally, test that your application runs locally with foreman by running.

foreman start

Now, you can initialize your git repo and commit your application.

git init
git add .
git commit -m "init"

create your app on Heroku

heroku create

optionally, create a database for the application

heroku addons:add heroku-postgresql

The connection settings can be found at your Heroku dashboard under the add-ons for the app.

deploy the application

git push heroku master

Your application should now be deployed to Heroku! For further instructions see the official documentation.

Contents

The template packages everything you need to create a production ready ClojureScript application following current best practices. The template uses the following features and libraries:

  • Reagent - ClojureScript interface to Facebook's React
  • reagent-forms - data binding library for Reagent
  • reagent-utils - utilities such as session and cookie management
  • Secretary - client-side routing
  • Hiccup - server-side HTML templating
  • Compojure - a popular routing library
  • Ring - Clojure HTTP interface
  • Prone - better exception reporting middleware for Ring
  • Heroku - the template is setup to work on Heroku out of the box, simply run git push heroku master
  • clojurescript.test - a maximal port of clojure.test to ClojureScript

Options

The template supports the following options:

  • +cljx - enable cross-compiling of Clojure/Script sources
  • +test - ClojureScript testing support

Contributing & Customizing

Take a look at the open issues, especially ones marked as help wanted. If you see one you'd like to address don't hesitate to start a discussion or submit a pull request.

If the template isn't doing quite what you're looking for, it's easy to create a local copy of your own following these simple steps:

git clone https://github.com/reagent-project/reagent-template.git
cd reagent-template
lein install

If you feel that your customizations are general enough to be useful for others then please consider making a pull request.

Requirements

  • JDK 1.7+
  • Leiningen 2.x

License

Copyright © 2015 Dmitri Sotnikov

Distributed under the The MIT License (MIT).

About

A Leiningen template for projects using Reagent.

License:MIT License


Languages

Language:Clojure 97.4%Language:CSS 2.6%