Skip to content

Instantly share code, notes, and snippets.

View brentonashworth's full-sized avatar

Brenton Ashworth brentonashworth

View GitHub Profile
@brentonashworth
brentonashworth / gist:926824
Created April 19, 2011 04:42
Add request header into to form input
(defform foo-form "/foo"
:fields [(hidden :id)
(hidden :remote-addr)
(textfield "Enter Your Foo" :foo)]
:on-cancel "/"
:on-success
#(do
(flash-put! :message (str %))
"/")
:defaults (fn [request]
@brentonashworth
brentonashworth / gist:1343920
Created November 7, 2011 00:50
ClojureScript Demo
;; ClojureScript Demo
;; ==================
(use 'cljs.closure)
;; ClojureScript compiler examples
(println (-compile '(defn add [a b] (+ a b)) {}))
(println (-compile '(defn add [& args] (reduce + args)) {}))
;; This is a clojure.test test case which enters a value in a form
;; field in the browser, clicks the submit button and checks that the
;; correct information is displayed in the page and that the client
;; and server state is as it should be. 'database' is an atom in the
;; server and 'state' is an atom in the browser.
(deftest test-enter-name
(reset! database #{})
;; evaluate two forms in the browser in the start.view namespace
(cljs-eval start.view
(dom/set-value :name-input "Ted")
(ns hack.queue)
(defn log [form]
(.log js/console (pr-str form)))
(defprotocol Queue
(pop [this])
(empty? [this])
(peek [this])
(append [this x]))
(def default-special-fns
(let [load-file-fn (fn [repl-env file] (load-file repl-env file))]
{'in-ns (fn [_ quoted-ns] (set! comp/*cljs-ns* (second quoted-ns)))
'load-file load-file-fn
'clojure.core/load-file load-file-fn
'load-namespace (fn [repl-env ns] (load-namespace repl-env ns))}))
(defn repl
"Note - repl will reload core.cljs every time, even if supplied old repl-env"
[repl-env & {:keys [verbose warn-on-undeclared special-fns]}]
(ns hammock-cafe.ui.history
(:require [io.pedestal.app.protocols :as p]
[io.pedestal.app.util.log :as log]
[io.pedestal.app.messages :as msg]))
(def last-page (atom nil))
(def dispatchers (atom {}))
(defn navigate [token]