Giter Site home page Giter Site logo

gyag-template's Introduction

gyag

  1. Tibetan for yak (or so I am told).
  2. An opinionated Leiningen template for developing web applications using Clojure and ClojureScript.

Features

  • Reliable and fast code reloads for Clojure code during development
  • Based on the Clojure de facto standard Ring
  • Hiccup server-side rendered HTML pages
  • Easy REST Api using Liberator
  • Fast, debuggable, ClojureScript builds with source maps
  • In-browser ClojureScript REPL via Austin

Usage

Prerequisite

Install Leiningen.

Initializing the template

Initialize your new Leiningen project: lein new gyag $your-project

ClojureScript compilation (browser-side)

Contains two ClojureScript build profiles:

  • dev : Source maps and no optimizations, multiple js-files
  • production : Advanced optimization to a single js-file

Build command examples:

  • Continuous builds of dev profile (occupies one terminal) and will rebuild the js-files from all changes in src-cljs: lein cljsbuild auto dev
  • Building production profile once: lein cljsbuild once production

Clojure compilation / dev cycle (server-side)

The project uses the excellent component and tools.nrepl libraries to enable fast and reliable code reloads. See component on github and REPL-driven development workflow.

Example:

  1. Start a nRepl for your project:
  • M-x cider-jack-in or M-x nrepl-jack-in in Emacs
  • lein repl from the command-line
  1. In the REPL start the server-side by issuing (go) which should produce something similar to this:
user> (go)
2014-feb-05 21:52:00 +0100 Aero.local INFO [myone.app] - Starting Myone App
2014-feb-05 21:52:00 +0100 Aero.local INFO [myone.web-server] - Starting Web Server
2014-feb-05 21:52:00 +0100 Aero.local INFO [myone.web-server] - Web Server running on port: 8080
2014-feb-05 21:52:00 +0100 Aero.local INFO [myone.repl] - Starting Hosted REPL
2014-feb-05 21:52:00 +0100 Aero.local INFO [myone.repl] - REPL running on port 12345
:ok
  1. The server-side is split into multiple components, which is what is logged out in the above:
  • The app: Ring handler and route compositions
  • The web-server: a Jetty-instance serving the app on HTTP
  • The in-app hosted REPL: live code changes everywhere, whats not to like? (caveat emptor)
  1. You can now open http://localhost:8080 to connect to your running application.
  2. During development, to reload code changes, perform the following in the REPL which launched to app: (user/reset). This performs the following steps:
  3. Stops the currently running components, releasing acquired resources (bound ports etc)
  4. Uses tools.nrepl to reload code under src/
  5. Restarts the components
  6. NOTE: In the case of problems reloading code, eg. compilation errors, first resolve these and then perform (clojure.tools.namespace.repl/refresh) followed by (user/reset)

License

Copyright © 2014 Thomas Christensen

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

gyag-template's People

Contributors

thomaschrstnsn avatar

Stargazers

Michael Rubanov avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.